@hubspot/cli 5.1.1 → 5.1.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/commands/accounts/clean.js +4 -4
- package/commands/accounts/info.js +1 -1
- package/commands/auth.js +24 -5
- package/commands/fetch.js +31 -9
- package/commands/filemanager/fetch.js +32 -4
- package/commands/filemanager/upload.js +7 -2
- package/commands/init.js +22 -9
- package/commands/upload.js +4 -2
- package/lang/en.lyaml +16 -2
- package/lib/__tests__/validation.js +2 -2
- package/lib/logCallbacks.js +7 -1
- package/lib/sandboxes.js +28 -7
- package/lib/validation.js +3 -2
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const {
|
|
3
3
|
accessTokenForPersonalAccessKey,
|
|
4
|
-
} = require('@hubspot/
|
|
4
|
+
} = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
5
5
|
|
|
6
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
7
7
|
const { i18n } = require('../../lib/lang');
|
|
@@ -20,7 +20,7 @@ const SpinniesManager = require('../../lib/SpinniesManager');
|
|
|
20
20
|
const { getConfig, deleteAccount } = require('@hubspot/local-dev-lib/config');
|
|
21
21
|
const {
|
|
22
22
|
isSpecifiedHubSpotAuthError,
|
|
23
|
-
} = require('
|
|
23
|
+
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
24
24
|
|
|
25
25
|
const i18nKey = 'cli.commands.accounts.subcommands.clean';
|
|
26
26
|
|
|
@@ -58,12 +58,12 @@ exports.handler = async options => {
|
|
|
58
58
|
} catch (error) {
|
|
59
59
|
if (
|
|
60
60
|
isSpecifiedHubSpotAuthError(error, {
|
|
61
|
-
|
|
61
|
+
status: 401,
|
|
62
62
|
category: 'INVALID_AUTHENTICATION',
|
|
63
63
|
subCategory: 'LocalDevAuthErrorType.PORTAL_NOT_ACTIVE',
|
|
64
64
|
}) ||
|
|
65
65
|
isSpecifiedHubSpotAuthError(error, {
|
|
66
|
-
|
|
66
|
+
status: 404,
|
|
67
67
|
category: 'INVALID_AUTHENTICATION',
|
|
68
68
|
subCategory: 'LocalDevAuthErrorType.INVALID_PORTAL_ID',
|
|
69
69
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
3
|
-
const { getAccessToken } = require('@hubspot/
|
|
3
|
+
const { getAccessToken } = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
4
4
|
const {
|
|
5
5
|
getAccountId,
|
|
6
6
|
addAccountOptions,
|
package/commands/auth.js
CHANGED
|
@@ -8,8 +8,9 @@ const {
|
|
|
8
8
|
} = require('@hubspot/cli-lib/lib/constants');
|
|
9
9
|
const { i18n } = require('../lib/lang');
|
|
10
10
|
const {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
getAccessToken,
|
|
12
|
+
updateConfigWithAccessToken,
|
|
13
|
+
} = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
13
14
|
const {
|
|
14
15
|
updateAccountConfig,
|
|
15
16
|
writeConfig,
|
|
@@ -17,7 +18,10 @@ const {
|
|
|
17
18
|
getConfigPath,
|
|
18
19
|
loadConfig,
|
|
19
20
|
} = require('@hubspot/local-dev-lib/config');
|
|
20
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
commaSeparatedValues,
|
|
23
|
+
toKebabCase,
|
|
24
|
+
} = require('@hubspot/local-dev-lib/text');
|
|
21
25
|
const { promptUser } = require('../lib/prompts/promptUtils');
|
|
22
26
|
const {
|
|
23
27
|
personalAccessKeyPrompt,
|
|
@@ -40,6 +44,7 @@ const { trackAuthAction, trackCommandUsage } = require('../lib/usageTracking');
|
|
|
40
44
|
const { authenticateWithOauth } = require('../lib/oauth');
|
|
41
45
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
42
46
|
const { uiFeatureHighlight } = require('../lib/ui');
|
|
47
|
+
const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
|
|
43
48
|
|
|
44
49
|
const i18nKey = 'cli.commands.auth';
|
|
45
50
|
|
|
@@ -85,6 +90,8 @@ exports.handler = async options => {
|
|
|
85
90
|
let updatedConfig;
|
|
86
91
|
let validName;
|
|
87
92
|
let successAuthMethod;
|
|
93
|
+
let token;
|
|
94
|
+
let defaultName;
|
|
88
95
|
|
|
89
96
|
switch (authType) {
|
|
90
97
|
case OAUTH_AUTH_METHOD.value:
|
|
@@ -97,7 +104,19 @@ exports.handler = async options => {
|
|
|
97
104
|
break;
|
|
98
105
|
case PERSONAL_ACCESS_KEY_AUTH_METHOD.value:
|
|
99
106
|
configData = await personalAccessKeyPrompt({ env, account });
|
|
100
|
-
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
token = await getAccessToken(configData.personalAccessKey, env);
|
|
110
|
+
defaultName = toKebabCase(token.hubName);
|
|
111
|
+
|
|
112
|
+
updatedConfig = await updateConfigWithAccessToken(
|
|
113
|
+
token,
|
|
114
|
+
configData.personalAccessKey,
|
|
115
|
+
env
|
|
116
|
+
);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
logErrorInstance(e);
|
|
119
|
+
}
|
|
101
120
|
|
|
102
121
|
if (!updatedConfig) {
|
|
103
122
|
break;
|
|
@@ -106,7 +125,7 @@ exports.handler = async options => {
|
|
|
106
125
|
validName = updatedConfig.name;
|
|
107
126
|
|
|
108
127
|
if (!validName) {
|
|
109
|
-
const { name: namePrompt } = await enterAccountNamePrompt();
|
|
128
|
+
const { name: namePrompt } = await enterAccountNamePrompt(defaultName);
|
|
110
129
|
validName = namePrompt;
|
|
111
130
|
}
|
|
112
131
|
|
package/commands/fetch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { downloadFileOrFolder } = require('@hubspot/
|
|
1
|
+
const { downloadFileOrFolder } = require('@hubspot/local-dev-lib/fileMapper');
|
|
2
2
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
3
3
|
|
|
4
4
|
const {
|
|
@@ -17,6 +17,22 @@ const { i18n } = require('../lib/lang');
|
|
|
17
17
|
|
|
18
18
|
const i18nKey = 'cli.commands.fetch';
|
|
19
19
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
20
|
+
const { buildLogCallbacks } = require('../lib/logCallbacks');
|
|
21
|
+
const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
|
|
22
|
+
|
|
23
|
+
const fileMapperLogCallbacks = buildLogCallbacks({
|
|
24
|
+
skippedExisting: `${i18nKey}.fileMapperLogCallbacks.skippedExisting`,
|
|
25
|
+
wroteFolder: `${i18nKey}.fileMapperLogCallbacks.wroteFolder`,
|
|
26
|
+
completedFetch: {
|
|
27
|
+
key: `${i18nKey}.fileMapperLogCallbacks.completedFetch`,
|
|
28
|
+
logger: logger.success,
|
|
29
|
+
},
|
|
30
|
+
folderFetch: `${i18nKey}.fileMapperLogCallbacks.folderFetch`,
|
|
31
|
+
completedFolderFetch: {
|
|
32
|
+
key: `${i18nKey}.fileMapperLogCallbacks.completedFolderFetch`,
|
|
33
|
+
logger: logger.success,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
20
36
|
|
|
21
37
|
exports.command = 'fetch <src> [dest]';
|
|
22
38
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
@@ -40,14 +56,20 @@ exports.handler = async options => {
|
|
|
40
56
|
|
|
41
57
|
trackCommandUsage('fetch', { mode }, accountId);
|
|
42
58
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
try {
|
|
60
|
+
// Fetch and write file/folder.
|
|
61
|
+
await downloadFileOrFolder(
|
|
62
|
+
accountId,
|
|
63
|
+
src,
|
|
64
|
+
resolveLocalPath(dest),
|
|
65
|
+
mode,
|
|
66
|
+
options,
|
|
67
|
+
fileMapperLogCallbacks
|
|
68
|
+
);
|
|
69
|
+
} catch (err) {
|
|
70
|
+
logErrorInstance(err);
|
|
71
|
+
process.exit(EXIT_CODES.ERROR);
|
|
72
|
+
}
|
|
51
73
|
};
|
|
52
74
|
|
|
53
75
|
exports.builder = yargs => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
const { downloadFileOrFolder } = require('@hubspot/
|
|
1
|
+
const { downloadFileOrFolder } = require('@hubspot/local-dev-lib/fileManager');
|
|
2
2
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
3
3
|
const { resolveLocalPath } = require('../../lib/filesystem');
|
|
4
|
+
const { buildLogCallbacks } = require('../../lib/logCallbacks');
|
|
4
5
|
|
|
5
6
|
const {
|
|
6
7
|
addConfigOptions,
|
|
@@ -14,12 +15,27 @@ const { i18n } = require('../../lib/lang');
|
|
|
14
15
|
|
|
15
16
|
const i18nKey = 'cli.commands.filemanager.subcommands.fetch';
|
|
16
17
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
18
|
+
const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
|
|
19
|
+
|
|
20
|
+
const downloadLogCallbacks = buildLogCallbacks({
|
|
21
|
+
skippedExisting: `${i18nKey}.downloadLogCallbacks.skippedExisting`,
|
|
22
|
+
fetchFolderStarted: `${i18nKey}.downloadLogCallbacks.fetchFolderStarted`,
|
|
23
|
+
fetchFolderSuccess: {
|
|
24
|
+
key: `${i18nKey}.downloadLogCallbacks.fetchFolderSuccess`,
|
|
25
|
+
logger: logger.success,
|
|
26
|
+
},
|
|
27
|
+
fetchFileStarted: `${i18nKey}.downloadLogCallbacks.fetchFileStarted`,
|
|
28
|
+
fetchFileSuccess: {
|
|
29
|
+
key: `${i18nKey}.downloadLogCallbacks.fetchFileSuccess`,
|
|
30
|
+
logger: logger.success,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
17
33
|
|
|
18
34
|
exports.command = 'fetch <src> [dest]';
|
|
19
35
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
20
36
|
|
|
21
37
|
exports.handler = async options => {
|
|
22
|
-
let { src, dest } = options;
|
|
38
|
+
let { src, dest, includeArchived } = options;
|
|
23
39
|
|
|
24
40
|
await loadAndValidateOptions(options);
|
|
25
41
|
|
|
@@ -34,8 +50,20 @@ exports.handler = async options => {
|
|
|
34
50
|
|
|
35
51
|
trackCommandUsage('filemanager-fetch', null, accountId);
|
|
36
52
|
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
try {
|
|
54
|
+
// Fetch and write file/folder.
|
|
55
|
+
await downloadFileOrFolder(
|
|
56
|
+
accountId,
|
|
57
|
+
src,
|
|
58
|
+
dest,
|
|
59
|
+
false,
|
|
60
|
+
includeArchived || false,
|
|
61
|
+
downloadLogCallbacks
|
|
62
|
+
);
|
|
63
|
+
} catch (err) {
|
|
64
|
+
logErrorInstance(err);
|
|
65
|
+
process.exit(EXIT_CODES.ERROR);
|
|
66
|
+
}
|
|
39
67
|
};
|
|
40
68
|
|
|
41
69
|
exports.builder = yargs => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
const { uploadFolder } = require('@hubspot/
|
|
4
|
+
const { uploadFolder } = require('@hubspot/local-dev-lib/fileManager');
|
|
5
5
|
const { uploadFile } = require('@hubspot/cli-lib/api/fileManager');
|
|
6
6
|
const { getCwd, convertToUnixPath } = require('@hubspot/local-dev-lib/path');
|
|
7
7
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
@@ -25,6 +25,11 @@ const { i18n } = require('../../lib/lang');
|
|
|
25
25
|
|
|
26
26
|
const i18nKey = 'cli.commands.filemanager.subcommands.upload';
|
|
27
27
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
28
|
+
const { buildLogCallbacks } = require('../../lib/logCallbacks');
|
|
29
|
+
|
|
30
|
+
const uploadLogCallbacks = buildLogCallbacks({
|
|
31
|
+
uploadSuccess: `${i18nKey}.uploadLogCallbacks.uploadSuccess`,
|
|
32
|
+
});
|
|
28
33
|
|
|
29
34
|
exports.command = 'upload <src> <dest>';
|
|
30
35
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
@@ -121,7 +126,7 @@ exports.handler = async options => {
|
|
|
121
126
|
src,
|
|
122
127
|
})
|
|
123
128
|
);
|
|
124
|
-
uploadFolder(accountId, absoluteSrcPath, dest)
|
|
129
|
+
uploadFolder(accountId, absoluteSrcPath, dest, uploadLogCallbacks)
|
|
125
130
|
.then(() => {
|
|
126
131
|
logger.success(
|
|
127
132
|
i18n(`${i18nKey}.success.uploadComplete`, {
|
package/commands/init.js
CHANGED
|
@@ -24,9 +24,11 @@ const {
|
|
|
24
24
|
const { i18n } = require('../lib/lang');
|
|
25
25
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
26
26
|
const {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
getAccessToken,
|
|
28
|
+
updateConfigWithAccessToken,
|
|
29
|
+
} = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
29
30
|
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
31
|
+
const { toKebabCase } = require('@hubspot/local-dev-lib/text');
|
|
30
32
|
const { trackCommandUsage, trackAuthAction } = require('../lib/usageTracking');
|
|
31
33
|
const { setLogLevel, addTestingOptions } = require('../lib/commonOpts');
|
|
32
34
|
const { promptUser } = require('../lib/prompts/promptUtils');
|
|
@@ -51,14 +53,25 @@ const TRACKING_STATUS = {
|
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
const personalAccessKeyConfigCreationFlow = async (env, account) => {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
const { personalAccessKey } = await personalAccessKeyPrompt({ env, account });
|
|
57
|
+
let updatedConfig;
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const token = await getAccessToken(personalAccessKey, env);
|
|
61
|
+
const defaultName = toKebabCase(token.hubName);
|
|
62
|
+
const { name } = await enterAccountNamePrompt(defaultName);
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
updatedConfig = updateConfigWithAccessToken(
|
|
65
|
+
token,
|
|
66
|
+
personalAccessKey,
|
|
67
|
+
env,
|
|
68
|
+
name,
|
|
69
|
+
true
|
|
70
|
+
);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
logErrorInstance(e);
|
|
73
|
+
}
|
|
74
|
+
return updatedConfig;
|
|
62
75
|
};
|
|
63
76
|
|
|
64
77
|
const oauthConfigCreationFlow = async env => {
|
package/commands/upload.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { uploadFolder, hasUploadErrors } = require('@hubspot/cli-lib');
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
getFileMapperQueryValues,
|
|
6
|
+
} = require('@hubspot/local-dev-lib/fileMapper');
|
|
5
7
|
const { upload, deleteFile } = require('@hubspot/cli-lib/api/fileMapper');
|
|
6
8
|
const {
|
|
7
9
|
getCwd,
|
|
@@ -155,7 +157,7 @@ exports.handler = async options => {
|
|
|
155
157
|
accountId,
|
|
156
158
|
absoluteSrcPath,
|
|
157
159
|
normalizedDest,
|
|
158
|
-
getFileMapperQueryValues(
|
|
160
|
+
getFileMapperQueryValues(mode, options)
|
|
159
161
|
)
|
|
160
162
|
.then(() => {
|
|
161
163
|
logger.success(
|
package/lang/en.lyaml
CHANGED
|
@@ -274,6 +274,12 @@ en:
|
|
|
274
274
|
describe: "Local directory you would like the files to be placed in, relative to your current working directory"
|
|
275
275
|
src:
|
|
276
276
|
describe: "Path in HubSpot Design Tools"
|
|
277
|
+
fileMapperLogCallbacks:
|
|
278
|
+
skippedExisting: 'Skipped existing "{{ filepath }}"'
|
|
279
|
+
wroteFolder: 'Wrote folder "{{ filepath }}"'
|
|
280
|
+
completedFetch: 'Completed fetch of file "{{ src }}"{{ version }} to "{{ dest }}" from the Design Manager'
|
|
281
|
+
folderFetch: 'Fetched "{{ src }}" from account {{ accountId }} from the Design Manager successfully'
|
|
282
|
+
completedFolderFetch: 'Completed fetch of folder "{{ src }}"{{ version }} to "{{ dest }}" from the Design Manager'
|
|
277
283
|
filemanager:
|
|
278
284
|
describe: "Commands for working with the File Manager."
|
|
279
285
|
subcommands:
|
|
@@ -289,6 +295,12 @@ en:
|
|
|
289
295
|
describe: "Path in HubSpot Design Tools"
|
|
290
296
|
src:
|
|
291
297
|
describe: "Path to the local directory you would like the files to be placed, relative to your current working directory. If omitted, this argument will default to your current working directory"
|
|
298
|
+
downloadLogCallbacks:
|
|
299
|
+
skippedExisting: "Skipped existing {{ filepath }}"
|
|
300
|
+
fetchFolderStarted: 'Fetching folder from "{{ src }}" to "{{ dest }}" in the File Manager of account {{ accountId }}'
|
|
301
|
+
fetchFolderSuccess: "Completed fetch of folder \"{{ src }}\" to \"{{ dest }}\" from the File Manager"
|
|
302
|
+
fetchFileStarted: "Fetching file from \"{{ src }}\" to \"{{ dest }}\" in the File Manager of account {{ accountId }}"
|
|
303
|
+
fetchFileSuccess: "Completed fetch of file \"{{ src }}\" to \"{{ dest }}\" from the File Manager"
|
|
292
304
|
upload:
|
|
293
305
|
describe: "Upload a folder or file from your computer to the HubSpot File Manager"
|
|
294
306
|
errors:
|
|
@@ -307,6 +319,8 @@ en:
|
|
|
307
319
|
success:
|
|
308
320
|
upload: "Uploaded file from \"{{ src }}\" to \"{{ dest }}\" in the File Manager of account {{ accountId }}"
|
|
309
321
|
uploadComplete: "Uploading files to \"{{ dest }}\" in the File Manager is complete"
|
|
322
|
+
uploadLogCallbacks:
|
|
323
|
+
uploadSuccess: 'Uploaded file "{{ file }}" to "{{ destPath }}"'
|
|
310
324
|
functions:
|
|
311
325
|
describe: "Commands for working with functions."
|
|
312
326
|
subcommands:
|
|
@@ -1296,8 +1310,8 @@ en:
|
|
|
1296
1310
|
404: "The {{ messageDetail }} was not found."
|
|
1297
1311
|
429: "The {{ messageDetail }} surpassed the rate limit. Retry in one minute."
|
|
1298
1312
|
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."
|
|
1299
|
-
|
|
1300
|
-
|
|
1313
|
+
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."
|
|
1314
|
+
400Generic: "The {{ messageDetail }} failed due to a client error."
|
|
1301
1315
|
generic: "The {{ messageDetail }} failed."
|
|
1302
1316
|
verifyAccessKeyAndUserAccess:
|
|
1303
1317
|
fetchScopeDataError: "Error verifying access of scopeGroup {{ scopeGroup }}: {{ error }}"
|
|
@@ -2,7 +2,7 @@ const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
|
2
2
|
const { getOauthManager } = require('@hubspot/cli-lib/oauth');
|
|
3
3
|
const {
|
|
4
4
|
accessTokenForPersonalAccessKey,
|
|
5
|
-
} = require('@hubspot/
|
|
5
|
+
} = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
6
6
|
|
|
7
7
|
const { getAccountId } = require('../commonOpts');
|
|
8
8
|
const { validateAccount } = require('../validation');
|
|
@@ -11,7 +11,7 @@ jest.mock('@hubspot/cli-lib');
|
|
|
11
11
|
jest.mock('@hubspot/local-dev-lib/config');
|
|
12
12
|
jest.mock('@hubspot/cli-lib/logger');
|
|
13
13
|
jest.mock('@hubspot/cli-lib/oauth');
|
|
14
|
-
jest.mock('@hubspot/
|
|
14
|
+
jest.mock('@hubspot/local-dev-lib/personalAccessKey');
|
|
15
15
|
jest.mock('../commonOpts');
|
|
16
16
|
|
|
17
17
|
describe('validation', () => {
|
package/lib/logCallbacks.js
CHANGED
|
@@ -4,7 +4,13 @@ const { i18n } = require('./lang');
|
|
|
4
4
|
function buildLogCallbacks(logData) {
|
|
5
5
|
const callbacksObject = {};
|
|
6
6
|
for (let key in logData) {
|
|
7
|
-
|
|
7
|
+
if (typeof logData[key] === 'string') {
|
|
8
|
+
callbacksObject[key] = interpolationData =>
|
|
9
|
+
logger.log(i18n(logData[key], interpolationData));
|
|
10
|
+
} else {
|
|
11
|
+
callbacksObject[key] = interpolationData =>
|
|
12
|
+
logData[key].logger(i18n(logData[key].key, interpolationData));
|
|
13
|
+
}
|
|
8
14
|
}
|
|
9
15
|
return callbacksObject;
|
|
10
16
|
}
|
package/lib/sandboxes.js
CHANGED
|
@@ -3,8 +3,9 @@ const { i18n } = require('./lang');
|
|
|
3
3
|
const { handleExit, handleKeypress } = require('./process');
|
|
4
4
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
5
5
|
const {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
getAccessToken,
|
|
7
|
+
updateConfigWithAccessToken,
|
|
8
|
+
} = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
8
9
|
const { EXIT_CODES } = require('./enums/exitCodes');
|
|
9
10
|
const { enterAccountNamePrompt } = require('./prompts/enterAccountNamePrompt');
|
|
10
11
|
const {
|
|
@@ -25,6 +26,7 @@ const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
|
25
26
|
const {
|
|
26
27
|
personalAccessKeyPrompt,
|
|
27
28
|
} = require('./prompts/personalAccessKeyPrompt');
|
|
29
|
+
const { logErrorInstance } = require('./errorHandlers/standardErrors');
|
|
28
30
|
|
|
29
31
|
const STANDARD_SANDBOX = 'standard';
|
|
30
32
|
const DEVELOPER_SANDBOX = 'developer';
|
|
@@ -234,14 +236,28 @@ const validateSandboxUsageLimits = async (accountConfig, sandboxType, env) => {
|
|
|
234
236
|
* @returns {String} validName saved into config
|
|
235
237
|
*/
|
|
236
238
|
const saveSandboxToConfig = async (env, result, force = false) => {
|
|
237
|
-
let
|
|
238
|
-
if (
|
|
239
|
-
configData = await personalAccessKeyPrompt({
|
|
239
|
+
let personalAccessKey = result.personalAccessKey;
|
|
240
|
+
if (personalAccessKey) {
|
|
241
|
+
const configData = await personalAccessKeyPrompt({
|
|
240
242
|
env,
|
|
241
243
|
account: result.sandbox.sandboxHubId,
|
|
242
244
|
});
|
|
245
|
+
personalAccessKey = configData.personalAccessKey;
|
|
243
246
|
}
|
|
244
|
-
|
|
247
|
+
|
|
248
|
+
let updatedConfig;
|
|
249
|
+
|
|
250
|
+
try {
|
|
251
|
+
const token = await getAccessToken(personalAccessKey, env);
|
|
252
|
+
updatedConfig = await updateConfigWithAccessToken(
|
|
253
|
+
token,
|
|
254
|
+
personalAccessKey,
|
|
255
|
+
env
|
|
256
|
+
);
|
|
257
|
+
} catch (e) {
|
|
258
|
+
logErrorInstance(e);
|
|
259
|
+
}
|
|
260
|
+
|
|
245
261
|
if (!updatedConfig) {
|
|
246
262
|
throw new Error('Failed to update config with personal access key.');
|
|
247
263
|
}
|
|
@@ -316,6 +332,7 @@ function pollSyncTaskStatus(
|
|
|
316
332
|
const mergeTasks = {
|
|
317
333
|
'lead-flows': 'forms', // lead-flows are a subset of forms. We combine these in the UI as a single item, so we want to merge here for consistency.
|
|
318
334
|
};
|
|
335
|
+
const ignoreTasks = ['gates'];
|
|
319
336
|
let progressCounter = {};
|
|
320
337
|
let pollInterval;
|
|
321
338
|
// Handle manual exit for return key and ctrl+c
|
|
@@ -352,7 +369,11 @@ function pollSyncTaskStatus(
|
|
|
352
369
|
for (const task of taskResult.tasks) {
|
|
353
370
|
// For each sync task, show a progress bar and increment bar each time we run this interval until status is 'COMPLETE'
|
|
354
371
|
const taskType = task.type;
|
|
355
|
-
if (
|
|
372
|
+
if (
|
|
373
|
+
!progressBar.get(taskType) &&
|
|
374
|
+
!mergeTasks[taskType] &&
|
|
375
|
+
!ignoreTasks.includes(taskType)
|
|
376
|
+
) {
|
|
356
377
|
// skip creation of lead-flows bar because we're combining lead-flows into the forms bar, otherwise create a bar instance for the type
|
|
357
378
|
progressCounter[taskType] = 0;
|
|
358
379
|
progressBar.create(taskType, 100, 0, {
|
package/lib/validation.js
CHANGED
|
@@ -17,13 +17,14 @@ const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
|
17
17
|
const { getOauthManager } = require('@hubspot/cli-lib/oauth');
|
|
18
18
|
const {
|
|
19
19
|
accessTokenForPersonalAccessKey,
|
|
20
|
-
} = require('@hubspot/
|
|
20
|
+
} = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
21
21
|
const { getCwd, getExt } = require('@hubspot/local-dev-lib/path');
|
|
22
22
|
const { getAccountId, getMode, setLogLevel } = require('./commonOpts');
|
|
23
23
|
const { logDebugInfo } = require('./debugInfo');
|
|
24
24
|
const fs = require('fs');
|
|
25
25
|
const path = require('path');
|
|
26
26
|
const { EXIT_CODES } = require('./enums/exitCodes');
|
|
27
|
+
const { logErrorInstance } = require('./errorHandlers/standardErrors');
|
|
27
28
|
|
|
28
29
|
async function loadAndValidateOptions(options, shouldValidateAccount = true) {
|
|
29
30
|
setLogLevel(options);
|
|
@@ -151,7 +152,7 @@ async function validateAccount(options) {
|
|
|
151
152
|
return false;
|
|
152
153
|
}
|
|
153
154
|
} catch (e) {
|
|
154
|
-
|
|
155
|
+
logErrorInstance(e);
|
|
155
156
|
return false;
|
|
156
157
|
}
|
|
157
158
|
} else if (!apiKey) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.2",
|
|
4
4
|
"description": "CLI for working with HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"url": "https://github.com/HubSpot/hubspot-cms-tools"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@hubspot/cli-lib": "^8.0.
|
|
12
|
-
"@hubspot/local-dev-lib": "^0.1
|
|
13
|
-
"@hubspot/serverless-dev-runtime": "5.1.
|
|
14
|
-
"@hubspot/ui-extensions-dev-server": "0.8.
|
|
11
|
+
"@hubspot/cli-lib": "^8.0.2",
|
|
12
|
+
"@hubspot/local-dev-lib": "^0.2.1",
|
|
13
|
+
"@hubspot/serverless-dev-runtime": "5.1.2",
|
|
14
|
+
"@hubspot/ui-extensions-dev-server": "0.8.6",
|
|
15
15
|
"archiver": "^5.3.0",
|
|
16
16
|
"chalk": "^4.1.2",
|
|
17
17
|
"chokidar": "^3.0.1",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "16ae446c55bb019fe01eb15944d80577a654aa02"
|
|
49
49
|
}
|