@hubspot/cli 6.3.0-experimental.0 → 6.4.0-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.
Files changed (77) hide show
  1. package/bin/cli.js +2 -21
  2. package/commands/accounts/clean.js +5 -8
  3. package/commands/accounts/info.js +6 -6
  4. package/commands/accounts/list.js +10 -14
  5. package/commands/accounts/remove.js +1 -1
  6. package/commands/accounts/rename.js +4 -3
  7. package/commands/auth.js +7 -11
  8. package/commands/cms/lighthouseScore.js +19 -19
  9. package/commands/config/set.js +5 -4
  10. package/commands/create.js +2 -3
  11. package/commands/customObject/create.js +6 -4
  12. package/commands/customObject/schema/create.js +9 -8
  13. package/commands/customObject/schema/delete.js +5 -3
  14. package/commands/customObject/schema/fetch-all.js +4 -3
  15. package/commands/customObject/schema/fetch.js +6 -4
  16. package/commands/customObject/schema/list.js +4 -3
  17. package/commands/customObject/schema/update.js +9 -8
  18. package/commands/fetch.js +4 -4
  19. package/commands/filemanager/fetch.js +5 -4
  20. package/commands/filemanager/upload.js +10 -9
  21. package/commands/functions/deploy.js +10 -12
  22. package/commands/functions/list.js +5 -5
  23. package/commands/functions/server.js +5 -4
  24. package/commands/hubdb/clear.js +6 -5
  25. package/commands/hubdb/create.js +6 -5
  26. package/commands/hubdb/delete.js +6 -5
  27. package/commands/hubdb/fetch.js +5 -4
  28. package/commands/init.js +8 -26
  29. package/commands/lint.js +5 -5
  30. package/commands/list.js +5 -4
  31. package/commands/logs.js +5 -4
  32. package/commands/module/marketplace-validate.js +7 -6
  33. package/commands/mv.js +8 -7
  34. package/commands/open.js +8 -7
  35. package/commands/project/add.js +3 -2
  36. package/commands/project/cloneApp.js +14 -14
  37. package/commands/project/create.js +3 -3
  38. package/commands/project/deploy.js +12 -15
  39. package/commands/project/dev.js +13 -13
  40. package/commands/project/download.js +9 -11
  41. package/commands/project/listBuilds.js +8 -10
  42. package/commands/project/logs.js +5 -5
  43. package/commands/project/migrateApp.js +18 -18
  44. package/commands/project/open.js +7 -6
  45. package/commands/project/upload.js +10 -12
  46. package/commands/project/watch.js +10 -9
  47. package/commands/remove.js +8 -10
  48. package/commands/sandbox/create.js +9 -8
  49. package/commands/sandbox/delete.js +9 -11
  50. package/commands/secrets/addSecret.js +7 -6
  51. package/commands/secrets/deleteSecret.js +7 -6
  52. package/commands/secrets/listSecrets.js +6 -6
  53. package/commands/secrets/updateSecret.js +7 -6
  54. package/commands/theme/marketplace-validate.js +7 -6
  55. package/commands/theme/preview.js +42 -23
  56. package/commands/upload.js +15 -18
  57. package/commands/watch.js +10 -9
  58. package/lang/en.lyaml +1 -3
  59. package/lib/buildAccount.js +1 -3
  60. package/lib/commonOpts.d.ts +1 -9
  61. package/lib/commonOpts.js +12 -14
  62. package/lib/developerTestAccounts.js +5 -8
  63. package/lib/errorHandlers/index.d.ts +14 -1
  64. package/lib/errorHandlers/index.js +43 -50
  65. package/lib/errorHandlers/suppressError.d.ts +2 -1
  66. package/lib/errorHandlers/suppressError.js +32 -37
  67. package/lib/links.d.ts +9 -0
  68. package/lib/links.js +99 -97
  69. package/lib/oauth.js +1 -3
  70. package/lib/prompts/accountsPrompt.js +4 -8
  71. package/lib/prompts/projectDevTargetAccountPrompt.js +2 -3
  72. package/lib/prompts/sandboxesPrompt.js +7 -10
  73. package/lib/prompts/setAsDefaultAccountPrompt.js +2 -4
  74. package/lib/sandboxSync.js +2 -5
  75. package/lib/sandboxes.js +7 -12
  76. package/lib/ui/serverlessFunctionLogs.js +8 -4
  77. package/package.json +4 -1
@@ -1,26 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { isSpecifiedError, isMissingScopeError, } = require('@hubspot/local-dev-lib/errors/index');
5
- const { logger } = require('@hubspot/local-dev-lib/logger');
6
- const { PLATFORM_VERSION_ERROR_TYPES } = require('../constants');
7
- const { i18n } = require('../lang');
8
- const { uiAccountDescription, uiLine, uiLink, uiCommandReference, } = require('../ui');
3
+ exports.shouldSuppressError = shouldSuppressError;
4
+ const index_1 = require("@hubspot/local-dev-lib/errors/index");
5
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
6
+ const constants_1 = require("../constants");
7
+ const lang_1 = require("../lang");
8
+ const ui_1 = require("../ui");
9
9
  const i18nKey = 'lib.errorHandlers.suppressErrors';
10
10
  function createPlatformVersionError(err, subCategory) {
11
11
  let translationKey = 'unspecifiedPlatformVersion';
12
12
  let platformVersion = 'unspecified platformVersion';
13
- const errorContext = err.response && err.response.data && err.response.data.context;
13
+ const errorContext = err.data.context;
14
14
  switch (subCategory) {
15
- case [PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED]:
15
+ case constants_1.PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED:
16
16
  translationKey = 'platformVersionRetired';
17
17
  if (errorContext && errorContext[subCategory]) {
18
18
  platformVersion = errorContext[subCategory];
19
19
  }
20
20
  break;
21
- case [
22
- PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST,
23
- ]:
21
+ case constants_1.PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST:
24
22
  translationKey = 'nonExistentPlatformVersion';
25
23
  if (errorContext && errorContext[subCategory]) {
26
24
  platformVersion = errorContext[subCategory];
@@ -29,48 +27,45 @@ function createPlatformVersionError(err, subCategory) {
29
27
  default:
30
28
  break;
31
29
  }
32
- uiLine();
33
- logger.error(i18n(`${i18nKey}.platformVersionErrors.header`));
34
- logger.log(i18n(`${i18nKey}.platformVersionErrors.${translationKey}`, {
30
+ (0, ui_1.uiLine)();
31
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.platformVersionErrors.header`));
32
+ logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.platformVersionErrors.${translationKey}`, {
35
33
  platformVersion,
36
34
  }));
37
- logger.log(i18n(`${i18nKey}.platformVersionErrors.updateProject`));
38
- logger.log(i18n(`${i18nKey}.platformVersionErrors.betaLink`, {
39
- docsLink: uiLink(i18n(`${i18nKey}.platformVersionErrors.docsLink`), 'https://developers.hubspot.com/docs/platform/platform-versioning'),
35
+ logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.platformVersionErrors.updateProject`));
36
+ logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.platformVersionErrors.betaLink`, {
37
+ docsLink: (0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.platformVersionErrors.docsLink`), 'https://developers.hubspot.com/docs/platform/platform-versioning'),
40
38
  }));
41
- uiLine();
39
+ (0, ui_1.uiLine)();
42
40
  }
43
- function shouldSuppressError(err, context = {}) {
44
- if (isMissingScopeError(err)) {
45
- logger.error(i18n(`${i18nKey}.missingScopeError`, {
46
- accountName: context.accountId
47
- ? uiAccountDescription(context.accountId)
41
+ function shouldSuppressError(err, context) {
42
+ if ((0, index_1.isMissingScopeError)(err)) {
43
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.missingScopeError`, {
44
+ accountName: context?.accountId
45
+ ? (0, ui_1.uiAccountDescription)(context.accountId)
48
46
  : '',
49
- request: context.request || 'request',
50
- authCommand: uiCommandReference('hs auth'),
47
+ request: context?.request || 'request',
48
+ authCommand: (0, ui_1.uiCommandReference)('hs auth'),
51
49
  }));
52
50
  return true;
53
51
  }
54
- if (isSpecifiedError(err, {
55
- subCategory: PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED,
52
+ if ((0, index_1.isSpecifiedError)(err, {
53
+ subCategory: constants_1.PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED,
56
54
  })) {
57
- createPlatformVersionError(err.data, PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED);
55
+ createPlatformVersionError(err.data, constants_1.PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED);
58
56
  return true;
59
57
  }
60
- if (isSpecifiedError(err, {
61
- subCategory: PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED,
58
+ if ((0, index_1.isSpecifiedError)(err, {
59
+ subCategory: constants_1.PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED,
62
60
  })) {
63
- createPlatformVersionError(err.data, PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED);
61
+ createPlatformVersionError(err.data, constants_1.PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED);
64
62
  return true;
65
63
  }
66
- if (isSpecifiedError(err, {
67
- subCategory: PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST,
64
+ if ((0, index_1.isSpecifiedError)(err, {
65
+ subCategory: constants_1.PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST,
68
66
  })) {
69
- createPlatformVersionError(err.data, PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST);
67
+ createPlatformVersionError(err.data, constants_1.PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST);
70
68
  return true;
71
69
  }
72
70
  return false;
73
71
  }
74
- module.exports = {
75
- shouldSuppressError,
76
- };
package/lib/links.d.ts CHANGED
@@ -1 +1,10 @@
1
+ type SiteLink = {
2
+ shortcut: string;
3
+ alias?: string;
4
+ getUrl: (accountId: number, baseUrl: string) => string;
5
+ url?: string;
6
+ };
7
+ export declare function getSiteLinksAsArray(accountId: number): SiteLink[];
8
+ export declare function logSiteLinks(accountId: number): void;
9
+ export declare function openLink(accountId: number, shortcut: string): void;
1
10
  export {};
package/lib/links.js CHANGED
@@ -1,107 +1,109 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { getEnv } = require('@hubspot/local-dev-lib/config');
5
- const { ENVIRONMENTS, } = require('@hubspot/local-dev-lib/constants/environments');
6
- const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
7
- const { logger } = require('@hubspot/local-dev-lib/logger');
8
- const { getTableContents, getTableHeader } = require('./ui/table');
9
- const open = require('open');
10
- const logSiteLinks = accountId => {
6
+ exports.getSiteLinksAsArray = getSiteLinksAsArray;
7
+ exports.logSiteLinks = logSiteLinks;
8
+ exports.openLink = openLink;
9
+ const open_1 = __importDefault(require("open"));
10
+ const config_1 = require("@hubspot/local-dev-lib/config");
11
+ const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
12
+ const urls_1 = require("@hubspot/local-dev-lib/urls");
13
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
14
+ const table_1 = require("./ui/table");
15
+ const SITE_LINKS = {
16
+ APPS_MARKETPLACE: {
17
+ shortcut: 'apps-marketplace',
18
+ alias: 'apm',
19
+ getUrl: (accountId, baseUrl) => `${baseUrl}/ecosystem/${accountId}/marketplace/apps`,
20
+ },
21
+ ASSET_MARKETPLACE: {
22
+ shortcut: 'asset-marketplace',
23
+ alias: 'asm',
24
+ getUrl: (accountId, baseUrl) => `${baseUrl}/ecosystem/${accountId}/marketplace/products`,
25
+ },
26
+ CONTENT_STAGING: {
27
+ shortcut: 'content-staging',
28
+ alias: 'cs',
29
+ getUrl: (accountId, baseUrl) => `${baseUrl}/content/${accountId}/staging`,
30
+ },
31
+ DESIGN_MANAGER: {
32
+ shortcut: 'design-manager',
33
+ alias: 'dm',
34
+ getUrl: (accountId, baseUrl) => `${baseUrl}/design-manager/${accountId}`,
35
+ },
36
+ DOCS: {
37
+ shortcut: 'docs',
38
+ getUrl: () => 'https://developers.hubspot.com',
39
+ },
40
+ FILE_MANAGER: {
41
+ shortcut: 'file-manager',
42
+ alias: 'fm',
43
+ getUrl: (accountId, baseUrl) => `${baseUrl}/files/${accountId}`,
44
+ },
45
+ FORUMS: {
46
+ shortcut: 'forums',
47
+ getUrl: () => 'https://community.hubspot.com',
48
+ },
49
+ HUBDB: {
50
+ shortcut: 'hubdb',
51
+ alias: 'hdb',
52
+ getUrl: (accountId, baseUrl) => `${baseUrl}/hubdb/${accountId}`,
53
+ },
54
+ SETTINGS: {
55
+ shortcut: 'settings',
56
+ alias: 's',
57
+ getUrl: (accountId, baseUrl) => `${baseUrl}/settings/${accountId}`,
58
+ },
59
+ SETTINGS_NAVIGATION: {
60
+ shortcut: 'settings/navigation',
61
+ alias: 'sn',
62
+ getUrl: (accountId, baseUrl) => `${baseUrl}/menus/${accountId}/edit/`,
63
+ },
64
+ SETTINGS_WEBSITE: {
65
+ shortcut: 'settings/website',
66
+ alias: 'sw',
67
+ getUrl: (accountId, baseUrl) => `${baseUrl}/settings/${accountId}/website/pages/all-domains/page-templates`,
68
+ },
69
+ SETTINGS_getUrl_REDIRECTS: {
70
+ shortcut: 'settings/url-redirects',
71
+ alias: 'sur',
72
+ getUrl: (accountId, baseUrl) => `${baseUrl}/domains/${accountId}/url-redirects`,
73
+ },
74
+ PURCHASED_ASSETS: {
75
+ shortcut: 'purchased-assets',
76
+ alias: 'pa',
77
+ getUrl: (accountId, baseUrl) => `${baseUrl}/marketplace/${accountId}/manage-purchases`,
78
+ },
79
+ WEBSITE_PAGES: {
80
+ shortcut: 'website-pages',
81
+ alias: 'wp',
82
+ getUrl: (accountId, baseUrl) => `${baseUrl}/website/${accountId}/pages/site`,
83
+ },
84
+ };
85
+ function getSiteLinksAsArray(accountId) {
86
+ const baseUrl = (0, urls_1.getHubSpotWebsiteOrigin)((0, config_1.getEnv)() === 'qa' ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD);
87
+ return Object.values(SITE_LINKS)
88
+ .sort((a, b) => (a.shortcut < b.shortcut ? -1 : 1))
89
+ .map(l => ({ ...l, url: l.getUrl(accountId, baseUrl) }));
90
+ }
91
+ function logSiteLinks(accountId) {
11
92
  const linksAsArray = getSiteLinksAsArray(accountId).map(l => [
12
93
  `${l.shortcut}${l.alias ? ` [alias: ${l.alias}]` : ''}`,
13
94
  '=>',
14
95
  l.url,
15
96
  ]);
16
- linksAsArray.unshift(getTableHeader(['Shortcut', '', 'Url']));
17
- logger.log(getTableContents(linksAsArray));
18
- };
19
- const getSiteLinksAsArray = accountId => Object.values(getSiteLinks(accountId)).sort((a, b) => a.shortcut < b.shortcut ? -1 : 1);
20
- const getSiteLinks = accountId => {
21
- const baseUrl = getHubSpotWebsiteOrigin(getEnv() === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD);
22
- return {
23
- APPS_MARKETPLACE: {
24
- shortcut: 'apps-marketplace',
25
- alias: 'apm',
26
- url: `${baseUrl}/ecosystem/${accountId}/marketplace/apps`,
27
- },
28
- ASSET_MARKETPLACE: {
29
- shortcut: 'asset-marketplace',
30
- alias: 'asm',
31
- url: `${baseUrl}/ecosystem/${accountId}/marketplace/products`,
32
- },
33
- CONTENT_STAGING: {
34
- shortcut: 'content-staging',
35
- alias: 'cs',
36
- url: `${baseUrl}/content/${accountId}/staging`,
37
- },
38
- DESIGN_MANAGER: {
39
- shortcut: 'design-manager',
40
- alias: 'dm',
41
- url: `${baseUrl}/design-manager/${accountId}`,
42
- },
43
- DOCS: {
44
- shortcut: 'docs',
45
- url: 'https://developers.hubspot.com',
46
- },
47
- FILE_MANAGER: {
48
- shortcut: 'file-manager',
49
- alias: 'fm',
50
- url: `${baseUrl}/files/${accountId}`,
51
- },
52
- FORUMS: {
53
- shortcut: 'forums',
54
- url: 'https://community.hubspot.com',
55
- },
56
- HUBDB: {
57
- shortcut: 'hubdb',
58
- alias: 'hdb',
59
- url: `${baseUrl}/hubdb/${accountId}`,
60
- },
61
- SETTINGS: {
62
- shortcut: 'settings',
63
- alias: 's',
64
- url: `${baseUrl}/settings/${accountId}`,
65
- },
66
- SETTINGS_NAVIGATION: {
67
- shortcut: 'settings/navigation',
68
- alias: 'sn',
69
- url: `${baseUrl}/menus/${accountId}/edit/`,
70
- },
71
- SETTINGS_WEBSITE: {
72
- shortcut: 'settings/website',
73
- alias: 'sw',
74
- url: `${baseUrl}/settings/${accountId}/website/pages/all-domains/page-templates`,
75
- },
76
- SETTINGS_URL_REDIRECTS: {
77
- shortcut: 'settings/url-redirects',
78
- alias: 'sur',
79
- url: `${baseUrl}/domains/${accountId}/url-redirects`,
80
- },
81
- PURCHASED_ASSETS: {
82
- shortcut: 'purchased-assets',
83
- alias: 'pa',
84
- url: `${baseUrl}/marketplace/${accountId}/manage-purchases`,
85
- },
86
- WEBSITE_PAGES: {
87
- shortcut: 'website-pages',
88
- alias: 'wp',
89
- url: `${baseUrl}/website/${accountId}/pages/site`,
90
- },
91
- };
92
- };
93
- const openLink = (accountId, shortcut) => {
94
- const match = Object.values(getSiteLinks(accountId)).find(l => l.shortcut === shortcut || (l.alias && l.alias === shortcut));
97
+ linksAsArray.unshift((0, table_1.getTableHeader)(['Shortcut', '', 'Url']));
98
+ logger_1.logger.log((0, table_1.getTableContents)(linksAsArray));
99
+ }
100
+ function openLink(accountId, shortcut) {
101
+ const match = Object.values(SITE_LINKS).find(l => l.shortcut === shortcut || (l.alias && l.alias === shortcut));
95
102
  if (!match) {
96
- logger.error(`We couldn't find a shortcut matching ${shortcut}. Type 'hs open list' to see a list of available shortcuts`);
103
+ logger_1.logger.error(`We couldn't find a shortcut matching ${shortcut}. Type 'hs open list' to see a list of available shortcuts`);
97
104
  return;
98
105
  }
99
- open(match.url, { url: true });
100
- logger.success(`We opened ${match.url} in your browser`);
101
- };
102
- module.exports = {
103
- getSiteLinks,
104
- getSiteLinksAsArray,
105
- logSiteLinks,
106
- openLink,
107
- };
106
+ const baseUrl = (0, urls_1.getHubSpotWebsiteOrigin)((0, config_1.getEnv)() === 'qa' ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD);
107
+ (0, open_1.default)(match.getUrl(accountId, baseUrl), { url: true });
108
+ logger_1.logger.success(`We opened ${match.getUrl(accountId, baseUrl)} in your browser`);
109
+ }
package/lib/oauth.js CHANGED
@@ -5,7 +5,6 @@ const express = require('express');
5
5
  const open = require('open');
6
6
  const { OAuth2Manager, } = require('@hubspot/local-dev-lib/models/OAuth2Manager');
7
7
  const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
8
- const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
9
8
  const { addOauthToAccountConfig } = require('@hubspot/local-dev-lib/oauth');
10
9
  const { handleExit } = require('./process');
11
10
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
@@ -75,8 +74,7 @@ const authorize = async (oauthManager) => {
75
74
  });
76
75
  };
77
76
  const setupOauth = accountConfig => {
78
- const id = getAccountIdentifier(accountConfig);
79
- const accountId = parseInt(id, 10);
77
+ const accountId = parseInt(accountConfig.portalId, 10);
80
78
  const config = getAccountConfig(accountId) || {};
81
79
  return new OAuth2Manager({
82
80
  ...accountConfig,
@@ -1,19 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // @ts-nocheck
4
- const { getConfigDefaultAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
5
- const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
6
4
  const { promptUser } = require('./promptUtils');
7
5
  const { i18n } = require('../lang');
8
6
  const { uiAccountDescription } = require('../ui');
9
7
  const mapAccountChoices = portals => portals.map(p => ({
10
- name: uiAccountDescription(getAccountIdentifier(p), false),
11
- value: p.name || getAccountIdentifier(p),
8
+ name: uiAccountDescription(p.portalId, false),
9
+ value: p.name || p.portalId,
12
10
  }));
13
11
  const i18nKey = 'commands.accounts.subcommands.use';
14
12
  const selectAccountFromConfig = async (config, prompt) => {
15
- const accountsList = getConfigAccounts();
16
- const defaultAccount = getConfigDefaultAccount(config);
17
13
  const { default: selectedDefault } = await promptUser([
18
14
  {
19
15
  type: 'list',
@@ -21,8 +17,8 @@ const selectAccountFromConfig = async (config, prompt) => {
21
17
  name: 'default',
22
18
  pageSize: 20,
23
19
  message: prompt || i18n(`${i18nKey}.promptMessage`),
24
- choices: mapAccountChoices(accountsList),
25
- default: defaultAccount,
20
+ choices: mapAccountChoices(config.portals),
21
+ default: config.defaultPortal,
26
22
  },
27
23
  ]);
28
24
  return selectedDefault;
@@ -8,12 +8,11 @@ const { isSandbox } = require('../accountTypes');
8
8
  const { getAccountId } = require('@hubspot/local-dev-lib/config');
9
9
  const { getSandboxUsageLimits, } = require('@hubspot/local-dev-lib/api/sandboxHubs');
10
10
  const { HUBSPOT_ACCOUNT_TYPES, HUBSPOT_ACCOUNT_TYPE_STRINGS, } = require('@hubspot/local-dev-lib/constants/config');
11
- const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
12
11
  const { logger } = require('@hubspot/local-dev-lib/logger');
13
12
  const { fetchDeveloperTestAccounts, } = require('@hubspot/local-dev-lib/api/developerTestAccounts');
14
13
  const i18nKey = 'lib.prompts.projectDevTargetAccountPrompt';
15
14
  const mapNestedAccount = accountConfig => ({
16
- name: uiAccountDescription(getAccountIdentifier(accountConfig), false),
15
+ name: uiAccountDescription(accountConfig.portalId, false),
17
16
  value: {
18
17
  targetAccountId: getAccountId(accountConfig.name),
19
18
  createNestedAccount: false,
@@ -98,7 +97,7 @@ const selectDeveloperTestTargetAccountPrompt = async (accounts, defaultAccountCo
98
97
  }
99
98
  const devTestAccounts = [];
100
99
  if (devTestAccountsResponse && devTestAccountsResponse.results) {
101
- const accountIds = accounts.map(account => getAccountIdentifier(account));
100
+ const accountIds = accounts.map(account => account.portalId);
102
101
  devTestAccountsResponse.results.forEach(acct => {
103
102
  const inConfig = accountIds.includes(acct.id);
104
103
  devTestAccounts.push({
@@ -5,24 +5,22 @@ const { promptUser } = require('./promptUtils');
5
5
  const { i18n } = require('../lang');
6
6
  const { uiAccountDescription } = require('../ui');
7
7
  const { HUBSPOT_ACCOUNT_TYPES, } = require('@hubspot/local-dev-lib/constants/config');
8
- const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
9
8
  const { isSandbox } = require('../accountTypes');
10
- const { getConfigDefaultAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
11
9
  const i18nKey = 'lib.prompts.sandboxesPrompt';
12
10
  const mapSandboxAccountChoices = portals => portals
13
11
  .filter(p => isSandbox(p))
14
12
  .map(p => {
15
13
  return {
16
- name: uiAccountDescription(getAccountIdentifier(p), false),
17
- value: p.name || getAccountIdentifier(p),
14
+ name: uiAccountDescription(p.portalId, false),
15
+ value: p.name || p.portalId,
18
16
  };
19
17
  });
20
18
  const mapNonSandboxAccountChoices = portals => portals
21
19
  .filter(p => !isSandbox(p))
22
20
  .map(p => {
23
21
  return {
24
- name: `${p.name} (${getAccountIdentifier(p)})`,
25
- value: p.name || getAccountIdentifier(p),
22
+ name: `${p.name} (${p.portalId})`,
23
+ value: p.name || p.portalId,
26
24
  };
27
25
  });
28
26
  const sandboxTypePrompt = () => {
@@ -47,10 +45,9 @@ const sandboxTypePrompt = () => {
47
45
  ]);
48
46
  };
49
47
  const deleteSandboxPrompt = (config, promptParentAccount = false) => {
50
- const accountsList = getConfigAccounts();
51
48
  const choices = promptParentAccount
52
- ? mapNonSandboxAccountChoices(accountsList)
53
- : mapSandboxAccountChoices(accountsList);
49
+ ? mapNonSandboxAccountChoices(config.portals)
50
+ : mapSandboxAccountChoices(config.portals);
54
51
  if (!choices.length) {
55
52
  return undefined;
56
53
  }
@@ -64,7 +61,7 @@ const deleteSandboxPrompt = (config, promptParentAccount = false) => {
64
61
  look: false,
65
62
  pageSize: 20,
66
63
  choices,
67
- default: getConfigDefaultAccount(config),
64
+ default: config.defaultPortal,
68
65
  },
69
66
  ]);
70
67
  };
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // @ts-nocheck
4
- const { getConfig, updateDefaultAccount, getConfigDefaultAccount, } = require('@hubspot/local-dev-lib/config');
4
+ const { getConfig, updateDefaultAccount, } = require('@hubspot/local-dev-lib/config');
5
5
  const { promptUser } = require('./promptUtils');
6
6
  const { i18n } = require('../lang');
7
7
  const i18nKey = 'lib.prompts.setAsDefaultAccountPrompt';
8
8
  const setAsDefaultAccountPrompt = async (accountName) => {
9
9
  const config = getConfig();
10
- // Accounts for deprecated and new config
11
- const defaultAccount = getConfigDefaultAccount(config);
12
10
  const { setAsDefault } = await promptUser([
13
11
  {
14
12
  name: 'setAsDefault',
15
13
  type: 'confirm',
16
- when: defaultAccount !== accountName,
14
+ when: config.defaultPortal !== accountName,
17
15
  message: i18n(`${i18nKey}.setAsDefaultAccountMessage`),
18
16
  },
19
17
  ]);
@@ -11,7 +11,6 @@ const { debugError, logError, ApiErrorContext, } = require('./errorHandlers/inde
11
11
  const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
12
12
  const { getSandboxTypeAsString } = require('./sandboxes');
13
13
  const { getAccountId } = require('@hubspot/local-dev-lib/config');
14
- const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
15
14
  const { uiAccountDescription, uiLine, uiLink, uiCommandDisabledBanner, } = require('./ui');
16
15
  const { isDevelopmentSandbox } = require('./accountTypes');
17
16
  const i18nKey = 'lib.sandbox.sync';
@@ -23,10 +22,8 @@ const i18nKey = 'lib.sandbox.sync';
23
22
  * @returns
24
23
  */
25
24
  const syncSandbox = async ({ accountConfig, parentAccountConfig, env, syncTasks, slimInfoMessage = false, }) => {
26
- const id = getAccountIdentifier(accountConfig);
27
- const accountId = getAccountId(id);
28
- const parentId = getAccountIdentifier(parentAccountConfig);
29
- const parentAccountId = getAccountId(parentId);
25
+ const accountId = getAccountId(accountConfig.portalId);
26
+ const parentAccountId = getAccountId(parentAccountConfig.portalId);
30
27
  const isDevSandbox = isDevelopmentSandbox(accountConfig);
31
28
  SpinniesManager.init({
32
29
  succeedColor: 'white',
package/lib/sandboxes.js CHANGED
@@ -5,12 +5,11 @@ const { i18n } = require('./lang');
5
5
  const { logger } = require('@hubspot/local-dev-lib/logger');
6
6
  const { getSandboxUsageLimits, } = require('@hubspot/local-dev-lib/api/sandboxHubs');
7
7
  const { fetchTypes } = require('@hubspot/local-dev-lib/api/sandboxSync');
8
- const { getAccountId, getEnv, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
8
+ const { getConfig, getAccountId, getEnv, } = require('@hubspot/local-dev-lib/config');
9
9
  const { promptUser } = require('./prompts/promptUtils');
10
10
  const { isDevelopmentSandbox } = require('./accountTypes');
11
11
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
12
12
  const { HUBSPOT_ACCOUNT_TYPES, } = require('@hubspot/local-dev-lib/constants/config');
13
- const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
14
13
  const { uiAccountDescription } = require('./ui');
15
14
  const { isMissingScopeError, isSpecifiedError, } = require('@hubspot/local-dev-lib/errors/index');
16
15
  const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
@@ -35,10 +34,9 @@ const getSandboxTypeAsString = accountType => {
35
34
  return 'standard';
36
35
  };
37
36
  function getHasSandboxesByType(parentAccountConfig, type) {
38
- const id = getAccountIdentifier(parentAccountConfig);
39
- const parentPortalId = getAccountId(id);
40
- const accountsList = getConfigAccounts();
41
- for (const portal of accountsList) {
37
+ const config = getConfig();
38
+ const parentPortalId = getAccountId(parentAccountConfig.portalId);
39
+ for (const portal of config.portals) {
42
40
  if ((portal.parentAccountId !== null ||
43
41
  portal.parentAccountId !== undefined) &&
44
42
  portal.parentAccountId === parentPortalId &&
@@ -56,10 +54,8 @@ function getSandboxLimit(error) {
56
54
  }
57
55
  // Fetches available sync types for a given sandbox portal
58
56
  async function getAvailableSyncTypes(parentAccountConfig, config) {
59
- const parentId = getAccountIdentifier(parentAccountConfig);
60
- const parentPortalId = getAccountId(parentId);
61
- const id = getAccountIdentifier(config);
62
- const portalId = getAccountId(id);
57
+ const parentPortalId = getAccountId(parentAccountConfig.portalId);
58
+ const portalId = getAccountId(config.portalId);
63
59
  const { data: { results: syncTypes }, } = await fetchTypes(parentPortalId, portalId);
64
60
  if (!syncTypes) {
65
61
  throw new Error('Unable to fetch available sandbox sync types. Please try again.');
@@ -102,8 +98,7 @@ const getSyncTypesWithContactRecordsPrompt = async (accountConfig, syncTasks, sk
102
98
  * @returns {null}
103
99
  */
104
100
  const validateSandboxUsageLimits = async (accountConfig, sandboxType, env) => {
105
- const id = getAccountIdentifier(accountConfig);
106
- const accountId = getAccountId(id);
101
+ const accountId = getAccountId(accountConfig.portalId);
107
102
  const { data: { usage }, } = await getSandboxUsageLimits(accountId);
108
103
  if (!usage) {
109
104
  throw new Error('Unable to fetch sandbox usage limits. Please try again.');
@@ -68,13 +68,17 @@ function processLog(log, options) {
68
68
  }
69
69
  }
70
70
  function isLogsResponse(logsResp) {
71
- return ('results' in logsResp &&
71
+ return (logsResp &&
72
+ 'results' in logsResp &&
72
73
  Array.isArray(logsResp.results) &&
73
- logsResp.results !== undefined &&
74
- logsResp.results.length > 0);
74
+ logsResp.results !== undefined);
75
75
  }
76
76
  function processLogs(logsResp, options) {
77
- if (isLogsResponse(logsResp)) {
77
+ const isLogsResp = isLogsResponse(logsResp);
78
+ if (!logsResp || (isLogsResp && logsResp.results.length === 0)) {
79
+ return (0, lang_1.i18n)(`${i18nKey}.noLogsFound`);
80
+ }
81
+ else if (isLogsResp) {
78
82
  return logsResp
79
83
  .results.map(log => {
80
84
  return processLog(log, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "6.3.0-experimental.0",
3
+ "version": "6.4.0-beta.0",
4
4
  "description": "The official CLI for developing on HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "https://github.com/HubSpot/hubspot-cli",
@@ -50,6 +50,9 @@
50
50
  "ts-node": "^10.9.2",
51
51
  "typescript": "^5.6.2"
52
52
  },
53
+ "optionalDependencies": {
54
+ "@hubspot/cms-dev-server": "^0.18.9"
55
+ },
53
56
  "scripts": {
54
57
  "build": "ts-node ./scripts/build.ts",
55
58
  "lint": "eslint . && prettier --list-different ./**/*.{js,json}",