@hubspot/cli 5.1.3-beta.1 → 5.1.4-beta.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.
@@ -1,13 +1,15 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
- const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
2
+ const { logApiErrorInstance } = require('../../lib/errorHandlers/apiErrors');
3
3
  const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
4
4
  const {
5
- isFileValidJSON,
5
+ checkAndConvertToJson,
6
6
  loadAndValidateOptions,
7
7
  } = require('../../lib/validation');
8
8
  const { trackCommandUsage } = require('../../lib/usageTracking');
9
9
  const { getAccountId } = require('../../lib/commonOpts');
10
- const { batchCreateObjects } = require('@hubspot/cli-lib/api/customObject');
10
+ const {
11
+ batchCreateObjects,
12
+ } = require('@hubspot/local-dev-lib/api/customObjects');
11
13
  const { i18n } = require('../../lib/lang');
12
14
 
13
15
  const i18nKey = 'cli.commands.customObject.subcommands.create';
@@ -26,15 +28,17 @@ exports.handler = async options => {
26
28
  trackCommandUsage('custom-object-batch-create', null, accountId);
27
29
 
28
30
  const filePath = getAbsoluteFilePath(definition);
29
- if (!isFileValidJSON(filePath)) {
31
+ const objectJson = checkAndConvertToJson(filePath);
32
+
33
+ if (!objectJson) {
30
34
  process.exit(EXIT_CODES.ERROR);
31
35
  }
32
36
 
33
37
  try {
34
- await batchCreateObjects(accountId, name, filePath);
38
+ await batchCreateObjects(accountId, name, objectJson);
35
39
  logger.success(i18n(`${i18nKey}.success.objectsCreated`));
36
40
  } catch (e) {
37
- logErrorInstance(e, { accountId });
41
+ logApiErrorInstance(e, { accountId });
38
42
  logger.error(
39
43
  i18n(`${i18nKey}.errors.creationFailed`, {
40
44
  definition,
@@ -1,10 +1,8 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
- const {
3
- logErrorInstance,
4
- } = require('../../../lib/errorHandlers/standardErrors');
2
+ const { logApiErrorInstance } = require('../../../lib/errorHandlers/apiErrors');
5
3
  const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
6
4
  const {
7
- isFileValidJSON,
5
+ checkAndConvertToJson,
8
6
  loadAndValidateOptions,
9
7
  } = require('../../../lib/validation');
10
8
  const { trackCommandUsage } = require('../../../lib/usageTracking');
@@ -14,10 +12,12 @@ const {
14
12
  isConfigFlagEnabled,
15
13
  } = require('@hubspot/local-dev-lib/config');
16
14
  const { ENVIRONMENTS, ConfigFlags } = require('@hubspot/cli-lib/lib/constants');
17
- const { createSchema } = require('@hubspot/cli-lib/api/schema');
15
+ const {
16
+ createObjectSchema,
17
+ } = require('@hubspot/local-dev-lib/api/customObjects');
18
18
  const {
19
19
  createSchema: createSchemaFromHubFile,
20
- } = require('@hubspot/cli-lib/api/fileTransport');
20
+ } = require('@hubspot/local-dev-lib/api/fileTransport');
21
21
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
22
22
  const { i18n } = require('../../../lib/lang');
23
23
 
@@ -38,7 +38,8 @@ exports.handler = async options => {
38
38
  trackCommandUsage('custom-object-schema-create', null, accountId);
39
39
 
40
40
  const filePath = getAbsoluteFilePath(definition);
41
- if (!isFileValidJSON(filePath)) {
41
+ const schemaJson = checkAndConvertToJson(filePath);
42
+ if (!schemaJson) {
42
43
  process.exit(EXIT_CODES.ERROR);
43
44
  }
44
45
 
@@ -51,7 +52,7 @@ exports.handler = async options => {
51
52
  })
52
53
  );
53
54
  } else {
54
- const res = await createSchema(accountId, filePath);
55
+ const res = await createObjectSchema(accountId, schemaJson);
55
56
  logger.success(
56
57
  i18n(`${i18nKey}.success.schemaViewable`, {
57
58
  url: `${getHubSpotWebsiteOrigin(
@@ -61,7 +62,7 @@ exports.handler = async options => {
61
62
  );
62
63
  }
63
64
  } catch (e) {
64
- logErrorInstance(e, { accountId });
65
+ logApiErrorInstance(e, { accountId });
65
66
  logger.error(
66
67
  i18n(`${i18nKey}.errors.creationFailed`, {
67
68
  definition,
@@ -1,12 +1,12 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
- const {
3
- logErrorInstance,
4
- } = require('../../../lib/errorHandlers/standardErrors');
2
+ const { logApiErrorInstance } = require('../../../lib/errorHandlers/apiErrors');
5
3
 
6
4
  const { loadAndValidateOptions } = require('../../../lib/validation');
7
5
  const { trackCommandUsage } = require('../../../lib/usageTracking');
8
6
  const { getAccountId } = require('../../../lib/commonOpts');
9
- const { deleteSchema } = require('@hubspot/cli-lib/api/schema');
7
+ const {
8
+ deleteObjectSchema,
9
+ } = require('@hubspot/local-dev-lib/api/customObjects');
10
10
  const { i18n } = require('../../../lib/lang');
11
11
 
12
12
  const i18nKey =
@@ -25,14 +25,14 @@ exports.handler = async options => {
25
25
  trackCommandUsage('custom-object-schema-delete', null, accountId);
26
26
 
27
27
  try {
28
- await deleteSchema(accountId, name);
28
+ await deleteObjectSchema(accountId, name);
29
29
  logger.success(
30
30
  i18n(`${i18nKey}.success.delete`, {
31
31
  name,
32
32
  })
33
33
  );
34
34
  } catch (e) {
35
- logErrorInstance(e);
35
+ logApiErrorInstance(e);
36
36
  logger.error(
37
37
  i18n(`${i18nKey}.errors.delete`, {
38
38
  name,
@@ -9,7 +9,7 @@ const {
9
9
  downloadSchema,
10
10
  getResolvedPath,
11
11
  } = require('@hubspot/local-dev-lib/customObjects');
12
- const { fetchSchema } = require('@hubspot/cli-lib/api/fileTransport');
12
+ const { fetchSchema } = require('@hubspot/local-dev-lib/api/fileTransport');
13
13
  const { getCwd } = require('@hubspot/local-dev-lib/path');
14
14
 
15
15
  const { loadAndValidateOptions } = require('../../../lib/validation');
@@ -1,10 +1,8 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
- const {
3
- logErrorInstance,
4
- } = require('../../../lib/errorHandlers/standardErrors');
2
+ const { logApiErrorInstance } = require('../../../lib/errorHandlers/apiErrors');
5
3
  const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
6
4
  const {
7
- isFileValidJSON,
5
+ checkAndConvertToJson,
8
6
  loadAndValidateOptions,
9
7
  } = require('../../../lib/validation');
10
8
  const { trackCommandUsage } = require('../../../lib/usageTracking');
@@ -14,10 +12,12 @@ const {
14
12
  getEnv,
15
13
  isConfigFlagEnabled,
16
14
  } = require('@hubspot/local-dev-lib/config');
17
- const { updateSchema } = require('@hubspot/cli-lib/api/schema');
15
+ const {
16
+ updateObjectSchema,
17
+ } = require('@hubspot/local-dev-lib/api/customObjects');
18
18
  const {
19
19
  updateSchema: updateSchemaFromHubFile,
20
- } = require('@hubspot/cli-lib/api/fileTransport');
20
+ } = require('@hubspot/local-dev-lib/api/fileTransport');
21
21
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
22
22
  const { i18n } = require('../../../lib/lang');
23
23
 
@@ -38,7 +38,8 @@ exports.handler = async options => {
38
38
  trackCommandUsage('custom-object-schema-update', null, accountId);
39
39
 
40
40
  const filePath = getAbsoluteFilePath(definition);
41
- if (!isFileValidJSON(filePath)) {
41
+ const schemaJson = checkAndConvertToJson(filePath);
42
+ if (!schemaJson) {
42
43
  process.exit(EXIT_CODES.ERROR);
43
44
  }
44
45
 
@@ -51,7 +52,7 @@ exports.handler = async options => {
51
52
  })
52
53
  );
53
54
  } else {
54
- const res = await updateSchema(accountId, name, filePath);
55
+ const res = await updateObjectSchema(accountId, name, schemaJson);
55
56
  logger.success(
56
57
  i18n(`${i18nKey}.success.viewAtUrl`, {
57
58
  url: `${getHubSpotWebsiteOrigin(
@@ -61,7 +62,7 @@ exports.handler = async options => {
61
62
  );
62
63
  }
63
64
  } catch (e) {
64
- logErrorInstance(e, { accountId });
65
+ logApiErrorInstance(e, { accountId });
65
66
  logger.error(
66
67
  i18n(`${i18nKey}.errors.update`, {
67
68
  definition,
@@ -15,7 +15,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
15
15
  const {
16
16
  buildPackage,
17
17
  getBuildStatus,
18
- } = require('@hubspot/cli-lib/api/functions');
18
+ } = require('@hubspot/local-dev-lib/api/functions');
19
19
  const { loadAndValidateOptions } = require('../../lib/validation');
20
20
  const { outputBuildLog } = require('../../lib/serverlessLogs');
21
21
  const { i18n } = require('../../lib/lang');
@@ -1,4 +1,4 @@
1
- const { getRoutes } = require('@hubspot/cli-lib/api/functions');
1
+ const { getRoutes } = require('@hubspot/local-dev-lib/api/functions');
2
2
  const { logger } = require('@hubspot/cli-lib/logger');
3
3
  const {
4
4
  logApiErrorInstance,
@@ -1,7 +1,7 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
- const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
3
- const { clearHubDbTableRows } = require('@hubspot/cli-lib/hubdb');
4
- const { publishTable } = require('@hubspot/cli-lib/api/hubdb');
2
+ const { logApiErrorInstance } = require('../../lib/errorHandlers/apiErrors');
3
+ const { clearHubDbTableRows } = require('@hubspot/local-dev-lib/hubdb');
4
+ const { publishTable } = require('@hubspot/local-dev-lib/api/hubdb');
5
5
 
6
6
  const { loadAndValidateOptions } = require('../../lib/validation');
7
7
  const { trackCommandUsage } = require('../../lib/usageTracking');
@@ -52,7 +52,7 @@ exports.handler = async options => {
52
52
  );
53
53
  }
54
54
  } catch (e) {
55
- logErrorInstance(e);
55
+ logApiErrorInstance(e);
56
56
  }
57
57
  };
58
58
 
@@ -1,12 +1,12 @@
1
1
  const path = require('path');
2
2
 
3
3
  const { logger } = require('@hubspot/cli-lib/logger');
4
- const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
4
+ const { logApiErrorInstance } = require('../../lib/errorHandlers/apiErrors');
5
5
  const { getCwd } = require('@hubspot/local-dev-lib/path');
6
- const { createHubDbTable } = require('@hubspot/cli-lib/hubdb');
6
+ const { createHubDbTable } = require('@hubspot/local-dev-lib/hubdb');
7
7
 
8
8
  const {
9
- isFileValidJSON,
9
+ checkAndConvertToJson,
10
10
  loadAndValidateOptions,
11
11
  } = require('../../lib/validation');
12
12
  const { trackCommandUsage } = require('../../lib/usageTracking');
@@ -35,7 +35,7 @@ exports.handler = async options => {
35
35
 
36
36
  try {
37
37
  const filePath = path.resolve(getCwd(), src);
38
- if (!isFileValidJSON(filePath)) {
38
+ if (!checkAndConvertToJson(filePath)) {
39
39
  process.exit(EXIT_CODES.ERROR);
40
40
  }
41
41
 
@@ -56,7 +56,7 @@ exports.handler = async options => {
56
56
  src,
57
57
  })
58
58
  );
59
- logErrorInstance(e);
59
+ logApiErrorInstance(e);
60
60
  }
61
61
  };
62
62
 
@@ -1,6 +1,6 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
- const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
3
- const { deleteTable } = require('@hubspot/cli-lib/api/hubdb');
2
+ const { logApiErrorInstance } = require('../../lib/errorHandlers/apiErrors');
3
+ const { deleteTable } = require('@hubspot/local-dev-lib/api/hubdb');
4
4
  const { loadAndValidateOptions } = require('../../lib/validation');
5
5
  const { trackCommandUsage } = require('../../lib/usageTracking');
6
6
 
@@ -40,7 +40,7 @@ exports.handler = async options => {
40
40
  tableId,
41
41
  })
42
42
  );
43
- logErrorInstance(e);
43
+ logApiErrorInstance(e);
44
44
  }
45
45
  };
46
46
 
@@ -1,6 +1,6 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
- const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
3
- const { downloadHubDbTable } = require('@hubspot/cli-lib/hubdb');
2
+ const { logApiErrorInstance } = require('../../lib/errorHandlers/apiErrors');
3
+ const { downloadHubDbTable } = require('@hubspot/local-dev-lib/hubdb');
4
4
 
5
5
  const { loadAndValidateOptions } = require('../../lib/validation');
6
6
  const { trackCommandUsage } = require('../../lib/usageTracking');
@@ -37,7 +37,7 @@ exports.handler = async options => {
37
37
  })
38
38
  );
39
39
  } catch (e) {
40
- logErrorInstance(e);
40
+ logApiErrorInstance(e);
41
41
  }
42
42
  };
43
43
 
package/commands/mv.js CHANGED
@@ -1,5 +1,6 @@
1
- const { moveFile } = require('@hubspot/local-dev-lib/api/fileMapper');
2
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
+ const { moveFile } = require('@hubspot/local-dev-lib/api/fileMapper');
3
+ const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
3
4
  const {
4
5
  logApiErrorInstance,
5
6
  ApiErrorContext,
@@ -55,7 +56,7 @@ exports.handler = async options => {
55
56
  srcPath,
56
57
  })
57
58
  );
58
- if (error.statusCode === 409) {
59
+ if (isSpecifiedError(error, { statusCode: 409 })) {
59
60
  logger.error(
60
61
  i18n(`${i18nKey}.errors.sourcePathExists`, {
61
62
  destPath,
@@ -11,7 +11,10 @@ const {
11
11
  ApiErrorContext,
12
12
  } = require('../../lib/errorHandlers/apiErrors');
13
13
  const { logger } = require('@hubspot/cli-lib/logger');
14
- const { deployProject, fetchProject } = require('@hubspot/cli-lib/api/dfs');
14
+ const {
15
+ deployProject,
16
+ fetchProject,
17
+ } = require('@hubspot/local-dev-lib/api/projects');
15
18
  const { loadAndValidateOptions } = require('../../lib/validation');
16
19
  const { getProjectConfig, pollDeployStatus } = require('../../lib/projects');
17
20
  const { projectNamePrompt } = require('../../lib/prompts/projectNamePrompt');
@@ -18,7 +18,10 @@ const {
18
18
  getAccountConfig,
19
19
  getEnv,
20
20
  } = require('@hubspot/local-dev-lib/config');
21
- const { createProject, fetchProject } = require('@hubspot/cli-lib/api/dfs');
21
+ const {
22
+ createProject,
23
+ fetchProject,
24
+ } = require('@hubspot/local-dev-lib/api/projects');
22
25
  const {
23
26
  getProjectConfig,
24
27
  ensureProjectExists,
@@ -16,7 +16,7 @@ const { extractZipArchive } = require('@hubspot/local-dev-lib/archive');
16
16
  const {
17
17
  downloadProject,
18
18
  fetchProjectBuilds,
19
- } = require('@hubspot/cli-lib/api/dfs');
19
+ } = require('@hubspot/local-dev-lib/api/projects');
20
20
  const { ensureProjectExists, getProjectConfig } = require('../../lib/projects');
21
21
  const { loadAndValidateOptions } = require('../../lib/validation');
22
22
  const {
@@ -16,7 +16,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
16
16
  const {
17
17
  fetchProject,
18
18
  fetchProjectBuilds,
19
- } = require('@hubspot/cli-lib/api/dfs');
19
+ } = require('@hubspot/local-dev-lib/api/projects');
20
20
  const {
21
21
  getTableContents,
22
22
  getTableHeader,
@@ -13,21 +13,21 @@ const { logger } = require('@hubspot/cli-lib/logger');
13
13
  const {
14
14
  fetchProject,
15
15
  fetchDeployComponentsMetadata,
16
- } = require('@hubspot/cli-lib/api/dfs');
16
+ } = require('@hubspot/local-dev-lib/api/projects');
17
17
  const {
18
18
  getTableContents,
19
19
  getTableHeader,
20
20
  } = require('@hubspot/local-dev-lib/logging/table');
21
21
  // const {
22
- // getProjectAppFunctionLogs,
23
- // getLatestProjectAppFunctionLog,
24
- // getFunctionLogs,
25
- // getLatestFunctionLog,
26
- // } = require('@hubspot/cli-lib/api/functions');
27
- // const {
28
22
  // logApiErrorInstance,
29
23
  // ApiErrorContext,
30
24
  // } = require('../../lib/errorHandlers/apiErrors');
25
+ // const {
26
+ // getFunctionLogs,
27
+ // getLatestFunctionLog,
28
+ // getProjectAppFunctionLogs,
29
+ // getLatestProjectAppFunctionLog,
30
+ // } = require('@hubspot/local-dev-lib/api/functions');
31
31
 
32
32
  const { ensureProjectExists } = require('../../lib/projects');
33
33
  const { loadAndValidateOptions } = require('../../lib/validation');
@@ -30,7 +30,7 @@ const { EXIT_CODES } = require('../../lib/enums/exitCodes');
30
30
 
31
31
  const i18nKey = 'cli.commands.project.subcommands.upload';
32
32
 
33
- exports.command = 'upload [path]';
33
+ exports.command = 'upload [path] [--forceCreate] [--message]';
34
34
  exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
35
35
 
36
36
  exports.handler = async options => {
@@ -49,7 +49,10 @@ exports.handler = async options => {
49
49
 
50
50
  await showPlatformVersionWarning(accountId, projectConfig);
51
51
 
52
- await ensureProjectExists(accountId, projectConfig.name, { forceCreate });
52
+ await ensureProjectExists(accountId, projectConfig.name, {
53
+ forceCreate,
54
+ uploadCommand: true,
55
+ });
53
56
 
54
57
  try {
55
58
  const result = await handleProjectUpload(
@@ -27,7 +27,8 @@ const {
27
27
  const {
28
28
  cancelStagedBuild,
29
29
  fetchProjectBuilds,
30
- } = require('@hubspot/cli-lib/api/dfs');
30
+ } = require('@hubspot/local-dev-lib/api/projects');
31
+ const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
31
32
  const { loadAndValidateOptions } = require('../../lib/validation');
32
33
  const { EXIT_CODES } = require('../../lib/enums/exitCodes');
33
34
  const { handleKeypress, handleExit } = require('../../lib/process');
@@ -64,7 +65,11 @@ const handleUserInput = (accountId, projectName, currentBuildId) => {
64
65
  await cancelStagedBuild(accountId, projectName);
65
66
  process.exit(EXIT_CODES.SUCCESS);
66
67
  } catch (err) {
67
- if (err.error.subCategory === ERROR_TYPES.BUILD_NOT_IN_PROGRESS) {
68
+ if (
69
+ isSpecifiedError(err, {
70
+ subCategory: ERROR_TYPES.BUILD_NOT_IN_PROGRESS,
71
+ })
72
+ ) {
68
73
  process.exit(EXIT_CODES.SUCCESS);
69
74
  } else {
70
75
  logApiErrorInstance(
@@ -1,9 +1,9 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
2
  const {
3
- logServerlessFunctionApiErrorInstance,
3
+ logApiErrorInstance,
4
4
  ApiErrorContext,
5
5
  } = require('../../lib/errorHandlers/apiErrors');
6
- const { addSecret } = require('@hubspot/cli-lib/api/secrets');
6
+ const { addSecret } = require('@hubspot/local-dev-lib/api/secrets');
7
7
 
8
8
  const { loadAndValidateOptions } = require('../../lib/validation');
9
9
  const { trackCommandUsage } = require('../../lib/usageTracking');
@@ -41,15 +41,14 @@ exports.handler = async options => {
41
41
  secretName,
42
42
  })
43
43
  );
44
- } catch (e) {
44
+ } catch (err) {
45
45
  logger.error(
46
46
  i18n(`${i18nKey}.errors.add`, {
47
47
  secretName,
48
48
  })
49
49
  );
50
- await logServerlessFunctionApiErrorInstance(
51
- accountId,
52
- e,
50
+ logApiErrorInstance(
51
+ err,
53
52
  new ApiErrorContext({
54
53
  request: 'add secret',
55
54
  accountId,
@@ -1,9 +1,9 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
2
  const {
3
- logServerlessFunctionApiErrorInstance,
4
3
  ApiErrorContext,
4
+ logApiErrorInstance,
5
5
  } = require('../../lib/errorHandlers/apiErrors');
6
- const { deleteSecret } = require('@hubspot/cli-lib/api/secrets');
6
+ const { deleteSecret } = require('@hubspot/local-dev-lib/api/secrets');
7
7
 
8
8
  const { loadAndValidateOptions } = require('../../lib/validation');
9
9
  const { trackCommandUsage } = require('../../lib/usageTracking');
@@ -38,15 +38,14 @@ exports.handler = async options => {
38
38
  secretName,
39
39
  })
40
40
  );
41
- } catch (e) {
41
+ } catch (err) {
42
42
  logger.error(
43
43
  i18n(`${i18nKey}.errors.delete`, {
44
44
  secretName,
45
45
  })
46
46
  );
47
- await logServerlessFunctionApiErrorInstance(
48
- accountId,
49
- e,
47
+ logApiErrorInstance(
48
+ err,
50
49
  new ApiErrorContext({
51
50
  request: 'delete a secret',
52
51
  accountId,
@@ -1,9 +1,9 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
2
  const {
3
- logServerlessFunctionApiErrorInstance,
3
+ logApiErrorInstance,
4
4
  ApiErrorContext,
5
5
  } = require('../../lib/errorHandlers/apiErrors');
6
- const { fetchSecrets } = require('@hubspot/cli-lib/api/secrets');
6
+ const { fetchSecrets } = require('@hubspot/local-dev-lib/api/secrets');
7
7
 
8
8
  const { loadAndValidateOptions } = require('../../lib/validation');
9
9
  const { trackCommandUsage } = require('../../lib/usageTracking');
@@ -36,11 +36,10 @@ exports.handler = async options => {
36
36
  logger.group(groupLabel);
37
37
  results.forEach(secret => logger.log(secret));
38
38
  logger.groupEnd(groupLabel);
39
- } catch (e) {
39
+ } catch (err) {
40
40
  logger.error(i18n(`${i18nKey}.errors.list`));
41
- await logServerlessFunctionApiErrorInstance(
42
- accountId,
43
- e,
41
+ logApiErrorInstance(
42
+ err,
44
43
  new ApiErrorContext({
45
44
  request: 'add secret',
46
45
  accountId,
@@ -1,9 +1,9 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
2
  const {
3
- logServerlessFunctionApiErrorInstance,
4
3
  ApiErrorContext,
4
+ logApiErrorInstance,
5
5
  } = require('../../lib/errorHandlers/apiErrors');
6
- const { updateSecret } = require('@hubspot/cli-lib/api/secrets');
6
+ const { updateSecret } = require('@hubspot/local-dev-lib/api/secrets');
7
7
 
8
8
  const { loadAndValidateOptions } = require('../../lib/validation');
9
9
  const { trackCommandUsage } = require('../../lib/usageTracking');
@@ -42,15 +42,14 @@ exports.handler = async options => {
42
42
  })
43
43
  );
44
44
  logger.log(i18n(`${i18nKey}.success.updateExplanation`));
45
- } catch (e) {
45
+ } catch (err) {
46
46
  logger.error(
47
47
  i18n(`${i18nKey}.errors.update`, {
48
48
  secretName,
49
49
  })
50
50
  );
51
- await logServerlessFunctionApiErrorInstance(
52
- accountId,
53
- e,
51
+ logApiErrorInstance(
52
+ err,
54
53
  new ApiErrorContext({
55
54
  request: 'update secret',
56
55
  accountId,
package/lang/en.lyaml CHANGED
@@ -933,6 +933,7 @@ en:
933
933
  fileFiltered: "Ignore rule triggered for \"{{ filename }}\""
934
934
  ensureProjectExists:
935
935
  createPrompt: "The project {{ projectName }} does not exist in {{ accountIdentifier }}. Would you like to create it?"
936
+ createPromptUpload: "[--forceCreate] The project {{ projectName }} does not exist in {{ accountIdentifier }}. Would you like to create it?"
936
937
  createSuccess: "New project {{#bold}}{{ projectName }}{{/bold}} successfully created in {{#bold}}{{ accountIdentifier }}{{/bold}}."
937
938
  notFound: "Your project {{#bold}}{{ projectName }}{{/bold}} could not be found in {{#bold}}{{ accountIdentifier }}{{/bold}}."
938
939
  pollFetchProject:
package/lib/lang.js CHANGED
@@ -52,11 +52,12 @@ const getTextValue = lookupDotNotation => {
52
52
  previouslyCheckedProp = prop;
53
53
  });
54
54
  } catch (e) {
55
- logger.error(
55
+ logger.debug(
56
56
  `Unable to access language property: ${lookupProps.join(
57
57
  '.'
58
58
  )}. Failed to access prop "${previouslyCheckedProp}".`
59
59
  );
60
+ logger.error('Unable to access language property.');
60
61
  return missingTextData;
61
62
  }
62
63
 
@@ -92,4 +93,5 @@ const setLangData = (newLocale, newLangObj) => {
92
93
  module.exports = {
93
94
  i18n,
94
95
  setLangData,
96
+ MISSING_LANGUAGE_DATA_PREFIX,
95
97
  };
@@ -5,7 +5,7 @@ const {
5
5
  requestValidation,
6
6
  getValidationStatus,
7
7
  getValidationResults,
8
- } = require('@hubspot/cli-lib/api/marketplaceValidation');
8
+ } = require('@hubspot/local-dev-lib/api/marketplaceValidation');
9
9
  const { i18n } = require('./lang');
10
10
  const { EXIT_CODES } = require('./enums/exitCodes');
11
11
 
package/lib/projects.js CHANGED
@@ -28,7 +28,8 @@ const {
28
28
  getDeployStructure,
29
29
  fetchProject,
30
30
  uploadProject,
31
- } = require('@hubspot/cli-lib/api/dfs');
31
+ } = require('@hubspot/local-dev-lib/api/projects');
32
+ const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
32
33
  const { shouldIgnoreFile } = require('@hubspot/local-dev-lib/ignoreRules');
33
34
  const { getCwd, getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
34
35
  const { downloadGitHubRepoContents } = require('@hubspot/cli-lib/github');
@@ -40,7 +41,6 @@ const SpinniesManager = require('./SpinniesManager');
40
41
  const {
41
42
  logApiErrorInstance,
42
43
  ApiErrorContext,
43
- isSpecifiedError, // Migrate isSpecifiedError to local-dev-lib version only after fetchProject is migrated to local-dev-lib
44
44
  isSpecifiedHubSpotAuthError,
45
45
  } = require('./errorHandlers/apiErrors');
46
46
  const { HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH } = require('./constants');
@@ -238,6 +238,7 @@ const ensureProjectExists = async (
238
238
  allowCreate = true,
239
239
  noLogs = false,
240
240
  withPolling = false,
241
+ uploadCommand = false,
241
242
  } = {}
242
243
  ) => {
243
244
  const accountIdentifier = uiAccountDescription(accountId);
@@ -247,14 +248,14 @@ const ensureProjectExists = async (
247
248
  : await fetchProject(accountId, projectName);
248
249
  return !!project;
249
250
  } catch (err) {
250
- if (err.statusCode === 404) {
251
+ if (isSpecifiedError(err, { statusCode: 404 })) {
251
252
  let shouldCreateProject = forceCreate;
252
-
253
253
  if (allowCreate && !shouldCreateProject) {
254
+ const promptKey = uploadCommand ? 'createPromptUpload' : 'createPrompt';
254
255
  const promptResult = await promptUser([
255
256
  {
256
257
  name: 'shouldCreateProject',
257
- message: i18n(`${i18nKey}.ensureProjectExists.createPrompt`, {
258
+ message: i18n(`${i18nKey}.ensureProjectExists.${promptKey}`, {
258
259
  projectName,
259
260
  accountIdentifier,
260
261
  }),
@@ -16,7 +16,8 @@ const {
16
16
  uploadFileToBuild,
17
17
  deleteFileFromBuild,
18
18
  queueBuild,
19
- } = require('@hubspot/cli-lib/api/dfs');
19
+ } = require('@hubspot/local-dev-lib/api/projects');
20
+ const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
20
21
  const { ERROR_TYPES } = require('@hubspot/cli-lib/lib/constants');
21
22
 
22
23
  const i18nKey = 'cli.commands.project.subcommands.watch';
@@ -29,25 +30,40 @@ let currentBuildId = null;
29
30
  let handleBuildStatus, handleUserInput;
30
31
  let timer;
31
32
 
32
- const processStandByQueue = async (accountId, projectName) => {
33
+ const processStandByQueue = async (accountId, projectName, platformVersion) => {
33
34
  queue.addAll(
34
35
  standbyeQueue.map(({ filePath, remotePath, action }) => {
35
36
  return async () => {
36
- queueFileOrFolder(accountId, projectName, filePath, remotePath, action);
37
+ queueFileOrFolder(
38
+ accountId,
39
+ projectName,
40
+ platformVersion,
41
+ filePath,
42
+ remotePath,
43
+ action
44
+ );
37
45
  };
38
46
  })
39
47
  );
40
48
  standbyeQueue.length = 0;
41
- debounceQueueBuild(accountId, projectName);
49
+ debounceQueueBuild(accountId, projectName, platformVersion);
42
50
  };
43
51
 
44
- const createNewStagingBuild = async (accountId, projectName) => {
45
- currentBuildId = await createNewBuild(accountId, projectName);
52
+ const createNewStagingBuild = async (
53
+ accountId,
54
+ projectName,
55
+ platformVersion
56
+ ) => {
57
+ currentBuildId = await createNewBuild(
58
+ accountId,
59
+ projectName,
60
+ platformVersion
61
+ );
46
62
 
47
63
  handleUserInput(accountId, projectName, currentBuildId);
48
64
  };
49
65
 
50
- const debounceQueueBuild = (accountId, projectName) => {
66
+ const debounceQueueBuild = (accountId, projectName, platformVersion) => {
51
67
  if (timer) {
52
68
  clearTimeout(timer);
53
69
  }
@@ -58,12 +74,13 @@ const debounceQueueBuild = (accountId, projectName) => {
58
74
  await queue.onIdle();
59
75
 
60
76
  try {
61
- await queueBuild(accountId, projectName);
77
+ await queueBuild(accountId, projectName, platformVersion);
62
78
  logger.debug(i18n(`${i18nKey}.debug.buildStarted`, { projectName }));
63
79
  } catch (err) {
64
80
  if (
65
- err.error &&
66
- err.error.subCategory === ERROR_TYPES.MISSING_PROJECT_PROVISION
81
+ isSpecifiedError(err, {
82
+ subCategory: ERROR_TYPES.MISSING_PROJECT_PROVISION,
83
+ })
67
84
  ) {
68
85
  logger.log(i18n(`${i18nKey}.logs.watchCancelledFromUi`));
69
86
  process.exit(0);
@@ -79,10 +96,10 @@ const debounceQueueBuild = (accountId, projectName) => {
79
96
 
80
97
  await handleBuildStatus(accountId, projectName, currentBuildId);
81
98
 
82
- await createNewStagingBuild(accountId, projectName);
99
+ await createNewStagingBuild(accountId, projectName, platformVersion);
83
100
 
84
101
  if (standbyeQueue.length > 0) {
85
- await processStandByQueue(accountId, projectName);
102
+ await processStandByQueue(accountId, projectName, platformVersion);
86
103
  }
87
104
 
88
105
  queue.start();
@@ -94,6 +111,7 @@ const debounceQueueBuild = (accountId, projectName) => {
94
111
  const queueFileOrFolder = async (
95
112
  accountId,
96
113
  projectName,
114
+ platformVersion,
97
115
  filePath,
98
116
  remotePath,
99
117
  action
@@ -107,7 +125,7 @@ const queueFileOrFolder = async (
107
125
  return;
108
126
  }
109
127
  if (!queue.isPaused) {
110
- debounceQueueBuild(accountId, projectName);
128
+ debounceQueueBuild(accountId, projectName, platformVersion);
111
129
  }
112
130
 
113
131
  logger.debug(i18n(`${i18nKey}.debug.uploading`, { filePath, remotePath }));
@@ -130,14 +148,18 @@ const queueFileOrFolder = async (
130
148
  });
131
149
  };
132
150
 
133
- const createNewBuild = async (accountId, projectName) => {
151
+ const createNewBuild = async (accountId, projectName, platformVersion) => {
134
152
  try {
135
153
  logger.debug(i18n(`${i18nKey}.debug.attemptNewBuild`));
136
- const { buildId } = await provisionBuild(accountId, projectName);
154
+ const { buildId } = await provisionBuild(
155
+ accountId,
156
+ projectName,
157
+ platformVersion
158
+ );
137
159
  return buildId;
138
160
  } catch (err) {
139
161
  logApiErrorInstance(err, new ApiErrorContext({ accountId, projectName }));
140
- if (err.error.subCategory !== ERROR_TYPES.PROJECT_LOCKED) {
162
+ if (isSpecifiedError(err, { subCategory: ERROR_TYPES.PROJECT_LOCKED })) {
141
163
  await cancelStagedBuild(accountId, projectName);
142
164
  logger.log(i18n(`${i18nKey}.logs.previousStagingBuildCancelled`));
143
165
  }
@@ -148,6 +170,7 @@ const createNewBuild = async (accountId, projectName) => {
148
170
  const handleWatchEvent = async (
149
171
  accountId,
150
172
  projectName,
173
+ platformVersion,
151
174
  projectSourceDir,
152
175
  filePath,
153
176
  action = 'upload'
@@ -165,6 +188,7 @@ const handleWatchEvent = async (
165
188
  await queueFileOrFolder(
166
189
  accountId,
167
190
  projectName,
191
+ platformVersion,
168
192
  filePath,
169
193
  remotePath,
170
194
  action
@@ -184,7 +208,11 @@ const createWatcher = async (
184
208
  handleBuildStatus = handleBuildStatusFn;
185
209
  handleUserInput = handleUserInputFn;
186
210
 
187
- await createNewStagingBuild(accountId, projectConfig.name);
211
+ await createNewStagingBuild(
212
+ accountId,
213
+ projectConfig.name,
214
+ projectConfig.platformVersion
215
+ );
188
216
 
189
217
  const watcher = chokidar.watch(projectSourceDir, {
190
218
  ignoreInitial: true,
@@ -195,15 +223,28 @@ const createWatcher = async (
195
223
  logger.log(`\n> Press ${chalk.bold('q')} to quit watching\n`);
196
224
  });
197
225
  watcher.on('add', async path => {
198
- handleWatchEvent(accountId, projectConfig.name, projectSourceDir, path);
226
+ handleWatchEvent(
227
+ accountId,
228
+ projectConfig.name,
229
+ projectConfig.platformVersion,
230
+ projectSourceDir,
231
+ path
232
+ );
199
233
  });
200
234
  watcher.on('change', async path => {
201
- handleWatchEvent(accountId, projectConfig.name, projectSourceDir, path);
235
+ handleWatchEvent(
236
+ accountId,
237
+ projectConfig.name,
238
+ projectConfig.platformVersion,
239
+ projectSourceDir,
240
+ path
241
+ );
202
242
  });
203
243
  watcher.on('unlink', async path => {
204
244
  handleWatchEvent(
205
245
  accountId,
206
246
  projectConfig.name,
247
+ projectConfig.platformVersion,
207
248
  projectSourceDir,
208
249
  path,
209
250
  'deleteFile'
@@ -213,6 +254,7 @@ const createWatcher = async (
213
254
  handleWatchEvent(
214
255
  accountId,
215
256
  projectConfig.name,
257
+ projectConfig.platformVersion,
216
258
  projectSourceDir,
217
259
  path,
218
260
  'deleteFolder'
@@ -1,6 +1,6 @@
1
1
  const { promptUser } = require('./promptUtils');
2
2
  const { getAccountId } = require('@hubspot/local-dev-lib/config');
3
- const { fetchProjects } = require('@hubspot/cli-lib/api/dfs');
3
+ const { fetchProjects } = require('@hubspot/local-dev-lib/api/projects');
4
4
  const {
5
5
  logApiErrorInstance,
6
6
  ApiErrorContext,
@@ -1,5 +1,5 @@
1
1
  const { i18n } = require('../lang');
2
- const { fetchProject } = require('@hubspot/cli-lib/api/dfs');
2
+ const { fetchProject } = require('@hubspot/local-dev-lib/api/projects');
3
3
  const { promptUser } = require('./promptUtils');
4
4
  const { getAccountId } = require('../commonOpts');
5
5
  const { getProjectConfig, ensureProjectExists } = require('../projects');
package/lib/sandboxes.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const chalk = require('chalk');
2
- const { i18n } = require('./lang');
2
+ const { i18n, MISSING_LANGUAGE_DATA_PREFIX } = require('./lang');
3
3
  const { handleExit, handleKeypress } = require('./process');
4
4
  const { logger } = require('@hubspot/cli-lib/logger');
5
5
  const {
@@ -332,7 +332,6 @@ function pollSyncTaskStatus(
332
332
  const mergeTasks = {
333
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.
334
334
  };
335
- const ignoreTasks = ['gates'];
336
335
  let progressCounter = {};
337
336
  let pollInterval;
338
337
  // Handle manual exit for return key and ctrl+c
@@ -368,16 +367,16 @@ function pollSyncTaskStatus(
368
367
  // Array of sync tasks, eg: workflows, pipelines, object-schemas, etc. with each task containing a status of 'PENDING', 'IN_PROGRESS', 'COMPLETE', and 'FAILURE'
369
368
  for (const task of taskResult.tasks) {
370
369
  // For each sync task, show a progress bar and increment bar each time we run this interval until status is 'COMPLETE'
371
- const taskType = task.type;
372
- if (
373
- !progressBar.get(taskType) &&
374
- !mergeTasks[taskType] &&
375
- !ignoreTasks.includes(taskType)
376
- ) {
370
+ let taskType = task.type;
371
+ const taskTypeLabel = i18n(`${i18nKey}.${taskType}.label`);
372
+ if (taskTypeLabel.startsWith(MISSING_LANGUAGE_DATA_PREFIX)) {
373
+ continue;
374
+ }
375
+ if (!progressBar.get(taskType) && !mergeTasks[taskType]) {
377
376
  // skip creation of lead-flows bar because we're combining lead-flows into the forms bar, otherwise create a bar instance for the type
378
377
  progressCounter[taskType] = 0;
379
378
  progressBar.create(taskType, 100, 0, {
380
- label: i18n(`${i18nKey}.${taskType}.label`),
379
+ label: taskTypeLabel,
381
380
  });
382
381
  } else if (mergeTasks[taskType]) {
383
382
  // It's a lead-flow here, merge status into the forms progress bar
@@ -408,7 +407,7 @@ function pollSyncTaskStatus(
408
407
  }
409
408
  if (progressBar.get(taskType) && task.status === 'COMPLETE') {
410
409
  progressBar.update(taskType, 100, {
411
- label: i18n(`${i18nKey}.${taskType}.label`),
410
+ label: taskTypeLabel,
412
411
  });
413
412
  } else if (
414
413
  // Do not start incrementing for tasks still in PENDING state
@@ -421,7 +420,7 @@ function pollSyncTaskStatus(
421
420
  taskType === syncTypes.OBJECT_RECORDS ? 2 : 3 // slower progress for object-records, sync can take up to a few minutes
422
421
  );
423
422
  progressBar.update(taskType, progressCounter[taskType], {
424
- label: i18n(`${i18nKey}.${taskType}.label`),
423
+ label: taskTypeLabel,
425
424
  });
426
425
  }
427
426
  }
package/lib/schema.js CHANGED
@@ -1,7 +1,9 @@
1
1
  const chalk = require('chalk');
2
2
  const { logger } = require('@hubspot/cli-lib/logger');
3
3
  const { table, getBorderCharacters } = require('table');
4
- const { fetchSchemas } = require('@hubspot/cli-lib/api/schema');
4
+ const {
5
+ fetchObjectSchemas,
6
+ } = require('@hubspot/local-dev-lib/api/customObjects');
5
7
 
6
8
  const logSchemas = schemas => {
7
9
  const data = schemas
@@ -22,7 +24,7 @@ const logSchemas = schemas => {
22
24
  };
23
25
 
24
26
  const listSchemas = async accountId => {
25
- const response = await fetchSchemas(accountId);
27
+ const response = await fetchObjectSchemas(accountId);
26
28
  logSchemas(response.results);
27
29
  };
28
30
 
package/lib/validation.js CHANGED
@@ -206,29 +206,31 @@ const fileExists = _path => {
206
206
  return true;
207
207
  };
208
208
 
209
- const isFileValidJSON = _path => {
209
+ const checkAndConvertToJson = _path => {
210
210
  const filePath = getAbsoluteFilePath(_path);
211
211
  if (!fileExists(filePath)) return false;
212
212
 
213
213
  if (getExt(_path) !== 'json') {
214
214
  logger.error(`The file "${_path}" must be a valid JSON file`);
215
- return false;
215
+ return null;
216
216
  }
217
217
 
218
+ let result;
219
+
218
220
  try {
219
- JSON.parse(fs.readFileSync(filePath));
221
+ result = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
220
222
  } catch (e) {
221
223
  logger.error(`The file "${_path}" contains invalid JSON`);
222
- return false;
224
+ result = null;
223
225
  }
224
226
 
225
- return true;
227
+ return result;
226
228
  };
227
229
 
228
230
  module.exports = {
229
231
  validateMode,
230
232
  validateAccount,
231
- isFileValidJSON,
233
+ checkAndConvertToJson,
232
234
  fileExists,
233
235
  loadAndValidateOptions,
234
236
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "5.1.3-beta.1",
3
+ "version": "5.1.4-beta.0",
4
4
  "description": "CLI for working with HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@hubspot/cli-lib": "^9.0.0",
12
- "@hubspot/local-dev-lib": "^0.3.0",
13
- "@hubspot/serverless-dev-runtime": "5.1.3-beta.1",
12
+ "@hubspot/local-dev-lib": "^0.3.3",
13
+ "@hubspot/serverless-dev-runtime": "5.1.4-beta.0",
14
14
  "@hubspot/ui-extensions-dev-server": "0.8.9",
15
15
  "archiver": "^5.3.0",
16
16
  "chalk": "^4.1.2",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "4b53ba30127c3d8c12e5ccd6d4dc3833cc87e7b1"
48
+ "gitHead": "6c4b965fc42578b79a53bf3eb2e6aa2342802d93"
49
49
  }