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

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 (66) hide show
  1. package/commands/accounts/clean.js +2 -2
  2. package/commands/accounts/info.js +1 -1
  3. package/commands/accounts/list.js +1 -4
  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/dev.js +4 -7
  21. package/commands/project/listBuilds.js +1 -4
  22. package/commands/project/logs.js +5 -6
  23. package/commands/project/upload.js +2 -5
  24. package/commands/project/watch.js +2 -5
  25. package/commands/theme/marketplace-validate.js +1 -1
  26. package/commands/theme/preview.js +18 -2
  27. package/commands/upload.js +5 -2
  28. package/commands/watch.js +1 -1
  29. package/lang/en.lyaml +23 -6
  30. package/lib/DevServerManager.js +8 -3
  31. package/lib/LocalDevManager.js +9 -6
  32. package/lib/__tests__/commonOpts.js +10 -8
  33. package/lib/__tests__/serverlessLogs.js +2 -2
  34. package/lib/__tests__/validation.js +0 -1
  35. package/lib/commonOpts.js +14 -2
  36. package/lib/constants.js +84 -0
  37. package/lib/errorHandlers/apiErrors.js +4 -2
  38. package/lib/errorHandlers/overrideErrors.js +95 -0
  39. package/lib/filesystem.js +3 -1
  40. package/lib/links.js +4 -5
  41. package/lib/oauth.js +3 -1
  42. package/lib/process.js +4 -6
  43. package/lib/projectStructure.js +27 -18
  44. package/lib/projects.js +8 -46
  45. package/lib/projectsWatch.js +5 -3
  46. package/lib/prompts/createProjectPrompt.js +3 -4
  47. package/lib/prompts/feedbackPrompt.js +1 -1
  48. package/lib/prompts/personalAccessKeyPrompt.js +1 -1
  49. package/lib/prompts/projectAddPrompt.js +1 -1
  50. package/lib/sandboxCreate.js +1 -1
  51. package/lib/sandboxSync.js +1 -1
  52. package/lib/sandboxes.js +1 -1
  53. package/lib/serverlessLogs.js +2 -2
  54. package/lib/ui/git.js +28 -0
  55. package/lib/{ui.js → ui/index.js} +6 -5
  56. package/lib/ui/serverlessFunctionLogs.js +103 -0
  57. package/lib/{supportHyperlinks.js → ui/supportHyperlinks.js} +1 -1
  58. package/lib/{supportsColor.js → ui/supportsColor.js} +1 -1
  59. package/lib/ui/table.js +70 -0
  60. package/lib/upload.js +3 -1
  61. package/lib/usageTracking.js +3 -1
  62. package/lib/validation.js +10 -6
  63. package/package.json +6 -6
  64. /package/lib/{CliProgressMultibarManager.js → ui/CliProgressMultibarManager.js} +0 -0
  65. /package/lib/{SpinniesManager.js → ui/SpinniesManager.js} +0 -0
  66. /package/lib/{spinniesUtils.js → ui/spinniesUtils.js} +0 -0
@@ -8,13 +8,13 @@ const {
8
8
  getAccountId,
9
9
  getConfigDefaultAccount,
10
10
  } = require('@hubspot/local-dev-lib/config');
11
- const { PROJECT_CONFIG_FILE } = require('@hubspot/cli-lib/lib/constants');
12
- const SpinniesManager = require('./SpinniesManager');
11
+ const { PROJECT_CONFIG_FILE } = require('./constants');
12
+ const SpinniesManager = require('./ui/SpinniesManager');
13
13
  const DevServerManager = require('./DevServerManager');
14
14
  const { EXIT_CODES } = require('./enums/exitCodes');
15
15
  const { getProjectDetailUrl } = require('./projects');
16
16
  const {
17
- APP_COMPONENT_CONFIG,
17
+ CONFIG_FILES,
18
18
  COMPONENT_TYPES,
19
19
  findProjectComponents,
20
20
  getAppCardConfigs,
@@ -243,7 +243,7 @@ class LocalDevManager {
243
243
  let missingComponents = [];
244
244
 
245
245
  runnableComponents.forEach(({ type, config, path }) => {
246
- if (type === COMPONENT_TYPES.app) {
246
+ if (Object.values(COMPONENT_TYPES).includes(type)) {
247
247
  const cardConfigs = getAppCardConfigs(config, path);
248
248
 
249
249
  if (!deployedComponentNames.includes(config.name)) {
@@ -283,9 +283,12 @@ class LocalDevManager {
283
283
  });
284
284
 
285
285
  const configPaths = runnableComponents
286
- .filter(({ type }) => type === COMPONENT_TYPES.app)
286
+ .filter(({ type }) => Object.values(COMPONENT_TYPES).includes(type))
287
287
  .map(component => {
288
- const appConfigPath = path.join(component.path, APP_COMPONENT_CONFIG);
288
+ const appConfigPath = path.join(
289
+ component.path,
290
+ CONFIG_FILES[component.type]
291
+ );
289
292
  return appConfigPath;
290
293
  });
291
294
 
@@ -1,4 +1,7 @@
1
- const { Mode, DEFAULT_MODE } = require('@hubspot/cli-lib');
1
+ const {
2
+ MODE,
3
+ DEFAULT_MODE,
4
+ } = require('@hubspot/local-dev-lib/constants/files');
2
5
  const {
3
6
  getAndLoadConfigIfNeeded,
4
7
  getAccountId,
@@ -7,7 +10,6 @@ const {
7
10
  } = require('@hubspot/local-dev-lib/config');
8
11
  const { getMode } = require('../commonOpts');
9
12
 
10
- jest.mock('@hubspot/cli-lib');
11
13
  jest.mock('@hubspot/local-dev-lib/config');
12
14
 
13
15
  describe('@hubspot/cli/lib/commonOpts', () => {
@@ -19,7 +21,7 @@ describe('@hubspot/cli/lib/commonOpts', () => {
19
21
  const devAccountConfig = {
20
22
  accountId: accounts.DEV,
21
23
  name: 'DEV',
22
- defaultMode: Mode.draft,
24
+ defaultMode: MODE.draft,
23
25
  };
24
26
  const prodAccountConfig = {
25
27
  accountId: accounts.PROD,
@@ -31,7 +33,7 @@ describe('@hubspot/cli/lib/commonOpts', () => {
31
33
  };
32
34
  const configWithDefaultMode = {
33
35
  ...config,
34
- defaultMode: Mode.draft,
36
+ defaultMode: MODE.draft,
35
37
  };
36
38
  afterEach(() => {
37
39
  getAndLoadConfigIfNeeded.mockReset();
@@ -44,8 +46,8 @@ describe('@hubspot/cli/lib/commonOpts', () => {
44
46
  it('should return the mode specified by the command option if present.', () => {
45
47
  getAndLoadConfigIfNeeded.mockReturnValue(configWithDefaultMode);
46
48
  getAccountConfig.mockReturnValue(devAccountConfig);
47
- expect(getMode({ mode: Mode.draft })).toBe(Mode.draft);
48
- expect(getMode({ mode: Mode.publish })).toBe(Mode.publish);
49
+ expect(getMode({ mode: MODE.draft })).toBe(MODE.draft);
50
+ expect(getMode({ mode: MODE.publish })).toBe(MODE.publish);
49
51
  expect(getMode({ mode: 'undefined-mode' })).toBe('undefined-mode');
50
52
  });
51
53
  });
@@ -55,7 +57,7 @@ describe('@hubspot/cli/lib/commonOpts', () => {
55
57
  getAccountId.mockReturnValue(accounts.DEV);
56
58
  getAccountConfig.mockReturnValue(devAccountConfig);
57
59
  loadConfigFromEnvironment.mockReturnValue(undefined);
58
- expect(getMode({ account: accounts.DEV })).toBe(Mode.draft);
60
+ expect(getMode({ account: accounts.DEV })).toBe(MODE.draft);
59
61
  });
60
62
  });
61
63
  describe('3. hubspot.config.yml -> config.defaultMode', () => {
@@ -64,7 +66,7 @@ describe('@hubspot/cli/lib/commonOpts', () => {
64
66
  getAccountId.mockReturnValue(accounts.PROD);
65
67
  getAccountConfig.mockReturnValue(prodAccountConfig);
66
68
  loadConfigFromEnvironment.mockReturnValue(undefined);
67
- expect(getMode({ account: accounts.PROD })).toBe(Mode.draft);
69
+ expect(getMode({ account: accounts.PROD })).toBe(MODE.draft);
68
70
  });
69
71
  });
70
72
  describe('4. DEFAULT_MODE', () => {
@@ -1,8 +1,8 @@
1
1
  const mockStdIn = require('mock-stdin');
2
- const { outputLogs } = require('@hubspot/cli-lib/lib/logs');
2
+ const { outputLogs } = require('../ui/serverlessFunctionLogs');
3
3
  const { tailLogs } = require('../serverlessLogs');
4
4
 
5
- jest.mock('@hubspot/cli-lib/lib/logs');
5
+ jest.mock('../ui/serverlessFunctionLogs');
6
6
 
7
7
  jest.useFakeTimers();
8
8
 
@@ -7,7 +7,6 @@ const {
7
7
  const { getAccountId } = require('../commonOpts');
8
8
  const { validateAccount } = require('../validation');
9
9
 
10
- jest.mock('@hubspot/cli-lib');
11
10
  jest.mock('@hubspot/local-dev-lib/config');
12
11
  jest.mock('@hubspot/local-dev-lib/logger');
13
12
  jest.mock('@hubspot/local-dev-lib/oauth');
package/lib/commonOpts.js CHANGED
@@ -2,7 +2,13 @@ const {
2
2
  LOG_LEVEL,
3
3
  setLogLevel: setLoggerLogLevel,
4
4
  } = require('@hubspot/local-dev-lib/logger');
5
- const { DEFAULT_MODE, Mode } = require('@hubspot/cli-lib');
5
+ const {
6
+ setLogLevel: setCliLibLoggerLogLevel,
7
+ } = require('@hubspot/cli-lib/logger');
8
+ const {
9
+ DEFAULT_MODE,
10
+ MODE,
11
+ } = require('@hubspot/local-dev-lib/constants/files');
6
12
  const {
7
13
  getAccountId: getAccountIdFromConfig,
8
14
  getAccountConfig,
@@ -35,7 +41,7 @@ const addOverwriteOptions = yargs =>
35
41
  });
36
42
 
37
43
  const addModeOptions = (yargs, { read, write }) => {
38
- const modes = `<${Object.values(Mode).join(' | ')}>`;
44
+ const modes = `<${Object.values(MODE).join(' | ')}>`;
39
45
 
40
46
  return yargs.option('mode', {
41
47
  alias: 'm',
@@ -68,8 +74,14 @@ const setLogLevel = (options = {}) => {
68
74
  const { debug } = options;
69
75
  if (debug) {
70
76
  setLoggerLogLevel(LOG_LEVEL.DEBUG);
77
+
78
+ // TODO remove this when we remove cli-lib as a dep
79
+ setCliLibLoggerLogLevel(LOG_LEVEL.DEBUG);
71
80
  } else {
72
81
  setLoggerLogLevel(LOG_LEVEL.LOG);
82
+
83
+ // TODO remove this when we remove cli-lib as a dep
84
+ setCliLibLoggerLogLevel(LOG_LEVEL.LOG);
73
85
  }
74
86
  };
75
87
 
package/lib/constants.js CHANGED
@@ -2,7 +2,91 @@ const HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH =
2
2
  'HubSpot/hubspot-project-components';
3
3
  const DEFAULT_PROJECT_TEMPLATE_BRANCH = 'main';
4
4
 
5
+ const FEEDBACK_OPTIONS = {
6
+ BUG: 'bug',
7
+ GENERAL: 'general',
8
+ };
9
+ const FEEDBACK_URLS = {
10
+ BUG: 'https://github.com/HubSpot/hubspot-cli/issues/new',
11
+ GENERAL:
12
+ 'https://docs.google.com/forms/d/e/1FAIpQLSejZZewYzuH3oKBU01tseX-cSWOUsTHLTr-YsiMGpzwcvgIMg/viewform?usp=sf_link',
13
+ };
14
+ const FEEDBACK_INTERVAL = 10;
15
+
16
+ const HUBSPOT_FOLDER = '@hubspot';
17
+ const MARKETPLACE_FOLDER = '@marketplace';
18
+
19
+ const CONFIG_FLAGS = {
20
+ USE_CUSTOM_OBJECT_HUBFILE: 'useCustomObjectHubfile',
21
+ };
22
+
23
+ const POLLING_DELAY = 2000;
24
+
25
+ const PROJECT_CONFIG_FILE = 'hsproject.json';
26
+ const PROJECT_BUILD_STATES = {
27
+ BUILDING: 'BUILDING',
28
+ ENQUEUED: 'ENQUEUED',
29
+ FAILURE: 'FAILURE',
30
+ PENDING: 'PENDING',
31
+ SUCCESS: 'SUCCESS',
32
+ };
33
+ const PROJECT_DEPLOY_STATES = {
34
+ DEPLOYING: 'DEPLOYING',
35
+ FAILURE: 'FAILURE',
36
+ PENDING: 'PENDING',
37
+ SUCCESS: 'SUCCESS',
38
+ };
39
+ const PROJECT_BUILD_TEXT = {
40
+ STATES: { ...PROJECT_BUILD_STATES },
41
+ STATUS_TEXT: 'Building',
42
+ SUBTASK_KEY: 'subbuildStatuses',
43
+ TYPE_KEY: 'buildType',
44
+ SUBTASK_NAME_KEY: 'buildName',
45
+ };
46
+ const PROJECT_DEPLOY_TEXT = {
47
+ STATES: { ...PROJECT_DEPLOY_STATES },
48
+ STATUS_TEXT: 'Deploying',
49
+ SUBTASK_KEY: 'subdeployStatuses',
50
+ TYPE_KEY: 'deployType',
51
+ SUBTASK_NAME_KEY: 'deployName',
52
+ };
53
+ const PROJECT_ERROR_TYPES = {
54
+ PROJECT_LOCKED: 'BuildPipelineErrorType.PROJECT_LOCKED',
55
+ MISSING_PROJECT_PROVISION: 'BuildPipelineErrorType.MISSING_PROJECT_PROVISION',
56
+ BUILD_NOT_IN_PROGRESS: 'BuildPipelineErrorType.BUILD_NOT_IN_PROGRESS',
57
+ };
58
+ const PROJECT_TASK_TYPES = {
59
+ PRIVATE_APP: 'private app',
60
+ APP_FUNCTION: 'function',
61
+ CRM_CARD_V2: 'crm card',
62
+ };
63
+ const PROJECT_COMPONENT_TYPES = {
64
+ PROJECTS: 'projects',
65
+ COMPONENTS: 'components',
66
+ };
67
+ const PLATFORM_VERSION_ERROR_TYPES = {
68
+ PLATFORM_VERSION_NOT_SPECIFIED:
69
+ 'PlatformVersionErrorType.PLATFORM_VERSION_NOT_SPECIFIED',
70
+ PLATFORM_VERSION_RETIRED: 'PlatformVersionErrorType.PLATFORM_VERSION_RETIRED',
71
+ PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST:
72
+ 'PlatformVersionErrorType.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST',
73
+ };
74
+
5
75
  module.exports = {
6
76
  HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH,
7
77
  DEFAULT_PROJECT_TEMPLATE_BRANCH,
78
+ FEEDBACK_OPTIONS,
79
+ FEEDBACK_URLS,
80
+ FEEDBACK_INTERVAL,
81
+ HUBSPOT_FOLDER,
82
+ MARKETPLACE_FOLDER,
83
+ CONFIG_FLAGS,
84
+ POLLING_DELAY,
85
+ PROJECT_CONFIG_FILE,
86
+ PROJECT_BUILD_TEXT,
87
+ PROJECT_DEPLOY_TEXT,
88
+ PROJECT_ERROR_TYPES,
89
+ PROJECT_TASK_TYPES,
90
+ PROJECT_COMPONENT_TYPES,
91
+ PLATFORM_VERSION_ERROR_TYPES,
8
92
  };
@@ -6,7 +6,7 @@ const {
6
6
  const {
7
7
  SCOPE_GROUPS,
8
8
  PERSONAL_ACCESS_KEY_AUTH_METHOD,
9
- } = require('@hubspot/cli-lib/lib/constants');
9
+ } = require('@hubspot/local-dev-lib/constants/auth');
10
10
  const {
11
11
  fetchScopeData,
12
12
  } = require('@hubspot/cli-lib/api/localDevAuth/authenticated');
@@ -15,6 +15,7 @@ const {
15
15
  logErrorInstance,
16
16
  ErrorContext,
17
17
  } = require('./standardErrors');
18
+ const { overrideErrors } = require('./overrideErrors');
18
19
  const { i18n } = require('../lang');
19
20
 
20
21
  const i18nKey = 'cli.lib.errorHandlers.apiErrors';
@@ -257,6 +258,7 @@ function logApiErrorInstance(error, context) {
257
258
  // Use the new local-dev-lib error handler
258
259
  // NOTE: This will eventually replace the logic in logApiStatusCodeError
259
260
  if (error.isAxiosError) {
261
+ if (overrideErrors(error)) return;
260
262
  const errorWithContext = getAxiosErrorWithContext(error, context);
261
263
  logger.error(errorWithContext.message);
262
264
  return;
@@ -338,7 +340,7 @@ async function logServerlessFunctionApiErrorInstance(
338
340
  context
339
341
  ) {
340
342
  if (isMissingScopeError(error)) {
341
- await verifyAccessKeyAndUserAccess(accountId, SCOPE_GROUPS.functions);
343
+ await verifyAccessKeyAndUserAccess(accountId, SCOPE_GROUPS.CMS_FUNCTIONS);
342
344
  return;
343
345
  }
344
346
 
@@ -0,0 +1,95 @@
1
+ const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
2
+ const { logger } = require('@hubspot/local-dev-lib/logger');
3
+
4
+ const { PLATFORM_VERSION_ERROR_TYPES } = require('../constants');
5
+ const { i18n } = require('../lang');
6
+ const { uiLine, uiLink } = require('../ui');
7
+
8
+ const i18nKey = 'cli.lib.errorHandlers.overrideErrors';
9
+
10
+ function createPlatformVersionError(subCategory, errData) {
11
+ const docsLink = uiLink(
12
+ i18n(`${i18nKey}.platformVersionErrors.docsLink`),
13
+ 'https://developers.hubspot.com/docs/platform/platform-versioning'
14
+ );
15
+
16
+ const platformVersionKey = {
17
+ [PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED]:
18
+ 'unspecified platformVersion',
19
+ [PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED]:
20
+ errData.context.RETIRED_PLATFORM_VERSION,
21
+ [PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST]:
22
+ errData.context.PLATFORM_VERSION,
23
+ };
24
+
25
+ const errorTypeToTranslationKey = {
26
+ [PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED]:
27
+ 'unspecifiedPlatformVersion',
28
+ [PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED]:
29
+ 'platformVersionRetired',
30
+ [PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST]:
31
+ 'nonExistentPlatformVersion',
32
+ };
33
+
34
+ const platformVersion = platformVersionKey[subCategory] || '';
35
+ const translationKey = errorTypeToTranslationKey[subCategory];
36
+
37
+ uiLine();
38
+ logger.error(i18n(`${i18nKey}.platformVersionErrors.header`));
39
+ logger.log(
40
+ i18n(`${i18nKey}.platformVersionErrors.${translationKey}`, {
41
+ platformVersion,
42
+ })
43
+ );
44
+ logger.log(i18n(`${i18nKey}.platformVersionErrors.updateProject`));
45
+ logger.log(
46
+ i18n(`${i18nKey}.platformVersionErrors.betaLink`, {
47
+ docsLink,
48
+ })
49
+ );
50
+ uiLine();
51
+ }
52
+
53
+ function overrideErrors(err) {
54
+ if (
55
+ isSpecifiedError(err, {
56
+ subCategory: PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED,
57
+ })
58
+ ) {
59
+ createPlatformVersionError(
60
+ PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED,
61
+ err.response.data
62
+ );
63
+ return true;
64
+ }
65
+
66
+ if (
67
+ isSpecifiedError(err, {
68
+ subCategory: PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED,
69
+ })
70
+ ) {
71
+ createPlatformVersionError(
72
+ PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED,
73
+ err.response.data
74
+ );
75
+ return true;
76
+ }
77
+
78
+ if (
79
+ isSpecifiedError(err, {
80
+ subCategory:
81
+ PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST,
82
+ })
83
+ ) {
84
+ createPlatformVersionError(
85
+ PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST,
86
+ err.response.data
87
+ );
88
+ return true;
89
+ }
90
+ return false;
91
+ }
92
+
93
+ module.exports = {
94
+ overrideErrors,
95
+ };
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);
@@ -869,45 +871,6 @@ const createProjectComponent = async (
869
871
  );
870
872
  };
871
873
 
872
- const showPlatformVersionWarning = async (accountId, projectConfig) => {
873
- const platformVersion = projectConfig.platformVersion;
874
- const docsLink = uiLink(
875
- i18n(`${i18nKey}.showPlatformVersionWarning.docsLink`),
876
- 'https://developers.hubspot.com/docs/platform/platform-versioning'
877
- );
878
-
879
- 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
- }
900
- } else if (platformVersion === '2023.1') {
901
- logger.log('');
902
- logger.warn(
903
- i18n(`${i18nKey}.showPlatformVersionWarning.deprecatedVersion`, {
904
- docsLink,
905
- })
906
- );
907
- logger.log('');
908
- }
909
- };
910
-
911
874
  module.exports = {
912
875
  writeProjectConfig,
913
876
  getProjectConfig,
@@ -924,5 +887,4 @@ module.exports = {
924
887
  ensureProjectExists,
925
888
  logFeedbackMessage,
926
889
  createProjectComponent,
927
- showPlatformVersionWarning,
928
890
  };
@@ -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');