@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/lib/buildAccount.js
CHANGED
|
@@ -15,17 +15,14 @@ const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
|
15
15
|
const { i18n } = require('./lang');
|
|
16
16
|
const { cliAccountNamePrompt } = require('./prompts/accountNamePrompt');
|
|
17
17
|
const SpinniesManager = require('./ui/SpinniesManager');
|
|
18
|
-
const {
|
|
19
|
-
debugErrorAndContext,
|
|
20
|
-
logErrorInstance,
|
|
21
|
-
} = require('./errorHandlers/standardErrors');
|
|
18
|
+
const { debugError, logError } = require('./errorHandlers/index');
|
|
22
19
|
const {
|
|
23
20
|
createDeveloperTestAccount,
|
|
24
|
-
} = require('@hubspot/local-dev-lib/developerTestAccounts');
|
|
21
|
+
} = require('@hubspot/local-dev-lib/api/developerTestAccounts');
|
|
25
22
|
const {
|
|
26
23
|
HUBSPOT_ACCOUNT_TYPES,
|
|
27
24
|
} = require('@hubspot/local-dev-lib/constants/config');
|
|
28
|
-
const { createSandbox } = require('@hubspot/local-dev-lib/
|
|
25
|
+
const { createSandbox } = require('@hubspot/local-dev-lib/api/sandboxHubs');
|
|
29
26
|
const { sandboxApiTypeMap, handleSandboxCreateError } = require('./sandboxes');
|
|
30
27
|
const {
|
|
31
28
|
handleDeveloperTestAccountCreateError,
|
|
@@ -134,10 +131,13 @@ async function buildNewAccount({
|
|
|
134
131
|
try {
|
|
135
132
|
if (isSandbox) {
|
|
136
133
|
const sandboxApiType = sandboxApiTypeMap[accountType]; // API expects sandbox type as 1 or 2.
|
|
137
|
-
|
|
134
|
+
|
|
135
|
+
const { data } = await createSandbox(accountId, name, sandboxApiType);
|
|
136
|
+
result = { name, ...data };
|
|
138
137
|
resultAccountId = result.sandbox.sandboxHubId;
|
|
139
138
|
} else if (isDeveloperTestAccount) {
|
|
140
|
-
|
|
139
|
+
const { data } = await createDeveloperTestAccount(accountId, name);
|
|
140
|
+
result = data;
|
|
141
141
|
resultAccountId = result.id;
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -148,7 +148,7 @@ async function buildNewAccount({
|
|
|
148
148
|
}),
|
|
149
149
|
});
|
|
150
150
|
} catch (err) {
|
|
151
|
-
|
|
151
|
+
debugError(err);
|
|
152
152
|
|
|
153
153
|
SpinniesManager.fail('buildNewAccount', {
|
|
154
154
|
text: i18n(`${spinniesI18nKey}.fail`, {
|
|
@@ -181,7 +181,7 @@ async function buildNewAccount({
|
|
|
181
181
|
force,
|
|
182
182
|
});
|
|
183
183
|
} catch (err) {
|
|
184
|
-
|
|
184
|
+
logError(err);
|
|
185
185
|
throw err;
|
|
186
186
|
}
|
|
187
187
|
|
|
@@ -5,15 +5,15 @@ const { getAccountId, getConfig } = require('@hubspot/local-dev-lib/config');
|
|
|
5
5
|
const { i18n } = require('./lang');
|
|
6
6
|
const {
|
|
7
7
|
fetchDeveloperTestAccounts,
|
|
8
|
-
} = require('@hubspot/local-dev-lib/developerTestAccounts');
|
|
8
|
+
} = require('@hubspot/local-dev-lib/api/developerTestAccounts');
|
|
9
9
|
const {
|
|
10
10
|
isMissingScopeError,
|
|
11
11
|
isSpecifiedError,
|
|
12
|
-
} = require('@hubspot/local-dev-lib/errors/
|
|
12
|
+
} = require('@hubspot/local-dev-lib/errors/index');
|
|
13
13
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
14
14
|
const { uiAccountDescription } = require('./ui');
|
|
15
15
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
16
|
-
const {
|
|
16
|
+
const { logError } = require('./errorHandlers/index');
|
|
17
17
|
|
|
18
18
|
const getHasDevTestAccounts = appDeveloperAccountConfig => {
|
|
19
19
|
const config = getConfig();
|
|
@@ -32,31 +32,31 @@ const getHasDevTestAccounts = appDeveloperAccountConfig => {
|
|
|
32
32
|
|
|
33
33
|
const validateDevTestAccountUsageLimits = async accountConfig => {
|
|
34
34
|
const accountId = getAccountId(accountConfig.portalId);
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
35
|
+
const { data } = await fetchDeveloperTestAccounts(accountId);
|
|
36
|
+
if (!data) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const limit = data.maxTestPortals;
|
|
40
|
+
const count = data.results.length;
|
|
41
|
+
if (count >= limit) {
|
|
42
|
+
const hasDevTestAccounts = getHasDevTestAccounts(accountConfig);
|
|
43
|
+
if (hasDevTestAccounts) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
i18n('lib.developerTestAccount.create.failure.alreadyInConfig', {
|
|
46
|
+
accountName: accountConfig.name || accountId,
|
|
47
|
+
limit,
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
throw new Error(
|
|
52
|
+
i18n('lib.developerTestAccount.create.failure.limit', {
|
|
53
|
+
accountName: accountConfig.name || accountId,
|
|
54
|
+
limit,
|
|
55
|
+
})
|
|
56
|
+
);
|
|
56
57
|
}
|
|
57
|
-
return response;
|
|
58
58
|
}
|
|
59
|
-
return
|
|
59
|
+
return data;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
function handleDeveloperTestAccountCreateError({
|
|
@@ -94,7 +94,7 @@ function handleDeveloperTestAccountCreateError({
|
|
|
94
94
|
);
|
|
95
95
|
logger.log('');
|
|
96
96
|
} else {
|
|
97
|
-
|
|
97
|
+
logError(err);
|
|
98
98
|
}
|
|
99
99
|
throw err;
|
|
100
100
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
+
const {
|
|
3
|
+
isHubSpotHttpError,
|
|
4
|
+
isSystemError,
|
|
5
|
+
isFileSystemError,
|
|
6
|
+
isValidationError,
|
|
7
|
+
isMissingScopeError,
|
|
8
|
+
} = require('@hubspot/local-dev-lib/errors/index');
|
|
9
|
+
const { shouldSuppressError } = require('./suppressError');
|
|
10
|
+
const { i18n } = require('../lang');
|
|
11
|
+
const util = require('util');
|
|
12
|
+
const { isAxiosError } = require('axios');
|
|
13
|
+
|
|
14
|
+
const i18nKey = 'lib.errorHandlers.index';
|
|
15
|
+
|
|
16
|
+
function logError(error, context = {}) {
|
|
17
|
+
debugError(error, context);
|
|
18
|
+
|
|
19
|
+
if (
|
|
20
|
+
shouldSuppressError(error, context) ||
|
|
21
|
+
shouldSuppressError(error, error.context)
|
|
22
|
+
) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (isHubSpotHttpError(error) && context) {
|
|
27
|
+
error.updateContext(context);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (isHubSpotHttpError(error) || isFileSystemError(error)) {
|
|
31
|
+
if (isValidationError(error) || isMissingScopeError(error)) {
|
|
32
|
+
logger.error(error.formattedValidationErrors());
|
|
33
|
+
} else {
|
|
34
|
+
logger.error(error.message);
|
|
35
|
+
}
|
|
36
|
+
} else if (isSystemError(error)) {
|
|
37
|
+
logger.error(error.message);
|
|
38
|
+
} else if (error.message || error.reason) {
|
|
39
|
+
const message = [];
|
|
40
|
+
|
|
41
|
+
[error.message, error.reason].forEach(msg => {
|
|
42
|
+
if (msg) {
|
|
43
|
+
message.push(msg);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
logger.error(message.join(' '));
|
|
47
|
+
} else {
|
|
48
|
+
// Unknown errors
|
|
49
|
+
logger.error(i18n(`${i18nKey}.unknownErrorOccurred`));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Logs (debug) the error and context objects.
|
|
55
|
+
*
|
|
56
|
+
* @param {Error} error
|
|
57
|
+
* @param {ApiErrorContext} context
|
|
58
|
+
*/
|
|
59
|
+
function debugError(error, context = {}) {
|
|
60
|
+
if (isHubSpotHttpError(error)) {
|
|
61
|
+
logger.debug(error.toString());
|
|
62
|
+
} else {
|
|
63
|
+
logger.debug(i18n(`${i18nKey}.errorOccurred`, { error }));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (error.cause) {
|
|
67
|
+
logger.debug(
|
|
68
|
+
i18n(`${i18nKey}.errorCause`, {
|
|
69
|
+
cause: isAxiosError(error.cause)
|
|
70
|
+
? error.cause
|
|
71
|
+
: util.inspect(error.cause, false, null, true),
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
if (context) {
|
|
76
|
+
logger.debug(
|
|
77
|
+
i18n(`${i18nKey}.errorContext`, {
|
|
78
|
+
context: util.inspect(context, false, null, true),
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
class ApiErrorContext {
|
|
85
|
+
constructor(props = {}) {
|
|
86
|
+
/** @type {number} */
|
|
87
|
+
this.accountId = props.accountId;
|
|
88
|
+
/** @type {string} */
|
|
89
|
+
this.request = props.request || '';
|
|
90
|
+
/** @type {string} */
|
|
91
|
+
this.payload = props.payload || '';
|
|
92
|
+
/** @type {string} */
|
|
93
|
+
this.projectName = props.projectName || '';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = {
|
|
98
|
+
logError,
|
|
99
|
+
debugError,
|
|
100
|
+
ApiErrorContext,
|
|
101
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const {
|
|
2
2
|
isSpecifiedError,
|
|
3
3
|
isMissingScopeError,
|
|
4
|
-
} = require('@hubspot/local-dev-lib/errors/
|
|
4
|
+
} = require('@hubspot/local-dev-lib/errors/index');
|
|
5
5
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
6
6
|
const { PLATFORM_VERSION_ERROR_TYPES } = require('../constants');
|
|
7
7
|
const { i18n } = require('../lang');
|
|
@@ -12,7 +12,7 @@ const {
|
|
|
12
12
|
uiCommandReference,
|
|
13
13
|
} = require('../ui');
|
|
14
14
|
|
|
15
|
-
const i18nKey = 'lib.errorHandlers.
|
|
15
|
+
const i18nKey = 'lib.errorHandlers.suppressErrors';
|
|
16
16
|
|
|
17
17
|
function createPlatformVersionError(err, subCategory) {
|
|
18
18
|
let translationKey = 'unspecifiedPlatformVersion';
|
|
@@ -58,7 +58,7 @@ function createPlatformVersionError(err, subCategory) {
|
|
|
58
58
|
uiLine();
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
function
|
|
61
|
+
function shouldSuppressError(err, context = {}) {
|
|
62
62
|
if (isMissingScopeError(err)) {
|
|
63
63
|
logger.error(
|
|
64
64
|
i18n(`${i18nKey}.missingScopeError`, {
|
|
@@ -78,7 +78,7 @@ function overrideErrors(err, context) {
|
|
|
78
78
|
})
|
|
79
79
|
) {
|
|
80
80
|
createPlatformVersionError(
|
|
81
|
-
err,
|
|
81
|
+
err.data,
|
|
82
82
|
PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED
|
|
83
83
|
);
|
|
84
84
|
return true;
|
|
@@ -90,7 +90,7 @@ function overrideErrors(err, context) {
|
|
|
90
90
|
})
|
|
91
91
|
) {
|
|
92
92
|
createPlatformVersionError(
|
|
93
|
-
err,
|
|
93
|
+
err.data,
|
|
94
94
|
PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED
|
|
95
95
|
);
|
|
96
96
|
return true;
|
|
@@ -103,7 +103,7 @@ function overrideErrors(err, context) {
|
|
|
103
103
|
})
|
|
104
104
|
) {
|
|
105
105
|
createPlatformVersionError(
|
|
106
|
-
err,
|
|
106
|
+
err.data,
|
|
107
107
|
PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST
|
|
108
108
|
);
|
|
109
109
|
return true;
|
|
@@ -112,5 +112,5 @@ function overrideErrors(err, context) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
module.exports = {
|
|
115
|
-
|
|
115
|
+
shouldSuppressError,
|
|
116
116
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const {
|
|
2
|
+
fetchEnabledFeatures,
|
|
3
|
+
} = require('@hubspot/local-dev-lib/api/localDevAuth');
|
|
4
|
+
|
|
5
|
+
const hasFeature = async (accountId, feature) => {
|
|
6
|
+
const {
|
|
7
|
+
data: { enabledFeatures },
|
|
8
|
+
} = await fetchEnabledFeatures(accountId);
|
|
9
|
+
|
|
10
|
+
return enabledFeatures[feature];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
hasFeature,
|
|
15
|
+
};
|
package/lib/localDev.js
CHANGED
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
const {
|
|
7
7
|
isMissingScopeError,
|
|
8
8
|
isSpecifiedError,
|
|
9
|
-
} = require('@hubspot/local-dev-lib/errors/
|
|
9
|
+
} = require('@hubspot/local-dev-lib/errors/index');
|
|
10
10
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
11
11
|
const { getAccountConfig, getEnv } = require('@hubspot/local-dev-lib/config');
|
|
12
12
|
const { createProject } = require('@hubspot/local-dev-lib/api/projects');
|
|
@@ -28,7 +28,6 @@ const { syncSandbox } = require('./sandboxSync');
|
|
|
28
28
|
const {
|
|
29
29
|
validateDevTestAccountUsageLimits,
|
|
30
30
|
} = require('./developerTestAccounts');
|
|
31
|
-
const { logErrorInstance } = require('./errorHandlers/standardErrors');
|
|
32
31
|
const { uiCommandReference, uiLine, uiAccountDescription } = require('./ui');
|
|
33
32
|
const SpinniesManager = require('./ui/SpinniesManager');
|
|
34
33
|
const { i18n } = require('./lang');
|
|
@@ -47,10 +46,7 @@ const {
|
|
|
47
46
|
PROJECT_BUILD_TEXT,
|
|
48
47
|
PROJECT_DEPLOY_TEXT,
|
|
49
48
|
} = require('./constants');
|
|
50
|
-
const {
|
|
51
|
-
logApiErrorInstance,
|
|
52
|
-
ApiErrorContext,
|
|
53
|
-
} = require('./errorHandlers/apiErrors');
|
|
49
|
+
const { logError, ApiErrorContext } = require('./errorHandlers/index');
|
|
54
50
|
const {
|
|
55
51
|
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
56
52
|
} = require('@hubspot/local-dev-lib/constants/auth');
|
|
@@ -82,11 +78,19 @@ const confirmDefaultAccountIsTarget = async accountConfig => {
|
|
|
82
78
|
}
|
|
83
79
|
};
|
|
84
80
|
|
|
85
|
-
// Confirm the default account is
|
|
86
|
-
const
|
|
87
|
-
if (!isAppDeveloperAccount(accountConfig)) {
|
|
81
|
+
// Confirm the default account is supported for the type of apps being developed
|
|
82
|
+
const checkIfDefaultAccountIsSupported = (accountConfig, hasPublicApps) => {
|
|
83
|
+
if (hasPublicApps && !isAppDeveloperAccount(accountConfig)) {
|
|
88
84
|
logger.error(
|
|
89
|
-
i18n(`${i18nKey}.
|
|
85
|
+
i18n(`${i18nKey}.checkIfDefaultAccountIsSupported.publicApp`, {
|
|
86
|
+
useCommand: uiCommandReference('hs accounts use'),
|
|
87
|
+
authCommand: uiCommandReference('hs auth'),
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
91
|
+
} else if (!hasPublicApps && isAppDeveloperAccount(accountConfig)) {
|
|
92
|
+
logger.error(
|
|
93
|
+
i18n(`${i18nKey}.checkIfDefaultAccountIsSupported.privateApp`, {
|
|
90
94
|
useCommand: uiCommandReference('hs accounts use'),
|
|
91
95
|
authCommand: uiCommandReference('hs auth'),
|
|
92
96
|
})
|
|
@@ -111,7 +115,7 @@ const checkIfParentAccountIsAuthed = accountConfig => {
|
|
|
111
115
|
};
|
|
112
116
|
|
|
113
117
|
// Confirm the default account is a developer account if developing public apps
|
|
114
|
-
const
|
|
118
|
+
const checkIfAccountFlagIsSupported = (accountConfig, hasPublicApps) => {
|
|
115
119
|
if (hasPublicApps) {
|
|
116
120
|
if (!isDeveloperTestAccount) {
|
|
117
121
|
logger.error(
|
|
@@ -184,7 +188,7 @@ const createSandboxForLocalDev = async (accountId, accountConfig, env) => {
|
|
|
184
188
|
})
|
|
185
189
|
);
|
|
186
190
|
} else {
|
|
187
|
-
|
|
191
|
+
logError(err);
|
|
188
192
|
}
|
|
189
193
|
process.exit(EXIT_CODES.ERROR);
|
|
190
194
|
}
|
|
@@ -223,7 +227,7 @@ const createSandboxForLocalDev = async (accountId, accountConfig, env) => {
|
|
|
223
227
|
});
|
|
224
228
|
return targetAccountId;
|
|
225
229
|
} catch (err) {
|
|
226
|
-
|
|
230
|
+
logError(err);
|
|
227
231
|
process.exit(EXIT_CODES.ERROR);
|
|
228
232
|
}
|
|
229
233
|
};
|
|
@@ -262,7 +266,7 @@ const createDeveloperTestAccountForLocalDev = async (
|
|
|
262
266
|
})
|
|
263
267
|
);
|
|
264
268
|
} else {
|
|
265
|
-
|
|
269
|
+
logError(err);
|
|
266
270
|
}
|
|
267
271
|
process.exit(EXIT_CODES.ERROR);
|
|
268
272
|
}
|
|
@@ -288,7 +292,7 @@ const createDeveloperTestAccountForLocalDev = async (
|
|
|
288
292
|
|
|
289
293
|
return result.id;
|
|
290
294
|
} catch (err) {
|
|
291
|
-
|
|
295
|
+
logError(err);
|
|
292
296
|
process.exit(EXIT_CODES.ERROR);
|
|
293
297
|
}
|
|
294
298
|
};
|
|
@@ -367,7 +371,10 @@ const createNewProjectForLocalDev = async (
|
|
|
367
371
|
});
|
|
368
372
|
|
|
369
373
|
try {
|
|
370
|
-
const project = await createProject(
|
|
374
|
+
const { data: project } = await createProject(
|
|
375
|
+
targetAccountId,
|
|
376
|
+
projectConfig.name
|
|
377
|
+
);
|
|
371
378
|
SpinniesManager.succeed('createProject', {
|
|
372
379
|
text: i18n(`${i18nKey}.createNewProjectForLocalDev.createdProject`, {
|
|
373
380
|
accountIdentifier: uiAccountDescription(targetAccountId),
|
|
@@ -420,7 +427,7 @@ const createInitialBuildForNewProject = async (
|
|
|
420
427
|
);
|
|
421
428
|
logger.log();
|
|
422
429
|
} else {
|
|
423
|
-
|
|
430
|
+
logError(
|
|
424
431
|
initialUploadResult.uploadError,
|
|
425
432
|
new ApiErrorContext({
|
|
426
433
|
accountId: targetAccountId,
|
|
@@ -465,8 +472,8 @@ const getAccountHomeUrl = accountId => {
|
|
|
465
472
|
|
|
466
473
|
module.exports = {
|
|
467
474
|
confirmDefaultAccountIsTarget,
|
|
468
|
-
|
|
469
|
-
|
|
475
|
+
checkIfDefaultAccountIsSupported,
|
|
476
|
+
checkIfAccountFlagIsSupported,
|
|
470
477
|
suggestRecommendedNestedAccount,
|
|
471
478
|
createSandboxForLocalDev,
|
|
472
479
|
createDeveloperTestAccountForLocalDev,
|
|
@@ -14,7 +14,7 @@ const SLEEP_TIME = 2000;
|
|
|
14
14
|
const kickOffValidation = async (accountId, assetType, src) => {
|
|
15
15
|
const requestGroup = 'EXTERNAL_DEVELOPER';
|
|
16
16
|
try {
|
|
17
|
-
const requestResult = await requestValidation(accountId, {
|
|
17
|
+
const { data: requestResult } = await requestValidation(accountId, {
|
|
18
18
|
path: src,
|
|
19
19
|
assetType,
|
|
20
20
|
requestGroup,
|
|
@@ -29,7 +29,7 @@ const kickOffValidation = async (accountId, assetType, src) => {
|
|
|
29
29
|
const pollForValidationFinish = async (accountId, validationId) => {
|
|
30
30
|
try {
|
|
31
31
|
const checkValidationStatus = async () => {
|
|
32
|
-
const validationStatus = await getValidationStatus(accountId, {
|
|
32
|
+
const { data: validationStatus } = await getValidationStatus(accountId, {
|
|
33
33
|
validationId,
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -47,7 +47,7 @@ const pollForValidationFinish = async (accountId, validationId) => {
|
|
|
47
47
|
|
|
48
48
|
const fetchValidationResults = async (accountId, validationId) => {
|
|
49
49
|
try {
|
|
50
|
-
const validationResults = await getValidationResults(accountId, {
|
|
50
|
+
const { data: validationResults } = await getValidationResults(accountId, {
|
|
51
51
|
validationId,
|
|
52
52
|
});
|
|
53
53
|
return validationResults;
|
package/lib/oauth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const express = require('express');
|
|
2
2
|
const open = require('open');
|
|
3
3
|
const {
|
|
4
|
-
|
|
4
|
+
OAuth2Manager,
|
|
5
5
|
} = require('@hubspot/local-dev-lib/models/OAuth2Manager');
|
|
6
6
|
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
7
7
|
const { addOauthToAccountConfig } = require('@hubspot/local-dev-lib/oauth');
|
package/lib/polling.js
CHANGED
|
@@ -4,7 +4,7 @@ const poll = (callback, accountId, taskId) => {
|
|
|
4
4
|
return new Promise((resolve, reject) => {
|
|
5
5
|
const pollInterval = setInterval(async () => {
|
|
6
6
|
try {
|
|
7
|
-
const pollResp = await callback(accountId, taskId);
|
|
7
|
+
const { data: pollResp } = await callback(accountId, taskId);
|
|
8
8
|
const { status } = pollResp;
|
|
9
9
|
|
|
10
10
|
if (status === POLLING_STATUS.SUCCESS) {
|
|
@@ -54,10 +54,9 @@ class ProjectLogsManager {
|
|
|
54
54
|
throw new Error(i18n(`${i18nKey}.errors.noProjectConfig`));
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
);
|
|
57
|
+
const {
|
|
58
|
+
data: { topLevelComponentMetadata },
|
|
59
|
+
} = await fetchProjectComponentsMetadata(this.accountId, this.projectId);
|
|
61
60
|
|
|
62
61
|
const apps = topLevelComponentMetadata.filter(componentMetadata => {
|
|
63
62
|
const { type } = componentMetadata;
|
package/lib/projectStructure.js
CHANGED
|
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { walk } = require('@hubspot/local-dev-lib/fs');
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
|
-
const {
|
|
5
|
+
const { logError } = require('./errorHandlers/index');
|
|
6
6
|
|
|
7
7
|
const COMPONENT_TYPES = Object.freeze({
|
|
8
8
|
privateApp: 'private-app',
|
|
@@ -94,7 +94,7 @@ async function findProjectComponents(projectSourceDir) {
|
|
|
94
94
|
try {
|
|
95
95
|
projectFiles = await walk(projectSourceDir);
|
|
96
96
|
} catch (e) {
|
|
97
|
-
|
|
97
|
+
logError(e);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
projectFiles.forEach(projectFile => {
|
package/lib/projects.js
CHANGED
|
@@ -33,10 +33,7 @@ const {
|
|
|
33
33
|
fetchBuildWarnLogs,
|
|
34
34
|
fetchDeployWarnLogs,
|
|
35
35
|
} = require('@hubspot/local-dev-lib/api/projects');
|
|
36
|
-
const {
|
|
37
|
-
isSpecifiedError,
|
|
38
|
-
isSpecifiedHubSpotAuthError,
|
|
39
|
-
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
36
|
+
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
40
37
|
const { shouldIgnoreFile } = require('@hubspot/local-dev-lib/ignoreRules');
|
|
41
38
|
const { getCwd, getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
42
39
|
const { downloadGithubRepoContents } = require('@hubspot/local-dev-lib/github');
|
|
@@ -45,10 +42,7 @@ const { EXIT_CODES } = require('./enums/exitCodes');
|
|
|
45
42
|
const { uiLine, uiLink, uiAccountDescription } = require('../lib/ui');
|
|
46
43
|
const { i18n } = require('./lang');
|
|
47
44
|
const SpinniesManager = require('./ui/SpinniesManager');
|
|
48
|
-
const {
|
|
49
|
-
logApiErrorInstance,
|
|
50
|
-
ApiErrorContext,
|
|
51
|
-
} = require('./errorHandlers/apiErrors');
|
|
45
|
+
const { logError, ApiErrorContext } = require('./errorHandlers/index');
|
|
52
46
|
|
|
53
47
|
const i18nKey = 'lib.projects';
|
|
54
48
|
|
|
@@ -215,11 +209,11 @@ const pollFetchProject = async (accountId, projectName) => {
|
|
|
215
209
|
});
|
|
216
210
|
const pollInterval = setInterval(async () => {
|
|
217
211
|
try {
|
|
218
|
-
const
|
|
219
|
-
if (
|
|
212
|
+
const response = await fetchProject(accountId, projectName);
|
|
213
|
+
if (response && response.data) {
|
|
220
214
|
SpinniesManager.remove('pollFetchProject');
|
|
221
215
|
clearInterval(pollInterval);
|
|
222
|
-
resolve(
|
|
216
|
+
resolve(response);
|
|
223
217
|
}
|
|
224
218
|
} catch (err) {
|
|
225
219
|
if (
|
|
@@ -254,7 +248,7 @@ const ensureProjectExists = async (
|
|
|
254
248
|
) => {
|
|
255
249
|
const accountIdentifier = uiAccountDescription(accountId);
|
|
256
250
|
try {
|
|
257
|
-
const project = withPolling
|
|
251
|
+
const { data: project } = withPolling
|
|
258
252
|
? await pollFetchProject(accountId, projectName)
|
|
259
253
|
: await fetchProject(accountId, projectName);
|
|
260
254
|
return { projectExists: !!project, project };
|
|
@@ -278,7 +272,7 @@ const ensureProjectExists = async (
|
|
|
278
272
|
|
|
279
273
|
if (shouldCreateProject) {
|
|
280
274
|
try {
|
|
281
|
-
const project = await createProject(accountId, projectName);
|
|
275
|
+
const { data: project } = await createProject(accountId, projectName);
|
|
282
276
|
logger.success(
|
|
283
277
|
i18n(`${i18nKey}.ensureProjectExists.createSuccess`, {
|
|
284
278
|
projectName,
|
|
@@ -287,7 +281,7 @@ const ensureProjectExists = async (
|
|
|
287
281
|
);
|
|
288
282
|
return { projectExists: true, project };
|
|
289
283
|
} catch (err) {
|
|
290
|
-
return
|
|
284
|
+
return logError(err, new ApiErrorContext({ accountId }));
|
|
291
285
|
}
|
|
292
286
|
} else {
|
|
293
287
|
if (!noLogs) {
|
|
@@ -302,14 +296,14 @@ const ensureProjectExists = async (
|
|
|
302
296
|
}
|
|
303
297
|
}
|
|
304
298
|
if (
|
|
305
|
-
|
|
299
|
+
isSpecifiedError(err, {
|
|
306
300
|
statusCode: 401,
|
|
307
301
|
})
|
|
308
302
|
) {
|
|
309
303
|
logger.error(err.message);
|
|
310
304
|
process.exit(EXIT_CODES.ERROR);
|
|
311
305
|
}
|
|
312
|
-
|
|
306
|
+
logError(err, new ApiErrorContext({ accountId }));
|
|
313
307
|
process.exit(EXIT_CODES.ERROR);
|
|
314
308
|
}
|
|
315
309
|
};
|
|
@@ -364,7 +358,7 @@ const uploadProjectFiles = async (
|
|
|
364
358
|
let error;
|
|
365
359
|
|
|
366
360
|
try {
|
|
367
|
-
const upload = await uploadProject(
|
|
361
|
+
const { data: upload } = await uploadProject(
|
|
368
362
|
accountId,
|
|
369
363
|
projectName,
|
|
370
364
|
filePath,
|
|
@@ -636,8 +630,10 @@ const makePollTaskStatusFunc = ({
|
|
|
636
630
|
});
|
|
637
631
|
|
|
638
632
|
const [
|
|
639
|
-
initialTaskStatus,
|
|
640
|
-
{
|
|
633
|
+
{ data: initialTaskStatus },
|
|
634
|
+
{
|
|
635
|
+
data: { topLevelComponentsWithChildren: taskStructure },
|
|
636
|
+
},
|
|
641
637
|
] = await Promise.all([
|
|
642
638
|
statusFn(accountId, taskName, taskId),
|
|
643
639
|
structureFn(accountId, taskName, taskId),
|
|
@@ -711,9 +707,17 @@ const makePollTaskStatusFunc = ({
|
|
|
711
707
|
const pollInterval = setInterval(async () => {
|
|
712
708
|
let taskStatus;
|
|
713
709
|
try {
|
|
714
|
-
|
|
710
|
+
const { data } = await statusFn(accountId, taskName, taskId);
|
|
711
|
+
taskStatus = data;
|
|
715
712
|
} catch (e) {
|
|
716
713
|
logger.debug(e);
|
|
714
|
+
logError(
|
|
715
|
+
e,
|
|
716
|
+
new ApiErrorContext({
|
|
717
|
+
accountId,
|
|
718
|
+
projectName: taskName,
|
|
719
|
+
})
|
|
720
|
+
);
|
|
717
721
|
return reject(
|
|
718
722
|
new Error(
|
|
719
723
|
i18n(
|
|
@@ -981,15 +985,21 @@ const displayWarnLogs = async (
|
|
|
981
985
|
|
|
982
986
|
if (isDeploy) {
|
|
983
987
|
try {
|
|
984
|
-
|
|
988
|
+
const { data } = await fetchDeployWarnLogs(
|
|
989
|
+
accountId,
|
|
990
|
+
projectName,
|
|
991
|
+
taskId
|
|
992
|
+
);
|
|
993
|
+
result = data;
|
|
985
994
|
} catch (e) {
|
|
986
|
-
|
|
995
|
+
logError(e);
|
|
987
996
|
}
|
|
988
997
|
} else {
|
|
989
998
|
try {
|
|
990
|
-
|
|
999
|
+
const { data } = await fetchBuildWarnLogs(accountId, projectName, taskId);
|
|
1000
|
+
result = data;
|
|
991
1001
|
} catch (e) {
|
|
992
|
-
|
|
1002
|
+
logError(e);
|
|
993
1003
|
}
|
|
994
1004
|
}
|
|
995
1005
|
|