@hubspot/cli 6.1.1 → 6.2.1

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.
Files changed (86) hide show
  1. package/bin/cli.js +2 -2
  2. package/commands/accounts/clean.js +5 -7
  3. package/commands/auth.js +5 -5
  4. package/commands/cms/convertFields.js +2 -2
  5. package/commands/cms/lighthouseScore.js +47 -36
  6. package/commands/create/api-sample.js +2 -4
  7. package/commands/create/function.js +2 -2
  8. package/commands/create/module.js +2 -2
  9. package/commands/create/template.js +2 -2
  10. package/commands/create.js +3 -5
  11. package/commands/customObject/create.js +2 -2
  12. package/commands/customObject/schema/create.js +4 -4
  13. package/commands/customObject/schema/delete.js +2 -3
  14. package/commands/customObject/schema/fetch-all.js +2 -5
  15. package/commands/customObject/schema/fetch.js +2 -4
  16. package/commands/customObject/schema/list.js +2 -4
  17. package/commands/customObject/schema/update.js +4 -4
  18. package/commands/fetch.js +2 -2
  19. package/commands/filemanager/fetch.js +2 -2
  20. package/commands/filemanager/upload.js +3 -7
  21. package/commands/functions/deploy.js +26 -23
  22. package/commands/functions/list.js +3 -6
  23. package/commands/hubdb/clear.js +5 -3
  24. package/commands/hubdb/create.js +2 -2
  25. package/commands/hubdb/delete.js +2 -2
  26. package/commands/hubdb/fetch.js +2 -2
  27. package/commands/init.js +4 -7
  28. package/commands/lint.js +2 -2
  29. package/commands/list.js +4 -6
  30. package/commands/logs.js +6 -3
  31. package/commands/mv.js +3 -6
  32. package/commands/project/__tests__/deploy.test.js +37 -26
  33. package/commands/project/__tests__/logs.test.js +4 -5
  34. package/commands/project/add.js +2 -2
  35. package/commands/project/cloneApp.js +11 -9
  36. package/commands/project/create.js +2 -6
  37. package/commands/project/deploy.js +9 -12
  38. package/commands/project/dev.js +6 -5
  39. package/commands/project/download.js +7 -9
  40. package/commands/project/listBuilds.js +8 -12
  41. package/commands/project/logs.js +2 -2
  42. package/commands/project/migrateApp.js +20 -15
  43. package/commands/project/upload.js +4 -10
  44. package/commands/project/watch.js +8 -13
  45. package/commands/remove.js +2 -5
  46. package/commands/sandbox/create.js +4 -6
  47. package/commands/sandbox/delete.js +6 -12
  48. package/commands/secrets/addSecret.js +2 -5
  49. package/commands/secrets/deleteSecret.js +2 -5
  50. package/commands/secrets/listSecrets.js +5 -6
  51. package/commands/secrets/updateSecret.js +2 -5
  52. package/commands/theme/preview.js +2 -5
  53. package/commands/upload.js +3 -7
  54. package/commands/watch.js +3 -7
  55. package/lang/en.lyaml +14 -18
  56. package/lib/LocalDevManager.js +8 -6
  57. package/lib/__tests__/downloadProjectPrompt.test.js +1 -1
  58. package/lib/__tests__/projectLogsManager.test.js +19 -17
  59. package/lib/__tests__/serverlessLogs.test.js +13 -9
  60. package/lib/buildAccount.js +10 -10
  61. package/lib/developerTestAccounts.js +27 -27
  62. package/lib/errorHandlers/index.js +101 -0
  63. package/lib/errorHandlers/{overrideErrors.js → suppressError.js} +7 -7
  64. package/lib/hasFeature.js +15 -0
  65. package/lib/localDev.js +32 -19
  66. package/lib/marketplace-validate.js +3 -3
  67. package/lib/oauth.js +1 -1
  68. package/lib/polling.js +1 -1
  69. package/lib/projectLogsManager.js +3 -4
  70. package/lib/projectStructure.js +2 -2
  71. package/lib/projects.js +42 -29
  72. package/lib/projectsWatch.js +7 -12
  73. package/lib/prompts/createProjectPrompt.js +14 -5
  74. package/lib/prompts/downloadProjectPrompt.js +3 -6
  75. package/lib/prompts/projectDevTargetAccountPrompt.js +8 -6
  76. package/lib/prompts/selectPublicAppPrompt.js +5 -3
  77. package/lib/sandboxSync.js +7 -7
  78. package/lib/sandboxes.js +11 -7
  79. package/lib/schema.js +2 -2
  80. package/lib/serverlessLogs.js +67 -15
  81. package/lib/upload.js +2 -2
  82. package/lib/validation.js +2 -2
  83. package/package.json +8 -9
  84. package/lib/errorHandlers/apiErrors.js +0 -145
  85. package/lib/errorHandlers/fileSystemErrors.js +0 -20
  86. package/lib/errorHandlers/standardErrors.js +0 -103
package/lib/upload.js CHANGED
@@ -6,7 +6,7 @@ const { isAllowedExtension } = require('@hubspot/local-dev-lib/path');
6
6
  const {
7
7
  isConvertableFieldJs,
8
8
  } = require('@hubspot/local-dev-lib/cms/handleFieldsJS');
9
- const { logErrorInstance } = require('./errorHandlers/standardErrors');
9
+ const { logError } = require('./errorHandlers/index');
10
10
 
11
11
  /*
12
12
  * Walks the src folder for files, filters them based on ignore filter.
@@ -17,7 +17,7 @@ const getUploadableFileList = async (src, convertFields) => {
17
17
  try {
18
18
  filePaths = await walk(src);
19
19
  } catch (e) {
20
- logErrorInstance(e);
20
+ logError(e);
21
21
  }
22
22
  const allowedFiles = filePaths
23
23
  .filter(file => {
package/lib/validation.js CHANGED
@@ -28,7 +28,7 @@ const { getAccountId, getMode, setLogLevel } = require('./commonOpts');
28
28
  const { logDebugInfo } = require('./debugInfo');
29
29
  const { EXIT_CODES } = require('./enums/exitCodes');
30
30
  const { checkAndWarnGitInclusion } = require('./ui/git');
31
- const { logErrorInstance } = require('./errorHandlers/standardErrors');
31
+ const { logError } = require('./errorHandlers/index');
32
32
 
33
33
  async function loadAndValidateOptions(options, shouldValidateAccount = true) {
34
34
  setLogLevel(options);
@@ -156,7 +156,7 @@ async function validateAccount(options) {
156
156
  return false;
157
157
  }
158
158
  } catch (e) {
159
- logErrorInstance(e);
159
+ logError(e);
160
160
  return false;
161
161
  }
162
162
  } else if (!apiKey) {
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "6.1.1",
3
+ "version": "6.2.1",
4
4
  "description": "CLI for working with HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/HubSpot/hubspot-cms-tools"
8
+ "url": "https://github.com/HubSpot/hubspot-cli"
9
9
  },
10
10
  "dependencies": {
11
- "@hubspot/local-dev-lib": "1.13.1",
12
- "@hubspot/serverless-dev-runtime": "6.1.1",
13
- "@hubspot/theme-preview-dev-server": "0.0.7",
11
+ "@hubspot/local-dev-lib": "^2.0.1",
12
+ "@hubspot/serverless-dev-runtime": "6.2.0",
13
+ "@hubspot/theme-preview-dev-server": "0.0.8",
14
14
  "@hubspot/ui-extensions-dev-server": "0.8.33",
15
- "archiver": "^5.3.0",
15
+ "archiver": "^7.0.1",
16
16
  "chalk": "^4.1.2",
17
17
  "chokidar": "^3.0.1",
18
18
  "cli-cursor": "^3.1.0",
@@ -24,13 +24,12 @@
24
24
  "js-yaml": "^4.1.0",
25
25
  "moment": "^2.29.1",
26
26
  "open": "^7.0.3",
27
- "ora": "^4.0.3",
28
27
  "p-queue": "^6.0.2",
29
28
  "strip-ansi": "^5.2.0",
30
29
  "table": "^6.6.0",
31
30
  "tmp": "^0.2.1",
32
31
  "update-notifier": "^5.1.0",
33
- "yargs": "15.4.1"
32
+ "yargs": "17.7.2"
34
33
  },
35
34
  "devDependencies": {
36
35
  "axios": "^1.7.2",
@@ -46,5 +45,5 @@
46
45
  "publishConfig": {
47
46
  "access": "public"
48
47
  },
49
- "gitHead": "f60d56f9f54ed272d48dea96a72278649ab9f8b5"
48
+ "gitHead": "bca108b05c57cfb6984cda5c09740760855c70d8"
50
49
  }
@@ -1,145 +0,0 @@
1
- const { logger } = require('@hubspot/local-dev-lib/logger');
2
- const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
3
- const {
4
- isMissingScopeError,
5
- isApiUploadValidationError,
6
- getAxiosErrorWithContext,
7
- parseValidationErrors,
8
- } = require('@hubspot/local-dev-lib/errors/apiErrors');
9
- const {
10
- SCOPE_GROUPS,
11
- PERSONAL_ACCESS_KEY_AUTH_METHOD,
12
- } = require('@hubspot/local-dev-lib/constants/auth');
13
- const { fetchScopeData } = require('@hubspot/local-dev-lib/api/localDevAuth');
14
- const {
15
- debugErrorAndContext,
16
- logErrorInstance,
17
- ErrorContext,
18
- } = require('./standardErrors');
19
- const { overrideErrors } = require('./overrideErrors');
20
- const { i18n } = require('../lang');
21
-
22
- const i18nKey = 'lib.errorHandlers.apiErrors';
23
-
24
- class ApiErrorContext extends ErrorContext {
25
- constructor(props = {}) {
26
- super(props);
27
- /** @type {string} */
28
- this.request = props.request || '';
29
- /** @type {string} */
30
- this.payload = props.payload || '';
31
- }
32
- }
33
-
34
- /**
35
- * @param {Error} error
36
- * @param {ApiErrorContext} context
37
- */
38
- function logValidationErrors(error, context) {
39
- const { response = {} } = error;
40
- const validationErrors = parseValidationErrors(response.data);
41
- if (validationErrors.length) {
42
- logger.error(validationErrors.join('\n- '));
43
- }
44
- debugErrorAndContext(error, context);
45
- }
46
-
47
- /**
48
- * Logs a message for an error instance resulting from API interaction.
49
- *
50
- * @param {Error|SystemError|Object} error
51
- * @param {ApiErrorContext} context
52
- */
53
- function logApiErrorInstance(error, context) {
54
- if (error.isAxiosError) {
55
- if (overrideErrors(error, context)) return;
56
- const errorWithContext = getAxiosErrorWithContext(error, context);
57
- logger.error(errorWithContext.message);
58
- return;
59
- }
60
- logErrorInstance(error, context);
61
- }
62
-
63
- /**
64
- * Logs a message for an error instance resulting from filemapper API upload.
65
- *
66
- * @param {Error|SystemError|Object} error
67
- * @param {ApiErrorContext} context
68
- */
69
- function logApiUploadErrorInstance(error, context) {
70
- if (isApiUploadValidationError(error)) {
71
- logValidationErrors(error, context);
72
- return;
73
- }
74
- logApiErrorInstance(error, context);
75
- }
76
-
77
- async function verifyAccessKeyAndUserAccess(accountId, scopeGroup) {
78
- const accountConfig = getAccountConfig(accountId);
79
- const { authType } = accountConfig;
80
- if (authType !== PERSONAL_ACCESS_KEY_AUTH_METHOD.value) {
81
- return;
82
- }
83
-
84
- let scopesData;
85
- try {
86
- scopesData = await fetchScopeData(accountId, scopeGroup);
87
- } catch (e) {
88
- logger.debug(
89
- i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.fetchScopeDataError`, {
90
- scopeGroup,
91
- error: e,
92
- })
93
- );
94
- return;
95
- }
96
- const { portalScopesInGroup, userScopesInGroup } = scopesData;
97
-
98
- if (!portalScopesInGroup.length) {
99
- logger.error(
100
- i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.portalMissingScope`)
101
- );
102
- return;
103
- }
104
-
105
- if (!portalScopesInGroup.every(s => userScopesInGroup.includes(s))) {
106
- logger.error(
107
- i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.userMissingScope`)
108
- );
109
- return;
110
- } else {
111
- logger.error(
112
- i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.genericMissingScope`)
113
- );
114
- return;
115
- }
116
- }
117
-
118
- /**
119
- * Logs a message for an error instance resulting from API interaction
120
- * related to serverless function.
121
- *
122
- * @param {int} accountId
123
- * @param {Error|SystemError|Object} error
124
- * @param {ApiErrorContext} context
125
- */
126
- async function logServerlessFunctionApiErrorInstance(
127
- accountId,
128
- error,
129
- context
130
- ) {
131
- if (isMissingScopeError(error)) {
132
- await verifyAccessKeyAndUserAccess(accountId, SCOPE_GROUPS.CMS_FUNCTIONS);
133
- return;
134
- }
135
-
136
- logApiErrorInstance(error, context);
137
- }
138
-
139
- module.exports = {
140
- ApiErrorContext,
141
- parseValidationErrors,
142
- logApiErrorInstance,
143
- logApiUploadErrorInstance,
144
- logServerlessFunctionApiErrorInstance,
145
- };
@@ -1,20 +0,0 @@
1
- const {
2
- getFileSystemError,
3
- } = require('@hubspot/local-dev-lib/errors/fileSystemErrors');
4
- const { debugErrorAndContext, logErrorInstance } = require('./standardErrors');
5
-
6
- /**
7
- * Logs a message for an error instance resulting from filesystem interaction.
8
- *
9
- * @param {Error|SystemError|Object} error
10
- * @param {FileSystemErrorContext} context
11
- */
12
- function logFileSystemErrorInstance(error, context) {
13
- const fileSystemError = getFileSystemError(error, context);
14
- logErrorInstance(fileSystemError.message, context);
15
- debugErrorAndContext(error, context);
16
- }
17
-
18
- module.exports = {
19
- logFileSystemErrorInstance,
20
- };
@@ -1,103 +0,0 @@
1
- const util = require('util');
2
- const { logger } = require('@hubspot/local-dev-lib/logger');
3
- const {
4
- isSystemError,
5
- } = require('@hubspot/local-dev-lib/errors/standardErrors');
6
- const { i18n } = require('../lang');
7
-
8
- const i18nKey = 'lib.errorHandlers.standardErrors';
9
-
10
- // TODO: Make these TS interfaces
11
- class ErrorContext {
12
- constructor(props = {}) {
13
- /** @type {number} */
14
- this.accountId = props.accountId;
15
- }
16
- }
17
-
18
- /**
19
- * Logs (debug) the error and context objects.
20
- *
21
- * @param {SystemError} error
22
- * @param {ErrorContext} context
23
- */
24
- function debugErrorAndContext(error, context) {
25
- if (error.name === 'StatusCodeError') {
26
- const { statusCode, message, response } = error;
27
- logger.debug(
28
- i18n(`${i18nKey}.errorOccurred`, {
29
- error: {
30
- statusCode,
31
- message,
32
- url: response.request.href,
33
- method: response.request.method,
34
- response: response.body,
35
- headers: response.headers,
36
- },
37
- })
38
- );
39
- } else {
40
- logger.debug(i18n(`${i18nKey}.errorOccurred`, { error }));
41
- }
42
- if (error.cause) {
43
- logger.debug(
44
- i18n(`${i18nKey}.errorCause`, {
45
- cause: util.inspect(error.cause, false, null, true),
46
- })
47
- );
48
- }
49
- logger.debug(
50
- i18n(`${i18nKey}.errorContext`, {
51
- context: util.inspect(context, false, null, true),
52
- })
53
- );
54
- }
55
-
56
- /**
57
- * Logs a SystemError
58
- * @see {@link https://nodejs.org/api/errors.html#errors_class_systemerror}
59
- *
60
- * @param {SystemError} error
61
- * @param {ErrorContext} context
62
- */
63
- function logSystemError(error, context) {
64
- logger.error(
65
- i18n(`${i18nKey}.systemErrorOccurred`, { error: error.message })
66
- );
67
- debugErrorAndContext(error, context);
68
- }
69
-
70
- /**
71
- * Logs a message for an error instance of type not asserted.
72
- *
73
- * @param {Error|SystemError|Object} error
74
- * @param {ErrorContext} context
75
- */
76
- function logErrorInstance(error, context) {
77
- // SystemError
78
- if (isSystemError(error)) {
79
- logSystemError(error, context);
80
- return;
81
- }
82
- if (error instanceof Error || error.message || error.reason) {
83
- // Error or Error subclass
84
- const name = error.name || 'Error';
85
- const message = [i18n(`${i18nKey}.genericErrorOccurred`, { name })];
86
- [error.message, error.reason].forEach(msg => {
87
- if (msg) {
88
- message.push(msg);
89
- }
90
- });
91
- logger.error(message.join(' '));
92
- } else {
93
- // Unknown errors
94
- logger.error(i18n(`${i18nKey}.unknownErrorOccurred`));
95
- }
96
- debugErrorAndContext(error, context);
97
- }
98
-
99
- module.exports = {
100
- debugErrorAndContext,
101
- ErrorContext,
102
- logErrorInstance,
103
- };