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

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 (72) hide show
  1. package/commands/accounts/clean.js +2 -2
  2. package/commands/accounts/info.js +1 -1
  3. package/commands/accounts/list.js +12 -19
  4. package/commands/auth.js +6 -2
  5. package/commands/cms/convertFields.js +2 -2
  6. package/commands/cms/lighthouseScore.js +3 -9
  7. package/commands/config/set/defaultMode.js +3 -3
  8. package/commands/create/api-sample.js +1 -0
  9. package/commands/create/website-theme.js +1 -0
  10. package/commands/customObject/schema/create.js +5 -2
  11. package/commands/customObject/schema/fetch.js +2 -2
  12. package/commands/customObject/schema/update.js +5 -2
  13. package/commands/feedback.js +1 -4
  14. package/commands/functions/deploy.js +1 -1
  15. package/commands/functions/list.js +1 -5
  16. package/commands/init.js +7 -3
  17. package/commands/list.js +1 -4
  18. package/commands/logs.js +1 -1
  19. package/commands/module/marketplace-validate.js +1 -1
  20. package/commands/project/deploy.js +2 -2
  21. package/commands/project/dev.js +14 -12
  22. package/commands/project/listBuilds.js +1 -4
  23. package/commands/project/logs.js +5 -6
  24. package/commands/project/upload.js +4 -4
  25. package/commands/project/watch.js +2 -2
  26. package/commands/sandbox/create.js +23 -12
  27. package/commands/sandbox/sync.js +18 -15
  28. package/commands/theme/marketplace-validate.js +1 -1
  29. package/commands/theme/preview.js +18 -2
  30. package/commands/upload.js +5 -2
  31. package/commands/watch.js +1 -1
  32. package/lang/en.lyaml +26 -5
  33. package/lib/DevServerManager.js +8 -3
  34. package/lib/LocalDevManager.js +9 -6
  35. package/lib/__tests__/commonOpts.js +10 -8
  36. package/lib/__tests__/serverlessLogs.js +2 -2
  37. package/lib/__tests__/validation.js +0 -1
  38. package/lib/commonOpts.js +14 -2
  39. package/lib/constants.js +82 -9
  40. package/lib/developerTestAccounts.js +0 -3
  41. package/lib/errorHandlers/apiErrors.js +4 -2
  42. package/lib/errorHandlers/overrideErrors.js +86 -0
  43. package/lib/filesystem.js +3 -1
  44. package/lib/links.js +4 -5
  45. package/lib/oauth.js +3 -1
  46. package/lib/process.js +4 -6
  47. package/lib/projectStructure.js +27 -18
  48. package/lib/projects.js +15 -26
  49. package/lib/projectsWatch.js +5 -3
  50. package/lib/prompts/createProjectPrompt.js +3 -4
  51. package/lib/prompts/feedbackPrompt.js +1 -1
  52. package/lib/prompts/personalAccessKeyPrompt.js +1 -1
  53. package/lib/prompts/projectAddPrompt.js +1 -1
  54. package/lib/prompts/projectDevTargetAccountPrompt.js +9 -10
  55. package/lib/prompts/sandboxesPrompt.js +13 -16
  56. package/lib/sandboxCreate.js +12 -10
  57. package/lib/sandboxSync.js +4 -9
  58. package/lib/sandboxes.js +37 -42
  59. package/lib/serverlessLogs.js +2 -2
  60. package/lib/ui/git.js +28 -0
  61. package/lib/{ui.js → ui/index.js} +12 -8
  62. package/lib/ui/serverlessFunctionLogs.js +103 -0
  63. package/lib/{supportHyperlinks.js → ui/supportHyperlinks.js} +1 -1
  64. package/lib/{supportsColor.js → ui/supportsColor.js} +1 -1
  65. package/lib/ui/table.js +70 -0
  66. package/lib/upload.js +3 -1
  67. package/lib/usageTracking.js +3 -1
  68. package/lib/validation.js +10 -6
  69. package/package.json +6 -6
  70. /package/lib/{CliProgressMultibarManager.js → ui/CliProgressMultibarManager.js} +0 -0
  71. /package/lib/{SpinniesManager.js → ui/SpinniesManager.js} +0 -0
  72. /package/lib/{spinniesUtils.js → ui/spinniesUtils.js} +0 -0
package/lib/filesystem.js CHANGED
@@ -1,6 +1,8 @@
1
1
  const path = require('path');
2
2
  const { getCwd } = require('@hubspot/local-dev-lib/path');
3
- const { FOLDER_DOT_EXTENSIONS } = require('@hubspot/cli-lib/lib/constants');
3
+ const {
4
+ FOLDER_DOT_EXTENSIONS,
5
+ } = require('@hubspot/local-dev-lib/constants/extensions');
4
6
 
5
7
  function resolveLocalPath(filepath) {
6
8
  return filepath && typeof filepath === 'string'
package/lib/links.js CHANGED
@@ -1,11 +1,10 @@
1
1
  const { getEnv } = require('@hubspot/local-dev-lib/config');
2
- const { ENVIRONMENTS } = require('@hubspot/cli-lib/lib/constants');
2
+ const {
3
+ ENVIRONMENTS,
4
+ } = require('@hubspot/local-dev-lib/constants/environments');
3
5
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
4
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
5
- const {
6
- getTableContents,
7
- getTableHeader,
8
- } = require('@hubspot/local-dev-lib/logging/table');
7
+ const { getTableContents, getTableHeader } = require('./ui/table');
9
8
 
10
9
  const open = require('open');
11
10
 
package/lib/oauth.js CHANGED
@@ -8,7 +8,9 @@ const { addOauthToAccountConfig } = require('@hubspot/local-dev-lib/oauth');
8
8
  const { handleExit } = require('./process');
9
9
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
10
10
  const { logger } = require('@hubspot/local-dev-lib/logger');
11
- const { ENVIRONMENTS } = require('@hubspot/cli-lib/lib/constants');
11
+ const {
12
+ ENVIRONMENTS,
13
+ } = require('@hubspot/local-dev-lib/constants/environments');
12
14
 
13
15
  const PORT = 3000;
14
16
  const redirectUri = `http://localhost:${PORT}/oauth-callback`;
package/lib/process.js CHANGED
@@ -4,9 +4,7 @@ const {
4
4
  setLogLevel,
5
5
  LOG_LEVEL,
6
6
  } = require('@hubspot/local-dev-lib/logger');
7
- const {
8
- setLogLevel: setLocalDevLibLogLevel,
9
- } = require('@hubspot/local-dev-lib/logger');
7
+ const { setLogLevel: setCliLibLogLevel } = require('@hubspot/cli-lib/logger');
10
8
  const { i18n } = require('./lang');
11
9
 
12
10
  const i18nKey = 'cli.lib.process';
@@ -36,9 +34,9 @@ const handleExit = callback => {
36
34
  if (isSIGHUP) {
37
35
  setLogLevel(LOG_LEVEL.NONE);
38
36
 
39
- // Update the log level in local-dev-lib's instance of the logger
40
- // This will evenutally replace cli-lib's version of it
41
- setLocalDevLibLogLevel(LOG_LEVEL.LOG);
37
+ // Update the log level in cli-lib's instance of the logger
38
+ // We can remove this when we remove cli-lib as a dep
39
+ setCliLibLogLevel(LOG_LEVEL.NONE);
42
40
  }
43
41
 
44
42
  logger.debug(i18n(`${i18nKey}.exitDebug`, { signal }));
@@ -5,10 +5,23 @@ const { logger } = require('@hubspot/local-dev-lib/logger');
5
5
  const { logErrorInstance } = require('./errorHandlers/standardErrors');
6
6
 
7
7
  const COMPONENT_TYPES = Object.freeze({
8
- app: 'app',
8
+ privateApp: 'private-app',
9
+ publicApp: 'public-app',
9
10
  });
10
11
 
11
- const APP_COMPONENT_CONFIG = 'app.json';
12
+ const CONFIG_FILES = {
13
+ [COMPONENT_TYPES.privateApp]: 'app.json',
14
+ [COMPONENT_TYPES.publicApp]: 'public-app.json',
15
+ };
16
+
17
+ function getTypeFromConfigFile(configFile) {
18
+ for (let key in CONFIG_FILES) {
19
+ if (CONFIG_FILES[key] === configFile) {
20
+ return key;
21
+ }
22
+ }
23
+ return null;
24
+ }
12
25
 
13
26
  function loadConfigFile(configPath) {
14
27
  if (configPath) {
@@ -84,24 +97,20 @@ async function findProjectComponents(projectSourceDir) {
84
97
 
85
98
  projectFiles.forEach(projectFile => {
86
99
  // Find app components
87
- if (projectFile.endsWith(APP_COMPONENT_CONFIG)) {
100
+ const { base, dir } = path.parse(projectFile);
101
+
102
+ if (Object.values(CONFIG_FILES).includes(base)) {
88
103
  const parsedAppConfig = loadConfigFile(projectFile);
89
104
 
90
105
  if (parsedAppConfig && parsedAppConfig.name) {
91
- const appPath = projectFile.substring(
92
- 0,
93
- projectFile.indexOf(APP_COMPONENT_CONFIG)
94
- );
95
- if (typeof appPath === 'string') {
96
- const isLegacy = getIsLegacyApp(parsedAppConfig, appPath);
97
-
98
- components.push({
99
- type: COMPONENT_TYPES.app,
100
- config: parsedAppConfig,
101
- runnable: !isLegacy,
102
- path: appPath,
103
- });
104
- }
106
+ const isLegacy = getIsLegacyApp(parsedAppConfig, dir);
107
+
108
+ components.push({
109
+ type: getTypeFromConfigFile(base),
110
+ config: parsedAppConfig,
111
+ runnable: !isLegacy,
112
+ path: dir,
113
+ });
105
114
  }
106
115
  }
107
116
  });
@@ -110,7 +119,7 @@ async function findProjectComponents(projectSourceDir) {
110
119
  }
111
120
 
112
121
  module.exports = {
113
- APP_COMPONENT_CONFIG,
122
+ CONFIG_FILES,
114
123
  COMPONENT_TYPES,
115
124
  findProjectComponents,
116
125
  getAppCardConfigs,
package/lib/projects.js CHANGED
@@ -9,17 +9,15 @@ const { getEnv } = require('@hubspot/local-dev-lib/config');
9
9
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
10
10
  const {
11
11
  ENVIRONMENTS,
12
+ } = require('@hubspot/local-dev-lib/constants/environments');
13
+ const {
12
14
  FEEDBACK_INTERVAL,
13
15
  POLLING_DELAY,
14
16
  PROJECT_BUILD_TEXT,
15
17
  PROJECT_DEPLOY_TEXT,
16
18
  PROJECT_CONFIG_FILE,
17
19
  PROJECT_TASK_TYPES,
18
- SPINNER_STATUS,
19
- } = require('@hubspot/cli-lib/lib/constants');
20
- const {
21
- fetchDefaultVersion,
22
- } = require('@hubspot/cli-lib/lib/projectPlatformVersion');
20
+ } = require('./constants');
23
21
  const {
24
22
  createProject,
25
23
  getBuildStatus,
@@ -37,7 +35,7 @@ const { promptUser } = require('./prompts/promptUtils');
37
35
  const { EXIT_CODES } = require('./enums/exitCodes');
38
36
  const { uiLine, uiLink, uiAccountDescription } = require('../lib/ui');
39
37
  const { i18n } = require('./lang');
40
- const SpinniesManager = require('./SpinniesManager');
38
+ const SpinniesManager = require('./ui/SpinniesManager');
41
39
  const {
42
40
  logApiErrorInstance,
43
41
  ApiErrorContext,
@@ -47,6 +45,10 @@ const { HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH } = require('./constants');
47
45
 
48
46
  const i18nKey = 'cli.lib.projects';
49
47
 
48
+ const SPINNER_STATUS = {
49
+ SPINNING: 'spinning',
50
+ };
51
+
50
52
  const writeProjectConfig = (configPath, config) => {
51
53
  try {
52
54
  fs.ensureFileSync(configPath);
@@ -877,26 +879,13 @@ const showPlatformVersionWarning = async (accountId, projectConfig) => {
877
879
  );
878
880
 
879
881
  if (!platformVersion) {
880
- try {
881
- const defaultVersion = await fetchDefaultVersion(accountId);
882
- logger.log('');
883
- logger.warn(
884
- i18n(`${i18nKey}.showPlatformVersionWarning.noPlatformVersion`, {
885
- defaultVersion,
886
- docsLink,
887
- })
888
- );
889
- logger.log('');
890
- } catch (e) {
891
- logger.log('');
892
- logger.warn(
893
- i18n(`${i18nKey}.showPlatformVersionWarning.noPlatformVersionAlt`, {
894
- docsLink,
895
- })
896
- );
897
- logger.log('');
898
- logger.debug(e.error);
899
- }
882
+ logger.log('');
883
+ logger.warn(
884
+ i18n(`${i18nKey}.showPlatformVersionWarning.noPlatformVersion`, {
885
+ docsLink,
886
+ })
887
+ );
888
+ logger.log('');
900
889
  } else if (platformVersion === '2023.1') {
901
890
  logger.log('');
902
891
  logger.warn(
@@ -18,7 +18,7 @@ const {
18
18
  queueBuild,
19
19
  } = require('@hubspot/local-dev-lib/api/projects');
20
20
  const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
21
- const { ERROR_TYPES } = require('@hubspot/cli-lib/lib/constants');
21
+ const { PROJECT_ERROR_TYPES } = require('./constants');
22
22
 
23
23
  const i18nKey = 'cli.commands.project.subcommands.watch';
24
24
 
@@ -79,7 +79,7 @@ const debounceQueueBuild = (accountId, projectName, platformVersion) => {
79
79
  } catch (err) {
80
80
  if (
81
81
  isSpecifiedError(err, {
82
- subCategory: ERROR_TYPES.MISSING_PROJECT_PROVISION,
82
+ subCategory: PROJECT_ERROR_TYPES.MISSING_PROJECT_PROVISION,
83
83
  })
84
84
  ) {
85
85
  logger.log(i18n(`${i18nKey}.logs.watchCancelledFromUi`));
@@ -159,7 +159,9 @@ const createNewBuild = async (accountId, projectName, platformVersion) => {
159
159
  return buildId;
160
160
  } catch (err) {
161
161
  logApiErrorInstance(err, new ApiErrorContext({ accountId, projectName }));
162
- if (isSpecifiedError(err, { subCategory: ERROR_TYPES.PROJECT_LOCKED })) {
162
+ if (
163
+ isSpecifiedError(err, { subCategory: PROJECT_ERROR_TYPES.PROJECT_LOCKED })
164
+ ) {
163
165
  await cancelStagedBuild(accountId, projectName);
164
166
  logger.log(i18n(`${i18nKey}.logs.previousStagingBuildCancelled`));
165
167
  }
@@ -1,9 +1,6 @@
1
1
  const path = require('path');
2
2
  const { getCwd } = require('@hubspot/local-dev-lib/path');
3
- const {
4
- PROJECT_COMPONENT_TYPES,
5
- PROJECT_PROPERTIES,
6
- } = require('@hubspot/cli-lib/lib/constants');
3
+ const { PROJECT_COMPONENT_TYPES } = require('../../lib/constants');
7
4
  const { promptUser } = require('./promptUtils');
8
5
  const { fetchJsonFromRepository } = require('@hubspot/cli-lib/github');
9
6
  const { i18n } = require('../lang');
@@ -16,6 +13,8 @@ const {
16
13
 
17
14
  const i18nKey = 'cli.lib.prompts.createProjectPrompt';
18
15
 
16
+ const PROJECT_PROPERTIES = ['name', 'label', 'path', 'insertPath'];
17
+
19
18
  const hasAllProperties = projectList => {
20
19
  return projectList.every(config =>
21
20
  PROJECT_PROPERTIES.every(p =>
@@ -1,6 +1,6 @@
1
1
  const { promptUser } = require('./promptUtils');
2
2
  const { i18n } = require('../lang');
3
- const { FEEDBACK_OPTIONS } = require('@hubspot/cli-lib/lib/constants');
3
+ const { FEEDBACK_OPTIONS } = require('../constants');
4
4
 
5
5
  const i18nKey = 'cli.lib.prompts.feedbackPrompt';
6
6
 
@@ -2,7 +2,7 @@ const open = require('open');
2
2
  const {
3
3
  OAUTH_SCOPES,
4
4
  DEFAULT_OAUTH_SCOPES,
5
- } = require('@hubspot/cli-lib/lib/constants');
5
+ } = require('@hubspot/local-dev-lib/constants/auth');
6
6
  const { deleteEmptyConfigFile } = require('@hubspot/local-dev-lib/config');
7
7
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
8
8
  const { logger } = require('@hubspot/local-dev-lib/logger');
@@ -2,7 +2,7 @@ const { promptUser } = require('./promptUtils');
2
2
  const { fetchJsonFromRepository } = require('@hubspot/cli-lib/github');
3
3
  const { i18n } = require('../lang');
4
4
  const { HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH } = require('../constants');
5
- const { PROJECT_COMPONENT_TYPES } = require('@hubspot/cli-lib/lib/constants');
5
+ const { PROJECT_COMPONENT_TYPES } = require('../constants');
6
6
 
7
7
  const i18nKey = 'cli.lib.prompts.projectAddPrompt';
8
8
 
@@ -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
  };
@@ -1,4 +1,4 @@
1
- const SpinniesManager = require('./SpinniesManager');
1
+ const SpinniesManager = require('./ui/SpinniesManager');
2
2
  const {
3
3
  getSandboxLimit,
4
4
  getHasSandboxesByType,
@@ -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(
@@ -1,12 +1,12 @@
1
- const SpinniesManager = require('./SpinniesManager');
1
+ const SpinniesManager = require('./ui/SpinniesManager');
2
2
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
3
3
  const { logger } = require('@hubspot/local-dev-lib/logger');
4
4
  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 {