@hubspot/cli 6.2.2-experimental.1 → 6.3.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 (57) hide show
  1. package/commands/auth.js +0 -2
  2. package/commands/create/api-sample.js +2 -2
  3. package/commands/create.js +0 -2
  4. package/commands/feedback.js +19 -4
  5. package/commands/functions/list.js +1 -1
  6. package/commands/init.js +0 -2
  7. package/commands/lint.js +28 -1
  8. package/commands/module/marketplace-validate.js +1 -1
  9. package/commands/project/deploy.js +10 -3
  10. package/commands/project/logs.js +1 -1
  11. package/commands/sandbox/delete.js +5 -3
  12. package/commands/theme/generate-selectors.js +1 -1
  13. package/commands/theme/marketplace-validate.js +1 -1
  14. package/lang/en.lyaml +8 -13
  15. package/lib/LocalDevManager.js +2 -2
  16. package/lib/commonOpts.d.ts +26 -1
  17. package/lib/commonOpts.js +72 -55
  18. package/lib/constants.d.ts +0 -8
  19. package/lib/constants.js +1 -9
  20. package/lib/interpolation.d.ts +4 -0
  21. package/lib/interpolation.js +38 -46
  22. package/lib/lang.d.ts +8 -0
  23. package/lib/lang.js +37 -32
  24. package/lib/process.d.ts +11 -0
  25. package/lib/process.js +16 -16
  26. package/lib/prompts/accountNamePrompt.js +1 -2
  27. package/lib/prompts/accountsPrompt.js +0 -17
  28. package/lib/prompts/createFunctionPrompt.js +3 -4
  29. package/lib/prompts/promptUtils.d.ts +12 -1
  30. package/lib/prompts/promptUtils.js +24 -13
  31. package/lib/usageTracking.js +10 -1
  32. package/lib/validation.js +0 -2
  33. package/package.json +3 -1
  34. package/lib/debugInfo.js +0 -20
  35. package/lib/environment.d.ts +0 -1
  36. package/lib/environment.js +0 -13
  37. package/lib/hublValidate.d.ts +0 -2
  38. package/lib/hublValidate.js +0 -32
  39. package/lib/interpolationHelpers.d.ts +0 -10
  40. package/lib/interpolationHelpers.js +0 -34
  41. package/lib/projectLogsManager.d.ts +0 -1
  42. package/lib/prompts/activeInstallConfirmationPrompt.d.ts +0 -1
  43. package/lib/prompts/activeInstallConfirmationPrompt.js +0 -20
  44. package/lib/prompts/deployBuildIdPrompt.d.ts +0 -1
  45. package/lib/prompts/deployBuildIdPrompt.js +0 -22
  46. package/lib/prompts/feedbackPrompt.d.ts +0 -1
  47. package/lib/prompts/feedbackPrompt.js +0 -39
  48. package/lib/prompts/folderOverwritePrompt.d.ts +0 -1
  49. package/lib/prompts/folderOverwritePrompt.js +0 -17
  50. package/lib/regex.d.ts +0 -1
  51. package/lib/regex.js +0 -4
  52. /package/lib/{debugInfo.d.ts → ProjectLogsManager.d.ts} +0 -0
  53. /package/lib/{projectLogsManager.js → ProjectLogsManager.js} +0 -0
  54. /package/lib/{generate-selectors.d.ts → generateSelectors.d.ts} +0 -0
  55. /package/lib/{generate-selectors.js → generateSelectors.js} +0 -0
  56. /package/lib/{marketplace-validate.d.ts → marketplaceValidate.d.ts} +0 -0
  57. /package/lib/{marketplace-validate.js → marketplaceValidate.js} +0 -0
package/commands/auth.js CHANGED
@@ -15,7 +15,6 @@ const { personalAccessKeyPrompt, OAUTH_FLOW, } = require('../lib/prompts/persona
15
15
  const { cliAccountNamePrompt } = require('../lib/prompts/accountNamePrompt');
16
16
  const { setAsDefaultAccountPrompt, } = require('../lib/prompts/setAsDefaultAccountPrompt');
17
17
  const { addConfigOptions, setLogLevel, getAccountId, addTestingOptions, } = require('../lib/commonOpts');
18
- const { logDebugInfo } = require('../lib/debugInfo');
19
18
  const { trackAuthAction, trackCommandUsage } = require('../lib/usageTracking');
20
19
  const { authenticateWithOauth } = require('../lib/oauth');
21
20
  const { EXIT_CODES } = require('../lib/enums/exitCodes');
@@ -40,7 +39,6 @@ exports.handler = async (options) => {
40
39
  const { type, config: c, qa, account } = options;
41
40
  const authType = (type && type.toLowerCase()) || PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
42
41
  setLogLevel(options);
43
- logDebugInfo(options);
44
42
  if (!getConfigPath(c)) {
45
43
  logger.error(i18n(`${i18nKey}.errors.noConfigFileFound`));
46
44
  process.exit(EXIT_CODES.ERROR);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // @ts-nocheck
4
4
  const { createApiSamplePrompt, } = require('../../lib/prompts/createApiSamplePrompt');
5
- const { folderOverwritePrompt, } = require('../../lib/prompts/folderOverwritePrompt');
5
+ const { confirmPrompt } = require('../../lib/prompts/promptUtils');
6
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
7
7
  const path = require('path');
8
8
  const fs = require('fs-extra');
@@ -22,7 +22,7 @@ module.exports = {
22
22
  execute: async ({ dest, name, assetType, options }) => {
23
23
  const filePath = path.join(dest, name);
24
24
  if (fs.existsSync(filePath)) {
25
- const { overwrite } = await folderOverwritePrompt(filePath);
25
+ const overwrite = await confirmPrompt(i18n(`${i18nKey}.folderOverwritePrompt`, { folderName: filePath }), { defaultAnswer: false });
26
26
  if (overwrite) {
27
27
  fs.rmdirSync(filePath, { recursive: true });
28
28
  }
@@ -28,7 +28,6 @@ const fs = require('fs-extra');
28
28
  const { logError } = require('../lib/errorHandlers/index');
29
29
  const { logger } = require('@hubspot/local-dev-lib/logger');
30
30
  const { setLogLevel, getAccountId } = require('../lib/commonOpts');
31
- const { logDebugInfo } = require('../lib/debugInfo');
32
31
  const { resolveLocalPath } = require('../lib/filesystem');
33
32
  const { trackCommandUsage } = require('../lib/usageTracking');
34
33
  const assets = require('./create/index');
@@ -45,7 +44,6 @@ exports.handler = async (options) => {
45
44
  let { type: assetType, dest } = options;
46
45
  const { name, internal: getInternalVersion } = options;
47
46
  setLogLevel(options);
48
- logDebugInfo(options);
49
47
  assetType = typeof assetType === 'string' && assetType.toLowerCase();
50
48
  if (assetType === 'global-partial') {
51
49
  logger.error(i18n(`${i18nKey}.errors.deprecatedAssetType`, {
@@ -3,17 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // @ts-nocheck
4
4
  const open = require('open');
5
5
  const { i18n } = require('../lib/lang');
6
- const { FEEDBACK_URLS } = require('../lib/constants');
7
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
8
- const { feedbackTypePrompt, shouldOpenBrowserPrompt, } = require('../lib/prompts/feedbackPrompt');
7
+ const { confirmPrompt, listPrompt } = require('../lib/prompts/promptUtils');
9
8
  const i18nKey = 'commands.project.subcommands.feedback';
9
+ const FEEDBACK_OPTIONS = {
10
+ BUG: 'bug',
11
+ GENERAL: 'general',
12
+ };
13
+ const FEEDBACK_URLS = {
14
+ BUG: 'https://github.com/HubSpot/hubspot-cli/issues/new',
15
+ GENERAL: 'https://docs.google.com/forms/d/e/1FAIpQLSejZZewYzuH3oKBU01tseX-cSWOUsTHLTr-YsiMGpzwcvgIMg/viewform?usp=sf_link',
16
+ };
10
17
  exports.command = 'feedback';
11
18
  exports.describe = i18n(`${i18nKey}.describe`);
12
19
  exports.handler = async (options) => {
13
20
  const { bug: bugFlag, general: generalFlag } = options;
14
21
  const usedTypeFlag = bugFlag !== generalFlag;
15
- const { type } = await feedbackTypePrompt(usedTypeFlag);
16
- const { shouldOpen } = await shouldOpenBrowserPrompt(type, usedTypeFlag);
22
+ await listPrompt(i18n(`${i18nKey}.feedbackType.prompt`), {
23
+ choices: Object.values(FEEDBACK_OPTIONS).map(option => ({
24
+ name: i18n(`${i18nKey}.feedbackType.${option}`),
25
+ value: option,
26
+ })),
27
+ when: !usedTypeFlag,
28
+ });
29
+ const shouldOpen = await confirmPrompt(i18n(`${i18nKey}.openPrompt`), {
30
+ when: !usedTypeFlag,
31
+ });
17
32
  if (shouldOpen || usedTypeFlag) {
18
33
  // NOTE: for now, all feedback should go to the hubspot-cli repository
19
34
  const url = FEEDBACK_URLS.BUG;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // @ts-nocheck
4
+ const moment = require('moment');
4
5
  const { getRoutes } = require('@hubspot/local-dev-lib/api/functions');
5
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
6
- const moment = require('moment');
7
7
  const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
8
8
  const { getTableContents, getTableHeader } = require('../../lib/ui/table');
9
9
  const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
package/commands/init.js CHANGED
@@ -21,7 +21,6 @@ const { setLogLevel, addTestingOptions } = require('../lib/commonOpts');
21
21
  const { promptUser } = require('../lib/prompts/promptUtils');
22
22
  const { OAUTH_FLOW, personalAccessKeyPrompt, } = require('../lib/prompts/personalAccessKeyPrompt');
23
23
  const { cliAccountNamePrompt } = require('../lib/prompts/accountNamePrompt');
24
- const { logDebugInfo } = require('../lib/debugInfo');
25
24
  const { authenticateWithOauth } = require('../lib/oauth');
26
25
  const { EXIT_CODES } = require('../lib/enums/exitCodes');
27
26
  const { uiFeatureHighlight } = require('../lib/ui');
@@ -71,7 +70,6 @@ exports.handler = async (options) => {
71
70
  const { auth: authType = PERSONAL_ACCESS_KEY_AUTH_METHOD.value, c, account: optionalAccount, } = options;
72
71
  const configPath = (c && path.join(getCwd(), c)) || getConfigPath();
73
72
  setLogLevel(options);
74
- logDebugInfo(options);
75
73
  trackCommandUsage('init', {
76
74
  authType,
77
75
  });
package/commands/lint.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // @ts-nocheck
4
4
  const { lint } = require('@hubspot/local-dev-lib/cms/validate');
5
- const { printHublValidationResult } = require('../lib/hublValidate');
6
5
  const { logger } = require('@hubspot/local-dev-lib/logger');
7
6
  const { logError } = require('../lib/errorHandlers/index');
8
7
  const { addConfigOptions, addAccountOptions, getAccountId, } = require('../lib/commonOpts');
@@ -15,6 +14,34 @@ const { EXIT_CODES } = require('../lib/enums/exitCodes');
15
14
  exports.command = 'lint <path>';
16
15
  // Hiding since this command is still experimental
17
16
  exports.describe = null; //'Lint a file or folder for HubL syntax';
17
+ function getErrorsFromHublValidationObject(validation) {
18
+ return ((validation && validation.meta && validation.meta.template_errors) || []);
19
+ }
20
+ function printHublValidationError(err) {
21
+ const { severity, message, lineno, startPosition } = err;
22
+ const method = severity === 'FATAL' ? 'error' : 'warn';
23
+ logger[method]('[%d, %d]: %s', lineno, startPosition, message);
24
+ }
25
+ function printHublValidationResult({ file, validation }) {
26
+ let count = 0;
27
+ if (!validation) {
28
+ return count;
29
+ }
30
+ const errors = getErrorsFromHublValidationObject(validation);
31
+ if (!errors.length) {
32
+ return count;
33
+ }
34
+ logger.group(file);
35
+ errors.forEach(err => {
36
+ if (err.reason !== 'SYNTAX_ERROR') {
37
+ return;
38
+ }
39
+ ++count;
40
+ printHublValidationError(err);
41
+ });
42
+ logger.groupEnd();
43
+ return count;
44
+ }
18
45
  exports.handler = async (options) => {
19
46
  const { path: lintPath } = options;
20
47
  await loadAndValidateOptions(options);
@@ -5,7 +5,7 @@ const SpinniesManager = require('../../lib/ui/SpinniesManager');
5
5
  const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
6
6
  const { loadAndValidateOptions } = require('../../lib/validation');
7
7
  const { trackCommandUsage } = require('../../lib/usageTracking');
8
- const { kickOffValidation, pollForValidationFinish, fetchValidationResults, processValidationErrors, displayValidationResults, } = require('../../lib/marketplace-validate');
8
+ const { kickOffValidation, pollForValidationFinish, fetchValidationResults, processValidationErrors, displayValidationResults, } = require('../../lib/marketplaceValidate');
9
9
  const { i18n } = require('../../lib/lang');
10
10
  const i18nKey = 'commands.module.subcommands.marketplaceValidate';
11
11
  exports.command = 'marketplace-validate <src>';
@@ -10,14 +10,14 @@ const { deployProject, fetchProject, } = require('@hubspot/local-dev-lib/api/pro
10
10
  const { loadAndValidateOptions } = require('../../lib/validation');
11
11
  const { getProjectConfig, pollDeployStatus, getProjectDetailUrl, } = require('../../lib/projects');
12
12
  const { projectNamePrompt } = require('../../lib/prompts/projectNamePrompt');
13
- const { deployBuildIdPrompt, } = require('../../lib/prompts/deployBuildIdPrompt');
13
+ const { promptUser } = require('../../lib/prompts/promptUtils');
14
14
  const { i18n } = require('../../lib/lang');
15
15
  const { uiBetaTag, uiLink } = require('../../lib/ui');
16
16
  const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
17
- const i18nKey = 'commands.project.subcommands.deploy';
18
17
  const { EXIT_CODES } = require('../../lib/enums/exitCodes');
19
18
  const { uiCommandReference, uiAccountDescription } = require('../../lib/ui');
20
19
  const { isHubSpotHttpError } = require('@hubspot/local-dev-lib/errors/index');
20
+ const i18nKey = 'commands.project.subcommands.deploy';
21
21
  exports.command = 'deploy';
22
22
  exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
23
23
  const validateBuildId = (buildId, deployedBuildId, latestBuildId, projectName, accountId) => {
@@ -69,7 +69,14 @@ exports.handler = async (options) => {
69
69
  }
70
70
  }
71
71
  else {
72
- const deployBuildIdPromptResponse = await deployBuildIdPrompt(latestBuild.buildId, deployedBuildId, buildId => validateBuildId(buildId, deployedBuildId, latestBuild.buildId, projectName, accountId));
72
+ const deployBuildIdPromptResponse = await promptUser({
73
+ name: 'buildId',
74
+ message: i18n(`${i18nKey}.deployBuildIdPrompt`),
75
+ default: latestBuild.buildId === deployedBuildId
76
+ ? undefined
77
+ : latestBuild.buildId,
78
+ validate: () => validateBuildId(buildId, deployedBuildId, latestBuild.buildId, projectName, accountId),
79
+ });
73
80
  buildIdToDeploy = deployBuildIdPromptResponse.buildId;
74
81
  }
75
82
  if (!buildIdToDeploy) {
@@ -14,7 +14,7 @@ const { uiBetaTag, uiLine, uiLink } = require('../../lib/ui');
14
14
  const { projectLogsPrompt } = require('../../lib/prompts/projectsLogsPrompt');
15
15
  const { i18n } = require('../../lib/lang');
16
16
  const { EXIT_CODES } = require('../../lib/enums/exitCodes');
17
- const ProjectLogsManager = require('../../lib/projectLogsManager');
17
+ const ProjectLogsManager = require('../../lib/ProjectLogsManager');
18
18
  const i18nKey = 'commands.project.subcommands.logs';
19
19
  const getPrivateAppsUrl = accountId => {
20
20
  const baseUrl = getHubSpotWebsiteOrigin(getEnv(accountId) === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD);
@@ -11,7 +11,7 @@ const { deleteSandbox } = require('@hubspot/local-dev-lib/api/sandboxHubs');
11
11
  const { i18n } = require('../../lib/lang');
12
12
  const { deleteSandboxPrompt } = require('../../lib/prompts/sandboxesPrompt');
13
13
  const { getConfig, getEnv, removeSandboxAccountFromConfig, updateDefaultAccount, } = require('@hubspot/local-dev-lib/config');
14
- const { selectAndSetAsDefaultAccountPrompt, } = require('../../lib/prompts/accountsPrompt');
14
+ const { selectAccountFromConfig } = require('../../lib/prompts/accountsPrompt');
15
15
  const { EXIT_CODES } = require('../../lib/enums/exitCodes');
16
16
  const { promptUser } = require('../../lib/prompts/promptUtils');
17
17
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
@@ -113,7 +113,8 @@ exports.handler = async (options) => {
113
113
  logger.log('');
114
114
  const promptDefaultAccount = removeSandboxAccountFromConfig(sandboxAccountId);
115
115
  if (promptDefaultAccount && !force) {
116
- await selectAndSetAsDefaultAccountPrompt(getConfig());
116
+ const newDefaultAccount = await selectAccountFromConfig(getConfig());
117
+ updateDefaultAccount(newDefaultAccount);
117
118
  }
118
119
  else {
119
120
  // If force is specified, skip prompt and set the parent account id as the default account
@@ -155,7 +156,8 @@ exports.handler = async (options) => {
155
156
  logger.log('');
156
157
  const promptDefaultAccount = removeSandboxAccountFromConfig(sandboxAccountId);
157
158
  if (promptDefaultAccount && !force) {
158
- await selectAndSetAsDefaultAccountPrompt(getConfig());
159
+ const newDefaultAccount = await selectAccountFromConfig(getConfig());
160
+ updateDefaultAccount(newDefaultAccount);
159
161
  }
160
162
  else {
161
163
  // If force is specified, skip prompt and set the parent account id as the default account
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const fs = require('fs');
5
5
  const { i18n } = require('../../lib/lang');
6
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
7
- const { findFieldsJsonPath, combineThemeCss, setPreviewSelectors, generateInheritedSelectors, generateSelectorsMap, getMaxFieldsDepth, } = require('../../lib/generate-selectors');
7
+ const { findFieldsJsonPath, combineThemeCss, setPreviewSelectors, generateInheritedSelectors, generateSelectorsMap, getMaxFieldsDepth, } = require('../../lib/generateSelectors');
8
8
  const { EXIT_CODES } = require('../../lib/enums/exitCodes');
9
9
  const HUBL_EXPRESSION_REGEX = new RegExp(/{%\s*(.*)\s*%}/, 'g');
10
10
  const HUBL_VARIABLE_NAME_REGEX = new RegExp(/{%\s*set\s*(\w*)/, 'i');
@@ -5,7 +5,7 @@ const SpinniesManager = require('../../lib/ui/SpinniesManager');
5
5
  const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
6
6
  const { loadAndValidateOptions } = require('../../lib/validation');
7
7
  const { trackCommandUsage } = require('../../lib/usageTracking');
8
- const { kickOffValidation, pollForValidationFinish, fetchValidationResults, processValidationErrors, displayValidationResults, } = require('../../lib/marketplace-validate');
8
+ const { kickOffValidation, pollForValidationFinish, fetchValidationResults, processValidationErrors, displayValidationResults, } = require('../../lib/marketplaceValidate');
9
9
  const { i18n } = require('../../lib/lang');
10
10
  const i18nKey = 'commands.theme.subcommands.marketplaceValidate';
11
11
  exports.command = 'marketplace-validate <src>';
package/lang/en.lyaml CHANGED
@@ -178,6 +178,7 @@ en:
178
178
  describe: "Type of asset"
179
179
  subcommands:
180
180
  apiSample:
181
+ folderOverwritePrompt: "The folder with name \"{{ folderName }}\" already exists. Overwrite?"
181
182
  errors:
182
183
  nameRequired: "The \"name\" argument is required when creating an API Sample."
183
184
  noSamples: "Currently there are no samples available, please, try again later."
@@ -570,6 +571,7 @@ en:
570
571
  withFlags: "Use --name and --type flags to bypass the prompt."
571
572
  deploy:
572
573
  describe: "Deploy a project build"
574
+ deployBuildIdPrompt: "[--build] Deploy which build?"
573
575
  debug:
574
576
  deploying: "Deploying project at path: {{ path }}"
575
577
  errors:
@@ -702,6 +704,11 @@ en:
702
704
  success: "Successfully opened \"{{ projectName }}\""
703
705
  feedback:
704
706
  describe: "Leave feedback on HubSpot projects or file a bug report"
707
+ feedbackType:
708
+ prompt: "What type of feedback would you like to leave?"
709
+ bug: "[--bug] Report a bug"
710
+ general: "[--general] Tell us about your experience with HubSpot's developer tools"
711
+ openPrompt: "Create a Github issue in your browser?"
705
712
  success: "We opened {{ url }} in your browser."
706
713
  options:
707
714
  bug:
@@ -999,6 +1006,7 @@ en:
999
1006
  installCount: "{{#bold}}The app {{ appName }} has {{ installCount }} production {{ installText }}{{/bold}}"
1000
1007
  explanation: "Some changes made during local development may need to be synced to HubSpot, which will impact those existing installs. We strongly recommend creating a copy of this app to use instead."
1001
1008
  confirmation: "You will always be asked to confirm any permanent changes to your app’s configuration before uploading them."
1009
+ confirmationPrompt: "Proceed with local development of this {{#bold}}production{{/bold}} app?"
1002
1010
  devServer:
1003
1011
  cleanupError: "Failed to cleanup local dev server: {{ message }}"
1004
1012
  setupError: "Failed to setup local dev server: {{ message }}"
@@ -1193,8 +1201,6 @@ en:
1193
1201
  invalidOauthClientSecretCopy: "Please copy the actual OAuth2 client secret rather than the asterisks that mask it."
1194
1202
  invalidPersonalAccessKey: "You did not enter a valid access key. Please try again."
1195
1203
  invalidPersonalAccessKeyCopy: "Please copy the actual access key rather than the bullets that mask it."
1196
- folderOverwritePrompt:
1197
- overwriteConfirm: "The folder with name \"{{ folderName }}\" already exists. Overwrite?"
1198
1204
  createTemplatePrompt:
1199
1205
  selectTemplate: "Select the type of template to create"
1200
1206
  createModulePrompt:
@@ -1276,15 +1282,6 @@ en:
1276
1282
  errors:
1277
1283
  invalidName: "You entered an invalid name. Please try again."
1278
1284
  projectDoesNotExist: "Project {{#bold}}{{ projectName }}{{/bold}} could not be found in \"{{ accountIdentifier }}\""
1279
- feedbackPrompt:
1280
- feedbackType:
1281
- message: "What type of feedback would you like to leave?"
1282
- bug: "[--bug] Report a bug"
1283
- general: "[--general] Tell us about your experience with HubSpot's developer tools"
1284
- bugPrompt: "Create an issue on Github in your browser?"
1285
- generalPrompt: "Create an issue on Github in your browser?"
1286
- deployBuildIdPrompt:
1287
- enterBuildId: "[--build] Deploy which build?"
1288
1285
  previewPrompt:
1289
1286
  enterSrc: "[--src] Enter a local theme directory to preview."
1290
1287
  enterDest: "[--dest] Enter the destination path for the src theme in HubSpot Design Tools."
@@ -1300,8 +1297,6 @@ en:
1300
1297
  prompt: "Open hubspot.com to install this app?"
1301
1298
  reinstallPrompt: "Open hubspot.com to reinstall this app?"
1302
1299
  decline: "To continue local development of this app, install it in your target test account and re-run {{#bold}}`hs project dev`{{/bold}}"
1303
- activeInstallConfirmationPrompt:
1304
- message: "Proceed with local development of this {{#bold}}production{{/bold}} app?"
1305
1300
  convertFields:
1306
1301
  positionals:
1307
1302
  src:
@@ -20,7 +20,7 @@ const { CONFIG_FILES, COMPONENT_TYPES, getAppCardConfigs, } = require('./project
20
20
  const { UI_COLORS, uiCommandReference, uiAccountDescription, uiBetaTag, uiLink, uiLine, } = require('./ui');
21
21
  const { logError } = require('./errorHandlers/index');
22
22
  const { installPublicAppPrompt } = require('./prompts/installPublicAppPrompt');
23
- const { activeInstallConfirmationPrompt, } = require('./prompts/activeInstallConfirmationPrompt');
23
+ const { confirmPrompt } = require('./prompts/promptUtils');
24
24
  const WATCH_EVENTS = {
25
25
  add: 'add',
26
26
  change: 'change',
@@ -98,7 +98,7 @@ class LocalDevManager {
98
98
  }));
99
99
  logger.log(i18n(`${i18nKey}.activeInstallWarning.explanation`));
100
100
  uiLine();
101
- const proceed = await activeInstallConfirmationPrompt();
101
+ const proceed = await confirmPrompt(i18n(`${i18nKey}.activeInstallWarning.confirmationPrompt`), { defaultAnswer: false });
102
102
  if (!proceed) {
103
103
  process.exit(EXIT_CODES.SUCCESS);
104
104
  }
@@ -1 +1,26 @@
1
- export {};
1
+ import { Argv, Arguments } from 'yargs';
2
+ export declare function addAccountOptions(yargs: Argv): Argv;
3
+ export declare function addConfigOptions(yargs: Argv): Argv;
4
+ export declare function addOverwriteOptions(yargs: Argv): Argv;
5
+ export declare function addModeOptions(yargs: Argv, { read, write }: {
6
+ read?: boolean;
7
+ write?: boolean;
8
+ }): Argv;
9
+ export declare function addTestingOptions(yargs: Argv): Argv;
10
+ export declare function addUseEnvironmentOptions(yargs: Argv): Argv;
11
+ export declare function setLogLevel(options: Arguments<{
12
+ debug?: boolean;
13
+ }>): void;
14
+ export declare function getCommandName(argv: Arguments<{
15
+ _?: string[];
16
+ }>): string;
17
+ /**
18
+ * Obtains accountId using supplied --account flag or from environment variables
19
+ */
20
+ export declare function getAccountId(options: Arguments<{
21
+ portal?: number | string;
22
+ account?: number | string;
23
+ }>): number | null;
24
+ export declare function getMode(options: Arguments<{
25
+ mode?: string;
26
+ }>): string;
package/lib/commonOpts.js CHANGED
@@ -1,89 +1,106 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { LOG_LEVEL, setLogLevel: setLoggerLogLevel, } = require('@hubspot/local-dev-lib/logger');
5
- const { DEFAULT_MODE, MODE, } = require('@hubspot/local-dev-lib/constants/files');
6
- const { getAccountId: getAccountIdFromConfig, getAccountConfig, getAndLoadConfigIfNeeded, } = require('@hubspot/local-dev-lib/config');
7
- const { i18n } = require('./lang');
3
+ exports.addAccountOptions = addAccountOptions;
4
+ exports.addConfigOptions = addConfigOptions;
5
+ exports.addOverwriteOptions = addOverwriteOptions;
6
+ exports.addModeOptions = addModeOptions;
7
+ exports.addTestingOptions = addTestingOptions;
8
+ exports.addUseEnvironmentOptions = addUseEnvironmentOptions;
9
+ exports.setLogLevel = setLogLevel;
10
+ exports.getCommandName = getCommandName;
11
+ exports.getAccountId = getAccountId;
12
+ exports.getMode = getMode;
13
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
14
+ const files_1 = require("@hubspot/local-dev-lib/constants/files");
15
+ const config_1 = require("@hubspot/local-dev-lib/config");
16
+ const lang_1 = require("./lang");
8
17
  const i18nKey = 'lib.commonOpts';
9
- const addAccountOptions = program => program.option('portal', {
10
- alias: ['p', 'account', 'a'],
11
- describe: i18n(`${i18nKey}.options.portal.describe`),
12
- type: 'string',
13
- });
14
- const addConfigOptions = yargs => yargs.option('config', {
15
- alias: 'c',
16
- describe: i18n(`${i18nKey}.options.config.describe`),
17
- type: 'string',
18
- });
19
- const addOverwriteOptions = yargs => yargs.option('overwrite', {
20
- alias: 'o',
21
- describe: i18n(`${i18nKey}.options.overwrite.describe`),
22
- type: 'boolean',
23
- default: false,
24
- });
25
- const addModeOptions = (yargs, { read, write }) => {
26
- const modes = `<${Object.values(MODE).join(' | ')}>`;
18
+ function addAccountOptions(yargs) {
19
+ return yargs.option('portal', {
20
+ alias: ['p', 'account', 'a'],
21
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.portal.describe`),
22
+ type: 'string',
23
+ });
24
+ }
25
+ function addConfigOptions(yargs) {
26
+ return yargs.option('config', {
27
+ alias: 'c',
28
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.config.describe`),
29
+ type: 'string',
30
+ });
31
+ }
32
+ function addOverwriteOptions(yargs) {
33
+ return yargs.option('overwrite', {
34
+ alias: 'o',
35
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.overwrite.describe`),
36
+ type: 'boolean',
37
+ default: false,
38
+ });
39
+ }
40
+ function addModeOptions(yargs, { read, write }) {
41
+ const modes = `<${Object.values(files_1.MODE).join(' | ')}>`;
27
42
  return yargs.option('mode', {
28
43
  alias: 'm',
29
- describe: i18n(`${i18nKey}.options.modes.describe.${read ? 'read' : write ? 'write' : 'default'}`, { modes }),
44
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.modes.describe.${read ? 'read' : write ? 'write' : 'default'}`, { modes }),
30
45
  type: 'string',
31
46
  });
32
- };
33
- const addTestingOptions = yargs => yargs.option('qa', {
34
- describe: i18n(`${i18nKey}.options.qa.describe`),
35
- type: 'boolean',
36
- default: false,
37
- hidden: true,
38
- });
39
- const addUseEnvironmentOptions = yargs => yargs.option('use-env', {
40
- describe: i18n(`${i18nKey}.options.useEnv.describe`),
41
- type: 'boolean',
42
- default: false,
43
- });
44
- const setLogLevel = (options = {}) => {
47
+ }
48
+ function addTestingOptions(yargs) {
49
+ return yargs.option('qa', {
50
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.qa.describe`),
51
+ type: 'boolean',
52
+ default: false,
53
+ hidden: true,
54
+ });
55
+ }
56
+ function addUseEnvironmentOptions(yargs) {
57
+ return yargs.option('use-env', {
58
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.useEnv.describe`),
59
+ type: 'boolean',
60
+ default: false,
61
+ });
62
+ }
63
+ function setLogLevel(options) {
45
64
  const { debug } = options;
46
65
  if (debug) {
47
- setLoggerLogLevel(LOG_LEVEL.DEBUG);
66
+ (0, logger_1.setLogLevel)(logger_1.LOG_LEVEL.DEBUG);
48
67
  }
49
68
  else {
50
- setLoggerLogLevel(LOG_LEVEL.LOG);
69
+ (0, logger_1.setLogLevel)(logger_1.LOG_LEVEL.LOG);
51
70
  }
52
- };
53
- /**
54
- * Get command name from Yargs `argv`
55
- * @param {object} argv
56
- */
57
- const getCommandName = argv => (argv && argv._ && argv._[0]) || '';
71
+ }
72
+ function getCommandName(argv) {
73
+ return (argv && argv._ && argv._[0]) || '';
74
+ }
58
75
  /**
59
76
  * Obtains accountId using supplied --account flag or from environment variables
60
77
  */
61
- const getAccountId = (options = {}) => {
78
+ function getAccountId(options) {
62
79
  const { portal, account } = options;
63
80
  if (options.useEnv && process.env.HUBSPOT_PORTAL_ID) {
64
81
  return parseInt(process.env.HUBSPOT_PORTAL_ID, 10);
65
82
  }
66
- return getAccountIdFromConfig(portal || account);
67
- };
68
- const getMode = (command = {}) => {
83
+ return (0, config_1.getAccountId)(portal || account);
84
+ }
85
+ function getMode(options) {
69
86
  // 1. --mode
70
- const { mode } = command;
87
+ const { mode } = options;
71
88
  if (mode && typeof mode === 'string') {
72
89
  return mode.toLowerCase();
73
90
  }
74
91
  // 2. config[portal].defaultMode
75
- const accountId = getAccountId(command);
92
+ const accountId = getAccountId(options);
76
93
  if (accountId) {
77
- const accountConfig = getAccountConfig(accountId);
94
+ const accountConfig = (0, config_1.getAccountConfig)(accountId);
78
95
  if (accountConfig && accountConfig.defaultMode) {
79
96
  return accountConfig.defaultMode;
80
97
  }
81
98
  }
82
99
  // 3. config.defaultMode
83
100
  // 4. DEFAULT_MODE
84
- const config = getAndLoadConfigIfNeeded();
85
- return (config && config.defaultMode) || DEFAULT_MODE;
86
- };
101
+ const config = (0, config_1.getAndLoadConfigIfNeeded)();
102
+ return (config && config.defaultMode) || files_1.DEFAULT_MODE;
103
+ }
87
104
  module.exports = {
88
105
  addAccountOptions,
89
106
  addConfigOptions,
@@ -1,13 +1,5 @@
1
1
  export declare const HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH: "HubSpot/hubspot-project-components";
2
2
  export declare const DEFAULT_PROJECT_TEMPLATE_BRANCH: "main";
3
- export declare const FEEDBACK_OPTIONS: {
4
- readonly BUG: "bug";
5
- readonly GENERAL: "general";
6
- };
7
- export declare const FEEDBACK_URLS: {
8
- readonly BUG: "https://github.com/HubSpot/hubspot-cli/issues/new";
9
- readonly GENERAL: "https://docs.google.com/forms/d/e/1FAIpQLSejZZewYzuH3oKBU01tseX-cSWOUsTHLTr-YsiMGpzwcvgIMg/viewform?usp=sf_link";
10
- };
11
3
  export declare const FEEDBACK_INTERVAL: 10;
12
4
  export declare const HUBSPOT_FOLDER: "@hubspot";
13
5
  export declare const MARKETPLACE_FOLDER: "@marketplace";
package/lib/constants.js CHANGED
@@ -1,16 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.POLLING_STATUS = exports.POLLING_DELAY = exports.CONFIG_FLAGS = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.FEEDBACK_URLS = exports.FEEDBACK_OPTIONS = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
3
+ exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.POLLING_STATUS = exports.POLLING_DELAY = exports.CONFIG_FLAGS = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
4
4
  exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = 'HubSpot/hubspot-project-components';
5
5
  exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = 'main';
6
- exports.FEEDBACK_OPTIONS = {
7
- BUG: 'bug',
8
- GENERAL: 'general',
9
- };
10
- exports.FEEDBACK_URLS = {
11
- BUG: 'https://github.com/HubSpot/hubspot-cli/issues/new',
12
- GENERAL: 'https://docs.google.com/forms/d/e/1FAIpQLSejZZewYzuH3oKBU01tseX-cSWOUsTHLTr-YsiMGpzwcvgIMg/viewform?usp=sf_link',
13
- };
14
6
  exports.FEEDBACK_INTERVAL = 10;
15
7
  exports.HUBSPOT_FOLDER = '@hubspot';
16
8
  exports.MARKETPLACE_FOLDER = '@marketplace';
@@ -1 +1,5 @@
1
+ type InterpolationData = {
2
+ [identifier: string]: string | number;
3
+ };
4
+ export declare function interpolate(stringValue: string, interpolationData: InterpolationData): string;
1
5
  export {};