@hubspot/cli 5.1.4-beta.2 → 5.1.4-beta.3

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.
@@ -13,13 +13,11 @@ const {
13
13
  const { trackCommandUsage } = require('../../lib/usageTracking');
14
14
  const { loadAndValidateOptions } = require('../../lib/validation');
15
15
  const { isSandbox, getSandboxName } = require('../../lib/sandboxes');
16
- const {
17
- isDeveloperTestAccount,
18
- DEV_TEST_ACCOUNT_STRING,
19
- } = require('../../lib/developerTestAccounts');
16
+ const { isDeveloperTestAccount } = require('../../lib/developerTestAccounts');
20
17
  const { i18n } = require('../../lib/lang');
21
18
  const {
22
19
  HUBSPOT_ACCOUNT_TYPES,
20
+ HUBSPOT_ACCOUNT_TYPE_STRINGS,
23
21
  } = require('@hubspot/local-dev-lib/constants/config');
24
22
 
25
23
  const i18nKey = 'cli.commands.accounts.subcommands.list';
@@ -31,22 +29,18 @@ const sortAndMapPortals = portals => {
31
29
  const mappedPortalData = {};
32
30
  // Standard and app developer portals
33
31
  portals
34
- .filter(p =>
35
- p.accountType
36
- ? p.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD ||
37
- p.accountType === HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER
38
- : p.sandboxAccountType === null
32
+ .filter(
33
+ p =>
34
+ p.accountType &&
35
+ (p.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD ||
36
+ p.accountType === HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER)
39
37
  )
40
38
  .forEach(portal => {
41
39
  mappedPortalData[portal.portalId] = [portal];
42
40
  });
43
41
  // Non-standard portals (sandbox, developer test account)
44
42
  portals
45
- .filter(p =>
46
- p.accountType
47
- ? isSandbox(p) || isDeveloperTestAccount(p)
48
- : p.sandboxAccountType !== null
49
- )
43
+ .filter(p => p.accountType && (isSandbox(p) || isDeveloperTestAccount(p)))
50
44
  .forEach(p => {
51
45
  if (p.parentAccountId) {
52
46
  mappedPortalData[p.parentAccountId] = [
@@ -71,7 +65,9 @@ const getPortalData = mappedPortalData => {
71
65
  name = `↳ ${name}`;
72
66
  }
73
67
  } else if (isDeveloperTestAccount(portal)) {
74
- name = `${portal.name} [${DEV_TEST_ACCOUNT_STRING}]`;
68
+ name = `${portal.name} [${
69
+ HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST]
70
+ }]`;
75
71
  if (set.length > 1) {
76
72
  name = `↳ ${name}`;
77
73
  }
@@ -36,9 +36,9 @@ exports.handler = async options => {
36
36
  const accountId = getAccountId(options);
37
37
  const accountConfig = getAccountConfig(accountId);
38
38
  const { project: projectOption, buildId: buildIdOption } = options;
39
- const sandboxType = accountConfig && accountConfig.sandboxAccountType;
39
+ const accountType = accountConfig && accountConfig.accountType;
40
40
 
41
- trackCommandUsage('project-deploy', { type: sandboxType }, accountId);
41
+ trackCommandUsage('project-deploy', { type: accountType }, accountId);
42
42
 
43
43
  const { projectConfig } = await getProjectConfig();
44
44
 
@@ -69,11 +69,11 @@ const {
69
69
  isMissingScopeError,
70
70
  } = require('@hubspot/local-dev-lib/errors/apiErrors');
71
71
  const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
72
+ const { isDeveloperTestAccount } = require('../../lib/developerTestAccounts');
72
73
  const {
73
- isDeveloperTestAccount,
74
- DEV_TEST_ACCOUNT_STRING,
75
- } = require('../../lib/developerTestAccounts');
76
- const { DEVELOPER_SANDBOX_TYPE } = require('../../lib/constants');
74
+ HUBSPOT_ACCOUNT_TYPES,
75
+ HUBSPOT_ACCOUNT_TYPE_STRINGS,
76
+ } = require('@hubspot/local-dev-lib/constants/config');
77
77
 
78
78
  const i18nKey = 'cli.commands.project.subcommands.dev';
79
79
 
@@ -116,7 +116,7 @@ exports.handler = async options => {
116
116
  accountConfig.name,
117
117
  defaultAccountIsSandbox
118
118
  ? `${getSandboxTypeAsString(accountConfig.accountType)} sandbox`
119
- : DEV_TEST_ACCOUNT_STRING
119
+ : HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST]
120
120
  );
121
121
 
122
122
  if (useDefaultAccount) {
@@ -152,7 +152,7 @@ exports.handler = async options => {
152
152
  try {
153
153
  await validateSandboxUsageLimits(
154
154
  accountConfig,
155
- DEVELOPER_SANDBOX_TYPE,
155
+ HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
156
156
  env
157
157
  );
158
158
  } catch (err) {
@@ -176,7 +176,9 @@ exports.handler = async options => {
176
176
  process.exit(EXIT_CODES.ERROR);
177
177
  }
178
178
  try {
179
- const { name } = await sandboxNamePrompt(DEVELOPER_SANDBOX_TYPE);
179
+ const { name } = await sandboxNamePrompt(
180
+ HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX
181
+ );
180
182
 
181
183
  trackCommandMetadataUsage(
182
184
  'sandbox-create',
@@ -186,7 +188,7 @@ exports.handler = async options => {
186
188
 
187
189
  const { result } = await buildSandbox({
188
190
  name,
189
- type: DEVELOPER_SANDBOX_TYPE,
191
+ type: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
190
192
  accountConfig,
191
193
  env,
192
194
  });
@@ -39,9 +39,9 @@ exports.handler = async options => {
39
39
  const { forceCreate, path: projectPath, message } = options;
40
40
  const accountId = getAccountId(options);
41
41
  const accountConfig = getAccountConfig(accountId);
42
- const sandboxType = accountConfig && accountConfig.sandboxAccountType;
42
+ const accountType = accountConfig && accountConfig.accountType;
43
43
 
44
- trackCommandUsage('project-upload', { type: sandboxType }, accountId);
44
+ trackCommandUsage('project-upload', { type: accountType }, accountId);
45
45
 
46
46
  const { projectConfig, projectDir } = await getProjectConfig(projectPath);
47
47
 
@@ -13,7 +13,6 @@ const { buildSandbox } = require('../../lib/sandboxCreate');
13
13
  const { uiFeatureHighlight, uiAccountDescription } = require('../../lib/ui');
14
14
  const {
15
15
  sandboxTypeMap,
16
- getSandboxTypeAsString,
17
16
  getAvailableSyncTypes,
18
17
  syncTypes,
19
18
  validateSandboxUsageLimits,
@@ -35,7 +34,10 @@ const {
35
34
  isMissingScopeError,
36
35
  } = require('@hubspot/local-dev-lib/errors/apiErrors');
37
36
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
38
- const { DEVELOPER_SANDBOX_TYPE } = require('../../lib/constants');
37
+ const {
38
+ HUBSPOT_ACCOUNT_TYPES,
39
+ HUBSPOT_ACCOUNT_TYPE_STRINGS,
40
+ } = require('@hubspot/local-dev-lib/constants/config');
39
41
 
40
42
  const i18nKey = 'cli.commands.sandbox.subcommands.create';
41
43
 
@@ -54,13 +56,16 @@ exports.handler = async options => {
54
56
 
55
57
  // Default account is not a production portal
56
58
  if (
57
- accountConfig.sandboxAccountType &&
58
- accountConfig.sandboxAccountType !== null
59
+ accountConfig.accountType &&
60
+ accountConfig.accountType !== HUBSPOT_ACCOUNT_TYPES.STANDARD
59
61
  ) {
60
62
  logger.error(
61
- i18n(`${i18nKey}.failure.creatingWithinSandbox`, {
62
- sandboxType: getSandboxTypeAsString(accountConfig.sandboxAccountType),
63
- sandboxName: accountConfig.name,
63
+ i18n(`${i18nKey}.failure.invalidAccountType`, {
64
+ accountType:
65
+ HUBSPOT_ACCOUNT_TYPE_STRINGS[
66
+ HUBSPOT_ACCOUNT_TYPES[accountConfig.accountType]
67
+ ],
68
+ accountName: accountConfig.name,
64
69
  })
65
70
  );
66
71
  process.exit(EXIT_CODES.ERROR);
@@ -69,7 +74,7 @@ exports.handler = async options => {
69
74
  let typePrompt;
70
75
  let namePrompt;
71
76
 
72
- if ((type && !sandboxTypeMap[type]) || !type) {
77
+ if ((type && !sandboxTypeMap[type.toLowerCase()]) || !type) {
73
78
  if (!force) {
74
79
  typePrompt = await sandboxTypePrompt();
75
80
  } else {
@@ -77,7 +82,9 @@ exports.handler = async options => {
77
82
  process.exit(EXIT_CODES.ERROR);
78
83
  }
79
84
  }
80
- const sandboxType = sandboxTypeMap[type] || sandboxTypeMap[typePrompt.type];
85
+ const sandboxType = type
86
+ ? sandboxTypeMap[type.toLowerCase()]
87
+ : typePrompt.type;
81
88
 
82
89
  // Check usage limits and exit if parent portal has no available sandboxes for the selected type
83
90
  try {
@@ -117,11 +124,15 @@ exports.handler = async options => {
117
124
  let contactRecordsSyncPromptResult = true;
118
125
  if (!force) {
119
126
  const syncI18nKey = 'cli.lib.sandbox.sync';
127
+ const sandboxLangKey =
128
+ sandboxType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX
129
+ ? 'developer'
130
+ : 'standard';
120
131
  const { sandboxSyncPrompt } = await promptUser([
121
132
  {
122
133
  name: 'sandboxSyncPrompt',
123
134
  type: 'confirm',
124
- message: i18n(`${syncI18nKey}.confirm.createFlow.${sandboxType}`, {
135
+ message: i18n(`${syncI18nKey}.confirm.createFlow.${sandboxLangKey}`, {
125
136
  parentAccountName: uiAccountDescription(accountId),
126
137
  sandboxName,
127
138
  }),
@@ -135,7 +146,7 @@ exports.handler = async options => {
135
146
  name: 'contactRecordsSyncPrompt',
136
147
  type: 'confirm',
137
148
  message: i18n(
138
- `${syncI18nKey}.confirm.syncContactRecords.${sandboxType}`
149
+ `${syncI18nKey}.confirm.syncContactRecords.${sandboxLangKey}`
139
150
  ),
140
151
  },
141
152
  ]);
@@ -191,7 +202,7 @@ exports.handler = async options => {
191
202
  }
192
203
 
193
204
  const highlightItems = ['accountsUseCommand', 'projectCreateCommand'];
194
- if (sandboxType === DEVELOPER_SANDBOX_TYPE) {
205
+ if (sandboxType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX) {
195
206
  highlightItems.push('projectDevCommand');
196
207
  } else {
197
208
  highlightItems.push('projectUploadCommand');
@@ -15,18 +15,20 @@ const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
15
15
  const { promptUser } = require('../../lib/prompts/promptUtils');
16
16
  const { uiLine, uiAccountDescription } = require('../../lib/ui');
17
17
  const {
18
- sandboxTypeMap,
19
18
  getAvailableSyncTypes,
20
19
  getSyncTypesWithContactRecordsPrompt,
20
+ isDevelopmentSandbox,
21
+ isStandardSandbox,
22
+ isSandbox,
21
23
  } = require('../../lib/sandboxes');
22
24
  const { syncSandbox } = require('../../lib/sandboxSync');
23
25
  const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
24
26
  const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
25
27
  const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
26
28
  const {
27
- DEVELOPER_SANDBOX_TYPE,
28
- STANDARD_SANDBOX_TYPE,
29
- } = require('../../lib/constants');
29
+ HUBSPOT_ACCOUNT_TYPE_STRINGS,
30
+ HUBSPOT_ACCOUNT_TYPES,
31
+ } = require('@hubspot/local-dev-lib/constants/config');
30
32
 
31
33
  const i18nKey = 'cli.commands.sandbox.subcommands.sync';
32
34
 
@@ -43,17 +45,22 @@ exports.handler = async options => {
43
45
 
44
46
  trackCommandUsage(
45
47
  'sandbox-sync',
46
- { type: accountConfig.sandboxAccountType },
48
+ { type: accountConfig.accountType },
47
49
  accountId
48
50
  );
49
51
 
50
52
  if (
51
53
  // Check if default account is a sandbox, otherwise exit
52
- // sandboxAccountType is null for non-sandbox portals, and one of 'DEVELOPER' or 'STANDARD' for sandbox portals. Undefined is to handle older config entries.
53
- accountConfig.sandboxAccountType === undefined ||
54
- accountConfig.sandboxAccountType === null
54
+ !isSandbox(accountConfig)
55
55
  ) {
56
- logger.error(i18n(`${i18nKey}.failure.notSandbox`));
56
+ logger.error(
57
+ i18n(`${i18nKey}.failure.invalidAccountType`, {
58
+ accountType:
59
+ HUBSPOT_ACCOUNT_TYPE_STRINGS[
60
+ HUBSPOT_ACCOUNT_TYPES[accountConfig.accountType]
61
+ ],
62
+ })
63
+ );
57
64
  process.exit(EXIT_CODES.ERROR);
58
65
  }
59
66
 
@@ -70,10 +77,6 @@ exports.handler = async options => {
70
77
  }
71
78
 
72
79
  const parentAccountConfig = getAccountConfig(parentAccountId);
73
- const isDevelopmentSandbox =
74
- sandboxTypeMap[accountConfig.sandboxAccountType] === DEVELOPER_SANDBOX_TYPE;
75
- const isStandardSandbox =
76
- sandboxTypeMap[accountConfig.sandboxAccountType] === STANDARD_SANDBOX_TYPE;
77
80
 
78
81
  let availableSyncTasks;
79
82
  try {
@@ -100,7 +103,7 @@ exports.handler = async options => {
100
103
  process.exit(EXIT_CODES.ERROR);
101
104
  }
102
105
 
103
- if (isDevelopmentSandbox) {
106
+ if (isDevelopmentSandbox(accountConfig)) {
104
107
  logger.log(i18n(`${i18nKey}.info.developmentSandbox`));
105
108
  logger.log(
106
109
  i18n(`${i18nKey}.info.sync`, {
@@ -129,7 +132,7 @@ exports.handler = async options => {
129
132
  process.exit(EXIT_CODES.SUCCESS);
130
133
  }
131
134
  }
132
- } else if (isStandardSandbox) {
135
+ } else if (isStandardSandbox(accountConfig)) {
133
136
  const standardSyncUrl = `${getHubSpotWebsiteOrigin(
134
137
  env
135
138
  )}/sandboxes-developer/${parentAccountId}/sync?step=select_sync_path&id=${parentAccountId}_${accountId}`;
package/lang/en.lyaml CHANGED
@@ -689,7 +689,7 @@ en:
689
689
  optionMissing:
690
690
  type: "Invalid or missing sandbox --type option in command. Please try again."
691
691
  name: "Invalid or missing sandbox --name option in command. Please try again."
692
- creatingWithinSandbox: "Sandboxes must be created from a production account. Your current default account {{#bold}}{{ sandboxName }}{{/bold}} is a {{ sandboxType }} sandbox.
692
+ invalidAccountType: "Sandboxes must be created from a production account. Your current default account {{#bold}}{{ accountName }}{{/bold}} is a {{ accountType }}.
693
693
  \n- Run {{#bold}}hs accounts use{{/bold}} to switch to your default account to your production account.
694
694
  \n- Run {{#bold}}hs auth{{/bold}} to connect a production account to the HubSpot CLI.\n"
695
695
  delete:
@@ -737,7 +737,7 @@ en:
737
737
  developmentSandbox: "Sync CRM object definitions to {{#cyan}}{{#bold}}{{ sandboxName }}{{/bold}}{{/cyan}} from {{#bold}}{{ parentAccountName }}{{/bold}}?"
738
738
  standardSandbox: "Sync all supported assets to {{#cyan}}{{#bold}}{{ sandboxName }}{{/bold}}{{/cyan}} from {{#bold}}{{ parentAccountName }}{{/bold}}?"
739
739
  failure:
740
- notSandbox: "Sync must be run in a sandbox account. Your default account is a production account. Run {{#bold}}hs auth{{/bold}} to connect your sandbox account to the CLI or {{#bold}}hs accounts use{{/bold}} to change your default account, then try again."
740
+ invalidAccountType: "Sync must be run in a sandbox account. Your default account is a {{ accountType }}. Run {{#bold}}hs auth{{/bold}} to connect your sandbox account to the CLI or {{#bold}}hs accounts use{{/bold}} to change your default account, then try again."
741
741
  missingParentPortal: "The production account associated to {{#bold}}{{ sandboxName }}{{/bold}} is not connected to your HubSpot CLI.
742
742
  \n- Run {{#bold}}hs auth{{/bold}} to connect that account to your terminal, then try again.
743
743
  \n- Run {{#bold}}hs accounts use{{/bold}} to change your default account, if you want to sync to a different sandbox. Then try again.\n"
package/lib/constants.js CHANGED
@@ -2,18 +2,7 @@ const HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH =
2
2
  'HubSpot/hubspot-project-components';
3
3
  const DEFAULT_PROJECT_TEMPLATE_BRANCH = 'main';
4
4
 
5
- // Sandboxes
6
- const STANDARD_SANDBOX_TYPE = 'standard';
7
- const DEVELOPER_SANDBOX_TYPE = 'developer';
8
-
9
- const STANDARD_SANDBOX = 'STANDARD';
10
- const DEVELOPER_SANDBOX = 'DEVELOPER';
11
-
12
5
  module.exports = {
13
6
  HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH,
14
7
  DEFAULT_PROJECT_TEMPLATE_BRANCH,
15
- STANDARD_SANDBOX_TYPE,
16
- DEVELOPER_SANDBOX_TYPE,
17
- STANDARD_SANDBOX,
18
- DEVELOPER_SANDBOX,
19
8
  };
@@ -2,13 +2,10 @@ const {
2
2
  HUBSPOT_ACCOUNT_TYPES,
3
3
  } = require('@hubspot/local-dev-lib/constants/config');
4
4
 
5
- const DEV_TEST_ACCOUNT_STRING = 'developer test account';
6
-
7
5
  const isDeveloperTestAccount = config =>
8
6
  config.accountType &&
9
7
  config.accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST;
10
8
 
11
9
  module.exports = {
12
- DEV_TEST_ACCOUNT_STRING,
13
10
  isDeveloperTestAccount,
14
11
  };
@@ -4,8 +4,10 @@ const { uiAccountDescription, uiCommandReference } = require('../ui');
4
4
  const { isSandbox } = require('../sandboxes');
5
5
  const { getAccountId } = require('@hubspot/local-dev-lib/config');
6
6
  const { getSandboxUsageLimits } = require('@hubspot/local-dev-lib/sandboxes');
7
+ const {
8
+ HUBSPOT_ACCOUNT_TYPES,
9
+ } = require('@hubspot/local-dev-lib/constants/config');
7
10
  const { logger } = require('@hubspot/local-dev-lib/logger');
8
- const { DEVELOPER_SANDBOX, STANDARD_SANDBOX } = require('../constants');
9
11
 
10
12
  const i18nKey = 'cli.lib.prompts.projectDevTargetAccountPrompt';
11
13
 
@@ -34,18 +36,15 @@ const selectTargetAccountPrompt = async (accounts, defaultAccountConfig) => {
34
36
  );
35
37
  let disabledMessage = false;
36
38
 
37
- if (
38
- sandboxUsage[DEVELOPER_SANDBOX] &&
39
- sandboxUsage[DEVELOPER_SANDBOX].available === 0
40
- ) {
41
- if (sandboxAccounts.length < sandboxUsage[DEVELOPER_SANDBOX].limit) {
39
+ if (sandboxUsage['DEVELOPER'] && sandboxUsage['DEVELOPER'].available === 0) {
40
+ if (sandboxAccounts.length < sandboxUsage['DEVELOPER'].limit) {
42
41
  disabledMessage = i18n(`${i18nKey}.sandboxLimitWithSuggestion`, {
43
42
  authCommand: uiCommandReference('hs auth'),
44
- limit: sandboxUsage[DEVELOPER_SANDBOX].limit,
43
+ limit: sandboxUsage['DEVELOPER'].limit,
45
44
  });
46
45
  } else {
47
46
  disabledMessage = i18n(`${i18nKey}.sandboxLimit`, {
48
- limit: sandboxUsage[DEVELOPER_SANDBOX].limit,
47
+ limit: sandboxUsage['DEVELOPER'].limit,
49
48
  });
50
49
  }
51
50
  }
@@ -53,10 +52,10 @@ const selectTargetAccountPrompt = async (accounts, defaultAccountConfig) => {
53
52
  // Order choices by Developer Sandbox -> Standard Sandbox
54
53
  const choices = [
55
54
  ...sandboxAccounts
56
- .filter(a => a.sandboxAccountType === DEVELOPER_SANDBOX)
55
+ .filter(a => a.accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)
57
56
  .map(mapSandboxAccount),
58
57
  ...sandboxAccounts
59
- .filter(a => a.sandboxAccountType === STANDARD_SANDBOX)
58
+ .filter(a => a.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX)
60
59
  .map(mapSandboxAccount),
61
60
  {
62
61
  name: i18n(`${i18nKey}.createNewSandboxOption`),
@@ -3,17 +3,15 @@ const { i18n } = require('../lang');
3
3
  const { accountNameExistsInConfig } = require('@hubspot/local-dev-lib/config');
4
4
  const { uiAccountDescription } = require('../ui');
5
5
  const {
6
- DEVELOPER_SANDBOX,
7
- STANDARD_SANDBOX,
8
- STANDARD_SANDBOX_TYPE,
9
- DEVELOPER_SANDBOX_TYPE,
10
- } = require('../constants');
6
+ HUBSPOT_ACCOUNT_TYPES,
7
+ } = require('@hubspot/local-dev-lib/constants/config');
8
+ const { isSandbox } = require('../sandboxes');
11
9
 
12
10
  const i18nKey = 'cli.lib.prompts.sandboxesPrompt';
13
11
 
14
12
  const mapSandboxAccountChoices = portals =>
15
13
  portals
16
- .filter(p => p.sandboxAccountType && p.sandboxAccountType !== null)
14
+ .filter(p => isSandbox(p))
17
15
  .map(p => {
18
16
  return {
19
17
  name: uiAccountDescription(p.portalId, false),
@@ -23,9 +21,7 @@ const mapSandboxAccountChoices = portals =>
23
21
 
24
22
  const mapNonSandboxAccountChoices = portals =>
25
23
  portals
26
- .filter(
27
- p => p.sandboxAccountType === null || p.sandboxAccountType === undefined
28
- )
24
+ .filter(p => !isSandbox(p))
29
25
  .map(p => {
30
26
  return {
31
27
  name: `${p.name} (${p.portalId})`,
@@ -33,9 +29,10 @@ const mapNonSandboxAccountChoices = portals =>
33
29
  };
34
30
  });
35
31
 
36
- const sandboxNamePrompt = (type = STANDARD_SANDBOX_TYPE) => {
37
- const isDeveloperSandbox = type === DEVELOPER_SANDBOX_TYPE;
38
- const namePromptMessage = isDeveloperSandbox
32
+ const sandboxNamePrompt = (type = HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX) => {
33
+ const isDevelopmentSandbox =
34
+ type === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX;
35
+ const namePromptMessage = isDevelopmentSandbox
39
36
  ? `${i18nKey}.name.developmentSandboxMessage`
40
37
  : `${i18nKey}.name.message`;
41
38
  return promptUser([
@@ -52,7 +49,7 @@ const sandboxNamePrompt = (type = STANDARD_SANDBOX_TYPE) => {
52
49
  ? i18n(`${i18nKey}.name.errors.accountNameExists`, { name: val })
53
50
  : true;
54
51
  },
55
- default: `New ${isDeveloperSandbox ? 'development ' : ''}sandbox`,
52
+ default: `New ${isDevelopmentSandbox ? 'development ' : ''}sandbox`,
56
53
  },
57
54
  ]);
58
55
  };
@@ -60,11 +57,11 @@ const sandboxNamePrompt = (type = STANDARD_SANDBOX_TYPE) => {
60
57
  const sandboxTypeChoices = [
61
58
  {
62
59
  name: i18n(`${i18nKey}.type.developer`),
63
- value: DEVELOPER_SANDBOX,
60
+ value: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
64
61
  },
65
62
  {
66
63
  name: i18n(`${i18nKey}.type.standard`),
67
- value: STANDARD_SANDBOX,
64
+ value: HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
68
65
  },
69
66
  ];
70
67
 
@@ -76,7 +73,7 @@ const sandboxTypePrompt = () => {
76
73
  type: 'list',
77
74
  look: false,
78
75
  choices: sandboxTypeChoices,
79
- default: DEVELOPER_SANDBOX,
76
+ default: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
80
77
  },
81
78
  ]);
82
79
  };
@@ -23,10 +23,6 @@ const {
23
23
  updateConfigWithAccessToken,
24
24
  } = require('@hubspot/local-dev-lib/personalAccessKey');
25
25
  const { uiAccountDescription } = require('./ui');
26
- const {
27
- DEVELOPER_SANDBOX_TYPE,
28
- STANDARD_SANDBOX_TYPE,
29
- } = require('./constants');
30
26
  const {
31
27
  personalAccessKeyPrompt,
32
28
  } = require('./prompts/personalAccessKeyPrompt');
@@ -36,6 +32,9 @@ const {
36
32
  writeConfig,
37
33
  updateAccountConfig,
38
34
  } = require('@hubspot/local-dev-lib/config');
35
+ const {
36
+ HUBSPOT_ACCOUNT_TYPES,
37
+ } = require('@hubspot/local-dev-lib/constants/config');
39
38
 
40
39
  const i18nKey = 'cli.lib.sandbox.create';
41
40
 
@@ -113,7 +112,7 @@ const saveSandboxToConfig = async (env, result, force = false) => {
113
112
 
114
113
  /**
115
114
  * @param {String} name - Name of sandbox
116
- * @param {String} type - Sandbox type to be created (standard/developer)
115
+ * @param {String} type - Sandbox type to be created (STANDARD_SANDBOX/DEVELOPMENT_SANDBOX)
117
116
  * @param {Object} accountConfig - Account config of parent portal
118
117
  * @param {String} env - Environment (QA/Prod)
119
118
  * @returns {Object} Object containing sandboxConfigName string and sandbox instance from API
@@ -131,7 +130,11 @@ const buildSandbox = async ({
131
130
  const accountId = getAccountId(accountConfig.portalId);
132
131
 
133
132
  let result;
134
- const spinniesI18nKey = `${i18nKey}.loading.${type}`;
133
+ const loadingLangKey =
134
+ type === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX
135
+ ? 'developer'
136
+ : 'standard';
137
+ const spinniesI18nKey = `${i18nKey}.loading.${loadingLangKey}`;
135
138
 
136
139
  try {
137
140
  logger.log('');
@@ -140,7 +143,6 @@ const buildSandbox = async ({
140
143
  sandboxName: name,
141
144
  }),
142
145
  });
143
-
144
146
  const sandboxApiType = sandboxApiTypeMap[type]; // API expects sandbox type as 1 or 2
145
147
  result = await createSandbox(accountId, name, sandboxApiType);
146
148
 
@@ -219,7 +221,7 @@ const buildSandbox = async ({
219
221
  const plural = devSandboxLimit !== 1;
220
222
  const hasDevelopmentSandboxes = getHasSandboxesByType(
221
223
  accountConfig,
222
- DEVELOPER_SANDBOX_TYPE
224
+ HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX
223
225
  );
224
226
  if (hasDevelopmentSandboxes) {
225
227
  logger.error(
@@ -262,7 +264,7 @@ const buildSandbox = async ({
262
264
  const plural = standardSandboxLimit !== 1;
263
265
  const hasStandardSandboxes = getHasSandboxesByType(
264
266
  accountConfig,
265
- STANDARD_SANDBOX_TYPE
267
+ HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX
266
268
  );
267
269
  if (hasStandardSandboxes) {
268
270
  logger.error(
@@ -5,8 +5,8 @@ const { i18n } = require('./lang');
5
5
  const {
6
6
  getAvailableSyncTypes,
7
7
  pollSyncTaskStatus,
8
- sandboxTypeMap,
9
8
  syncTypes,
9
+ isDevelopmentSandbox,
10
10
  } = require('./sandboxes');
11
11
  const { initiateSync } = require('@hubspot/local-dev-lib/sandboxes');
12
12
  const {
@@ -20,7 +20,6 @@ const {
20
20
  const { getSandboxTypeAsString } = require('./sandboxes');
21
21
  const { getAccountId } = require('@hubspot/local-dev-lib/config');
22
22
  const { uiAccountDescription } = require('./ui');
23
- const { DEVELOPER_SANDBOX_TYPE } = require('./constants');
24
23
 
25
24
  const i18nKey = 'cli.lib.sandbox.sync';
26
25
 
@@ -51,7 +50,7 @@ const syncSandbox = async ({
51
50
 
52
51
  const baseUrl = getHubSpotWebsiteOrigin(env);
53
52
  const syncStatusUrl = `${baseUrl}/sandboxes-developer/${parentAccountId}/${getSandboxTypeAsString(
54
- accountConfig.sandboxAccountType
53
+ accountConfig.accountType
55
54
  )}`;
56
55
 
57
56
  try {
@@ -86,11 +85,7 @@ const syncSandbox = async ({
86
85
  accountName: uiAccountDescription(accountId),
87
86
  }),
88
87
  });
89
- if (
90
- skipPolling &&
91
- sandboxTypeMap[accountConfig.sandboxAccountType] ===
92
- DEVELOPER_SANDBOX_TYPE
93
- ) {
88
+ if (skipPolling && isDevelopmentSandbox(accountConfig)) {
94
89
  if (syncTasks.some(t => t.type === syncTypes.OBJECT_RECORDS)) {
95
90
  logger.log(i18n(`${i18nKey}.loading.skipPollingWithContacts`));
96
91
  } else {
package/lib/sandboxes.js CHANGED
@@ -14,53 +14,45 @@ const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
14
14
  const {
15
15
  HUBSPOT_ACCOUNT_TYPES,
16
16
  } = require('@hubspot/local-dev-lib/constants/config');
17
- const {
18
- STANDARD_SANDBOX_TYPE,
19
- DEVELOPER_SANDBOX_TYPE,
20
- DEVELOPER_SANDBOX,
21
- STANDARD_SANDBOX,
22
- } = require('./constants');
23
17
 
24
18
  const syncTypes = {
25
19
  OBJECT_RECORDS: 'object-records',
26
20
  };
27
21
 
28
22
  const sandboxTypeMap = {
29
- DEV: DEVELOPER_SANDBOX_TYPE,
30
- dev: DEVELOPER_SANDBOX_TYPE,
31
- DEVELOPER: DEVELOPER_SANDBOX_TYPE,
32
- developer: DEVELOPER_SANDBOX_TYPE,
33
- DEVELOPMENT: DEVELOPER_SANDBOX_TYPE,
34
- development: DEVELOPER_SANDBOX_TYPE,
35
- STANDARD: STANDARD_SANDBOX_TYPE,
36
- standard: STANDARD_SANDBOX_TYPE,
23
+ dev: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
24
+ developer: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
25
+ development: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
26
+ standard: HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
37
27
  };
38
28
 
39
29
  const sandboxApiTypeMap = {
40
- standard: 1,
41
- developer: 2,
30
+ [HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX]: 1,
31
+ [HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX]: 2,
42
32
  };
43
33
 
44
34
  const getSandboxTypeAsString = accountType => {
45
- if (
46
- accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX ||
47
- accountType === DEVELOPER_SANDBOX // remove line once sandboxAccountType is removed
48
- ) {
35
+ if (accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX) {
49
36
  return 'development'; // Only place we're using this specific name
50
37
  }
51
- return STANDARD_SANDBOX_TYPE;
38
+ return 'standard';
52
39
  };
53
40
 
54
41
  const getSandboxName = config =>
55
- `[${getSandboxTypeAsString(
56
- config.accountType || config.sandboxAccountType
57
- )} sandbox] `;
42
+ `[${getSandboxTypeAsString(config.accountType)} sandbox] `;
58
43
 
59
44
  const isSandbox = config =>
60
- config.accountType
61
- ? config.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX ||
62
- config.accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX
63
- : config.sandboxAccountType && config.sandboxAccountType !== null;
45
+ config.accountType &&
46
+ (config.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX ||
47
+ config.accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX);
48
+
49
+ const isStandardSandbox = config =>
50
+ config.accountType &&
51
+ config.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX;
52
+
53
+ const isDevelopmentSandbox = config =>
54
+ config.accountType &&
55
+ config.accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX;
64
56
 
65
57
  function getHasSandboxesByType(parentAccountConfig, type) {
66
58
  const config = getConfig();
@@ -70,8 +62,8 @@ function getHasSandboxesByType(parentAccountConfig, type) {
70
62
  (portal.parentAccountId !== null ||
71
63
  portal.parentAccountId !== undefined) &&
72
64
  portal.parentAccountId === parentPortalId &&
73
- portal.sandboxAccountType &&
74
- sandboxTypeMap[portal.sandboxAccountType] === type
65
+ portal.accountType &&
66
+ portal.accountType === type
75
67
  ) {
76
68
  return true;
77
69
  }
@@ -116,14 +108,15 @@ const getSyncTypesWithContactRecordsPrompt = async (
116
108
  syncTasks.some(t => t.type === syncTypes.OBJECT_RECORDS) &&
117
109
  !skipPrompt
118
110
  ) {
111
+ const langKey = isDevelopmentSandbox(accountConfig)
112
+ ? 'developer'
113
+ : 'standard';
119
114
  const { contactRecordsSyncPrompt } = await promptUser([
120
115
  {
121
116
  name: 'contactRecordsSyncPrompt',
122
117
  type: 'confirm',
123
118
  message: i18n(
124
- `cli.lib.sandbox.sync.confirm.syncContactRecords.${
125
- sandboxTypeMap[accountConfig.sandboxAccountType]
126
- }`
119
+ `cli.lib.sandbox.sync.confirm.syncContactRecords.${langKey}`
127
120
  ),
128
121
  },
129
122
  ]);
@@ -146,13 +139,13 @@ const validateSandboxUsageLimits = async (accountConfig, sandboxType, env) => {
146
139
  if (!usage) {
147
140
  throw new Error('Unable to fetch sandbox usage limits. Please try again.');
148
141
  }
149
- if (sandboxType === DEVELOPER_SANDBOX_TYPE) {
150
- if (usage[DEVELOPER_SANDBOX].available === 0) {
151
- const devSandboxLimit = usage[DEVELOPER_SANDBOX].limit;
142
+ if (sandboxType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX) {
143
+ if (usage['DEVELOPER'].available === 0) {
144
+ const devSandboxLimit = usage['DEVELOPER'].limit;
152
145
  const plural = devSandboxLimit !== 1;
153
146
  const hasDevelopmentSandboxes = getHasSandboxesByType(
154
147
  accountConfig,
155
- DEVELOPER_SANDBOX_TYPE
148
+ HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX
156
149
  );
157
150
  if (hasDevelopmentSandboxes) {
158
151
  throw new Error(
@@ -183,13 +176,13 @@ const validateSandboxUsageLimits = async (accountConfig, sandboxType, env) => {
183
176
  }
184
177
  }
185
178
  }
186
- if (sandboxType === STANDARD_SANDBOX_TYPE) {
187
- if (usage[STANDARD_SANDBOX].available === 0) {
188
- const standardSandboxLimit = usage[STANDARD_SANDBOX].limit;
179
+ if (sandboxType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX) {
180
+ if (usage['STANDARD'].available === 0) {
181
+ const standardSandboxLimit = usage['STANDARD'].limit;
189
182
  const plural = standardSandboxLimit !== 1;
190
183
  const hasStandardSandboxes = getHasSandboxesByType(
191
184
  accountConfig,
192
- STANDARD_SANDBOX_TYPE
185
+ HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX
193
186
  );
194
187
  if (hasStandardSandboxes) {
195
188
  throw new Error(
@@ -364,6 +357,8 @@ module.exports = {
364
357
  sandboxApiTypeMap,
365
358
  syncTypes,
366
359
  isSandbox,
360
+ isStandardSandbox,
361
+ isDevelopmentSandbox,
367
362
  getSandboxName,
368
363
  getSandboxTypeAsString,
369
364
  getHasSandboxesByType,
package/lib/ui.js CHANGED
@@ -5,10 +5,11 @@ const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
5
5
  const { i18n } = require('./lang');
6
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
7
7
  const { isSandbox, getSandboxName } = require('./sandboxes');
8
+ const { isDeveloperTestAccount } = require('./developerTestAccounts');
8
9
  const {
9
- isDeveloperTestAccount,
10
- DEV_TEST_ACCOUNT_STRING,
11
- } = require('./developerTestAccounts');
10
+ HUBSPOT_ACCOUNT_TYPE_STRINGS,
11
+ HUBSPOT_ACCOUNT_TYPES,
12
+ } = require('@hubspot/local-dev-lib/constants/config');
12
13
 
13
14
  const UI_COLORS = {
14
15
  SORBET: '#FF8F59',
@@ -82,7 +83,9 @@ const uiAccountDescription = (accountId, bold = true) => {
82
83
  if (isSandbox(account)) {
83
84
  accountTypeString = getSandboxName(account);
84
85
  } else if (isDeveloperTestAccount(account)) {
85
- accountTypeString = `[${DEV_TEST_ACCOUNT_STRING}] `;
86
+ accountTypeString = `[${
87
+ HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST]
88
+ }] `;
86
89
  }
87
90
  const message = `${account.name} ${accountTypeString}(${account.portalId})`;
88
91
  return bold ? chalk.bold(message) : message;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "5.1.4-beta.2",
3
+ "version": "5.1.4-beta.3",
4
4
  "description": "CLI for working with HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -11,7 +11,7 @@
11
11
  "@hubspot/cli-lib": "^9.0.0",
12
12
  "@hubspot/local-dev-lib": "^0.3.5",
13
13
  "@hubspot/serverless-dev-runtime": "5.1.4-beta.2",
14
- "@hubspot/theme-preview-dev-server": "0.0.2",
14
+ "@hubspot/theme-preview-dev-server": "0.0.3",
15
15
  "@hubspot/ui-extensions-dev-server": "0.8.9",
16
16
  "archiver": "^5.3.0",
17
17
  "chalk": "^4.1.2",
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "cebb71d06baf30086b1f20bb96e2eb508d242cac"
49
+ "gitHead": "9c4a1d3e530cbbe997db1beb3a1291546c6fa8b0"
50
50
  }