@hubspot/cli 6.2.2-experimental.1 → 6.2.2-experimental.2

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 (89) hide show
  1. package/bin/cli.js +2 -0
  2. package/commands/auth.js +0 -2
  3. package/commands/create/api-sample.js +2 -2
  4. package/commands/create.js +0 -2
  5. package/commands/doctor.d.ts +8 -0
  6. package/commands/doctor.js +60 -0
  7. package/commands/feedback.js +19 -4
  8. package/commands/functions/list.js +1 -1
  9. package/commands/init.js +20 -9
  10. package/commands/lint.d.ts +4 -1
  11. package/commands/lint.js +39 -3
  12. package/commands/module/marketplace-validate.js +1 -1
  13. package/commands/project/deploy.js +10 -3
  14. package/commands/project/installDeps.js +5 -5
  15. package/commands/project/logs.js +2 -2
  16. package/commands/sandbox/delete.js +5 -3
  17. package/commands/theme/generate-selectors.js +1 -1
  18. package/commands/theme/marketplace-validate.js +1 -1
  19. package/lang/en.lyaml +75 -13
  20. package/lib/DevServerManager.js +2 -5
  21. package/lib/LocalDevManager.js +2 -2
  22. package/lib/commonOpts.d.ts +27 -1
  23. package/lib/commonOpts.js +74 -57
  24. package/lib/constants.d.ts +0 -8
  25. package/lib/constants.js +1 -9
  26. package/lib/dependencyManagement.d.ts +3 -1
  27. package/lib/dependencyManagement.js +19 -0
  28. package/lib/doctor/Diagnosis.d.ts +27 -0
  29. package/lib/doctor/Diagnosis.js +119 -0
  30. package/lib/doctor/DiagnosticInfoBuilder.d.ts +61 -0
  31. package/lib/doctor/DiagnosticInfoBuilder.js +158 -0
  32. package/lib/doctor/Doctor.d.ts +21 -0
  33. package/lib/doctor/Doctor.js +328 -0
  34. package/lib/interpolation.d.ts +7 -0
  35. package/lib/interpolation.js +41 -48
  36. package/lib/lang.d.ts +8 -0
  37. package/lib/lang.js +37 -32
  38. package/lib/process.d.ts +11 -0
  39. package/lib/process.js +16 -16
  40. package/lib/projects.d.ts +4 -1
  41. package/lib/projects.js +5 -3
  42. package/lib/prompts/accountNamePrompt.js +1 -2
  43. package/lib/prompts/accountsPrompt.js +0 -17
  44. package/lib/prompts/createFunctionPrompt.js +3 -4
  45. package/lib/prompts/promptUtils.d.ts +12 -1
  46. package/lib/prompts/promptUtils.js +24 -13
  47. package/lib/ui/SpinniesManager.d.ts +39 -1
  48. package/lib/ui/SpinniesManager.js +66 -35
  49. package/lib/ui/git.d.ts +1 -1
  50. package/lib/ui/git.js +17 -17
  51. package/lib/ui/index.d.ts +16 -1
  52. package/lib/ui/index.js +87 -114
  53. package/lib/ui/serverlessFunctionLogs.js +25 -20
  54. package/lib/ui/spinniesUtils.d.ts +31 -0
  55. package/lib/ui/spinniesUtils.js +45 -31
  56. package/lib/ui/supportHyperlinks.d.ts +6 -0
  57. package/lib/ui/supportHyperlinks.js +10 -10
  58. package/lib/ui/supportsColor.d.ts +16 -0
  59. package/lib/ui/supportsColor.js +19 -17
  60. package/lib/ui/table.d.ts +3 -1
  61. package/lib/ui/table.js +17 -11
  62. package/lib/usageTracking.d.ts +2 -1
  63. package/lib/usageTracking.js +12 -1
  64. package/lib/validation.js +0 -2
  65. package/package.json +7 -3
  66. package/lib/debugInfo.js +0 -20
  67. package/lib/environment.d.ts +0 -1
  68. package/lib/environment.js +0 -13
  69. package/lib/hublValidate.d.ts +0 -2
  70. package/lib/hublValidate.js +0 -32
  71. package/lib/interpolationHelpers.d.ts +0 -10
  72. package/lib/interpolationHelpers.js +0 -34
  73. package/lib/projectLogsManager.d.ts +0 -1
  74. package/lib/prompts/activeInstallConfirmationPrompt.d.ts +0 -1
  75. package/lib/prompts/activeInstallConfirmationPrompt.js +0 -20
  76. package/lib/prompts/deployBuildIdPrompt.d.ts +0 -1
  77. package/lib/prompts/deployBuildIdPrompt.js +0 -22
  78. package/lib/prompts/feedbackPrompt.d.ts +0 -1
  79. package/lib/prompts/feedbackPrompt.js +0 -39
  80. package/lib/prompts/folderOverwritePrompt.d.ts +0 -1
  81. package/lib/prompts/folderOverwritePrompt.js +0 -17
  82. package/lib/regex.d.ts +0 -1
  83. package/lib/regex.js +0 -4
  84. /package/lib/{debugInfo.d.ts → ProjectLogsManager.d.ts} +0 -0
  85. /package/lib/{projectLogsManager.js → ProjectLogsManager.js} +0 -0
  86. /package/lib/{generate-selectors.d.ts → generateSelectors.d.ts} +0 -0
  87. /package/lib/{generate-selectors.js → generateSelectors.js} +0 -0
  88. /package/lib/{marketplace-validate.d.ts → marketplaceValidate.d.ts} +0 -0
  89. /package/lib/{marketplace-validate.js → marketplaceValidate.js} +0 -0
package/bin/cli.js CHANGED
@@ -38,6 +38,7 @@ const accountsCommand = require('../commands/accounts');
38
38
  const sandboxesCommand = require('../commands/sandbox');
39
39
  const cmsCommand = require('../commands/cms');
40
40
  const feedbackCommand = require('../commands/feedback');
41
+ const doctorCommand = require('../commands/doctor');
41
42
  const notifier = updateNotifier({
42
43
  pkg: { ...pkg, name: '@hubspot/cli' },
43
44
  distTag: 'latest',
@@ -167,6 +168,7 @@ const argv = yargs
167
168
  .command(accountsCommand)
168
169
  .command(sandboxesCommand)
169
170
  .command(feedbackCommand)
171
+ .command(doctorCommand)
170
172
  .help()
171
173
  .recommendCommands()
172
174
  .demandCommand(1, '')
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`, {
@@ -0,0 +1,8 @@
1
+ import { ArgumentsCamelCase, BuilderCallback } from 'yargs';
2
+ export interface DoctorOptions {
3
+ 'output-dir'?: string;
4
+ }
5
+ export declare const command = "doctor";
6
+ export declare const describe: any;
7
+ export declare const handler: ({ outputDir, }: ArgumentsCamelCase<DoctorOptions>) => Promise<never>;
8
+ export declare const builder: BuilderCallback<DoctorOptions, DoctorOptions>;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.builder = exports.handler = exports.describe = exports.command = void 0;
7
+ const usageTracking_1 = require("../lib/usageTracking");
8
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const Doctor_1 = require("../lib/doctor/Doctor");
11
+ const exitCodes_1 = require("../lib/enums/exitCodes");
12
+ const path_1 = __importDefault(require("path"));
13
+ const path_2 = require("@hubspot/local-dev-lib/path");
14
+ const { i18n } = require('../lib/lang');
15
+ const i18nKey = 'commands.doctor';
16
+ exports.command = 'doctor';
17
+ exports.describe = i18n(`${i18nKey}.describe`);
18
+ const handler = async ({ outputDir, }) => {
19
+ const doctor = new Doctor_1.Doctor();
20
+ (0, usageTracking_1.trackCommandUsage)(exports.command, undefined, doctor.accountId);
21
+ const output = await doctor.diagnose();
22
+ const totalCount = (output?.errorCount || 0) + (output?.warningCount || 0);
23
+ if (totalCount > 0) {
24
+ (0, usageTracking_1.trackCommandMetadataUsage)(exports.command, { success: false, type: totalCount }, doctor.accountId);
25
+ }
26
+ if (!outputDir) {
27
+ if (output?.diagnosis) {
28
+ logger_1.logger.log(output.diagnosis);
29
+ }
30
+ else {
31
+ logger_1.logger.error(i18n(`${i18nKey}.errors.generatingDiagnosis`));
32
+ return process.exit(exitCodes_1.EXIT_CODES.ERROR);
33
+ }
34
+ return process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
35
+ }
36
+ if (!path_1.default.isAbsolute(outputDir)) {
37
+ outputDir = path_1.default.join((0, path_2.getCwd)(), outputDir);
38
+ }
39
+ const outputFile = path_1.default.join(outputDir, `hubspot-doctor-${new Date().toISOString()}.json`);
40
+ try {
41
+ fs_1.default.writeFileSync(outputFile, JSON.stringify(output, null, 4));
42
+ logger_1.logger.success(i18n(`${i18nKey}.outputWritten`, { filename: outputFile }));
43
+ }
44
+ catch (e) {
45
+ logger_1.logger.error(i18n(`${i18nKey}.errors.unableToWriteOutputFile`, {
46
+ file: outputFile,
47
+ errorMessage: e instanceof Error ? e.message : e,
48
+ }));
49
+ return process.exit(exitCodes_1.EXIT_CODES.ERROR);
50
+ }
51
+ return process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
52
+ };
53
+ exports.handler = handler;
54
+ const builder = yargs => {
55
+ yargs.option('output-dir', {
56
+ describe: i18n(`${i18nKey}.options.outputDir`),
57
+ type: 'string',
58
+ });
59
+ };
60
+ exports.builder = builder;
@@ -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');
@@ -68,13 +67,14 @@ exports.describe = i18n(`${i18nKey}.describe`, {
68
67
  configName: DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
69
68
  });
70
69
  exports.handler = async (options) => {
71
- const { auth: authType = PERSONAL_ACCESS_KEY_AUTH_METHOD.value, c, account: optionalAccount, } = options;
70
+ const { auth: authType = PERSONAL_ACCESS_KEY_AUTH_METHOD.value, c, account: optionalAccount, disableTracking, } = options;
72
71
  const configPath = (c && path.join(getCwd(), c)) || getConfigPath();
73
72
  setLogLevel(options);
74
- logDebugInfo(options);
75
- trackCommandUsage('init', {
76
- authType,
77
- });
73
+ if (!disableTracking) {
74
+ trackCommandUsage('init', {
75
+ authType,
76
+ });
77
+ }
78
78
  const env = options.qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
79
79
  if (fs.existsSync(configPath)) {
80
80
  logger.error(i18n(`${i18nKey}.errors.configFileExists`, {
@@ -83,7 +83,9 @@ exports.handler = async (options) => {
83
83
  logger.info(i18n(`${i18nKey}.logs.updateConfig`));
84
84
  process.exit(EXIT_CODES.ERROR);
85
85
  }
86
- trackAuthAction('init', authType, TRACKING_STATUS.STARTED);
86
+ if (!disableTracking) {
87
+ await trackAuthAction('init', authType, TRACKING_STATUS.STARTED);
88
+ }
87
89
  createEmptyConfigFile({ path: configPath });
88
90
  handleExit(deleteEmptyConfigFile);
89
91
  try {
@@ -104,12 +106,16 @@ exports.handler = async (options) => {
104
106
  account: name || accountId,
105
107
  }));
106
108
  uiFeatureHighlight(['helpCommand', 'authCommand', 'accountsListCommand']);
107
- await trackAuthAction('init', authType, TRACKING_STATUS.COMPLETE, accountId);
109
+ if (!disableTracking) {
110
+ await trackAuthAction('init', authType, TRACKING_STATUS.COMPLETE, accountId);
111
+ }
108
112
  process.exit(EXIT_CODES.SUCCESS);
109
113
  }
110
114
  catch (err) {
111
115
  logError(err);
112
- await trackAuthAction('init', authType, TRACKING_STATUS.ERROR);
116
+ if (!disableTracking) {
117
+ await trackAuthAction('init', authType, TRACKING_STATUS.ERROR);
118
+ }
113
119
  process.exit(EXIT_CODES.ERROR);
114
120
  }
115
121
  };
@@ -131,6 +137,11 @@ exports.builder = yargs => {
131
137
  describe: i18n(`${i18nKey}.options.account.describe`),
132
138
  type: 'string',
133
139
  },
140
+ 'disable-tracking': {
141
+ type: 'boolean',
142
+ hidden: true,
143
+ default: false,
144
+ },
134
145
  });
135
146
  addConfigOptions(yargs);
136
147
  addTestingOptions(yargs);
@@ -1 +1,4 @@
1
- export {};
1
+ export declare const command = "lint <path>";
2
+ export declare const describe: null;
3
+ export declare const handler: (options: any) => Promise<void>;
4
+ export declare const builder: (yargs: any) => any;
package/commands/lint.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builder = exports.handler = exports.describe = exports.command = void 0;
3
4
  // @ts-nocheck
4
5
  const { lint } = require('@hubspot/local-dev-lib/cms/validate');
5
- const { printHublValidationResult } = require('../lib/hublValidate');
6
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
7
7
  const { logError } = require('../lib/errorHandlers/index');
8
8
  const { addConfigOptions, addAccountOptions, getAccountId, } = require('../lib/commonOpts');
@@ -15,7 +15,35 @@ const { EXIT_CODES } = require('../lib/enums/exitCodes');
15
15
  exports.command = 'lint <path>';
16
16
  // Hiding since this command is still experimental
17
17
  exports.describe = null; //'Lint a file or folder for HubL syntax';
18
- exports.handler = async (options) => {
18
+ function getErrorsFromHublValidationObject(validation) {
19
+ return ((validation && validation.meta && validation.meta.template_errors) || []);
20
+ }
21
+ function printHublValidationError(err) {
22
+ const { severity, message, lineno, startPosition } = err;
23
+ const method = severity === 'FATAL' ? 'error' : 'warn';
24
+ logger[method]('[%d, %d]: %s', lineno, startPosition, message);
25
+ }
26
+ function printHublValidationResult({ file, validation }) {
27
+ let count = 0;
28
+ if (!validation) {
29
+ return count;
30
+ }
31
+ const errors = getErrorsFromHublValidationObject(validation);
32
+ if (!errors.length) {
33
+ return count;
34
+ }
35
+ logger.group(file);
36
+ errors.forEach(err => {
37
+ if (err.reason !== 'SYNTAX_ERROR') {
38
+ return;
39
+ }
40
+ ++count;
41
+ printHublValidationError(err);
42
+ });
43
+ logger.groupEnd();
44
+ return count;
45
+ }
46
+ const handler = async (options) => {
19
47
  const { path: lintPath } = options;
20
48
  await loadAndValidateOptions(options);
21
49
  const accountId = getAccountId(options);
@@ -41,7 +69,8 @@ exports.handler = async (options) => {
41
69
  count,
42
70
  }));
43
71
  };
44
- exports.builder = yargs => {
72
+ exports.handler = handler;
73
+ const builder = yargs => {
45
74
  addConfigOptions(yargs);
46
75
  addAccountOptions(yargs);
47
76
  yargs.positional('path', {
@@ -50,3 +79,10 @@ exports.builder = yargs => {
50
79
  });
51
80
  return yargs;
52
81
  };
82
+ exports.builder = builder;
83
+ module.exports = {
84
+ builder: exports.builder,
85
+ handler: exports.handler,
86
+ command: exports.command,
87
+ describe: exports.describe,
88
+ };
@@ -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) {
@@ -10,14 +10,14 @@ const path = require('path');
10
10
  const { i18n } = require('../../lib/lang');
11
11
  const { trackCommandUsage } = require('../../lib/usageTracking');
12
12
  const { getAccountId } = require('../../lib/commonOpts');
13
+ const { uiBetaTag } = require('../../lib/ui');
13
14
  const i18nKey = `commands.project.subcommands.installDeps`;
14
15
  exports.command = 'install-deps [packages..]';
15
- // Intentionally making this null to hide command
16
- exports.describe = null;
17
- // exports.describe = uiBetaTag(i18n(`${i18nKey}.help.describe`), false);
18
- exports.handler = async ({ packages }) => {
16
+ exports.describe = uiBetaTag(i18n(`${i18nKey}.help.describe`), false);
17
+ exports.handler = async (options) => {
18
+ const { packages } = options || {};
19
19
  try {
20
- const accountId = getAccountId();
20
+ const accountId = getAccountId(options);
21
21
  trackCommandUsage('project-install-deps', null, accountId);
22
22
  const projectConfig = await getProjectConfig();
23
23
  if (!projectConfig || !projectConfig.projectDir) {
@@ -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);
@@ -65,7 +65,7 @@ exports.handler = async (options) => {
65
65
  }
66
66
  catch (e) {
67
67
  logError(e, {
68
- accountId: getAccountId(),
68
+ accountId,
69
69
  projectName: ProjectLogsManager.projectName,
70
70
  });
71
71
  return process.exit(EXIT_CODES.ERROR);
@@ -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."
@@ -274,6 +275,14 @@ en:
274
275
  success:
275
276
  update: "Your schema has been updated in account \"{{ accountId }}\""
276
277
  viewAtUrl: "Schema can be viewed at {{ url }}"
278
+ doctor:
279
+ describe: "Retrieve diagnostic information about your local HubSpot configurations."
280
+ options:
281
+ outputDir: "Directory to save a detailed diagnosis JSON file in"
282
+ errors:
283
+ generatingDiagnosis: "Error generating diagnosis"
284
+ unableToWriteOutputFile: "Unable to write output to {{#bold}}{{ file }}{{/bold}}, {{ errorMessage }}"
285
+ outputWritten: "Output written to {{#bold}}{{ filename }}{{/bold}}"
277
286
  fetch:
278
287
  describe: "Fetch a file, directory or module from HubSpot and write to a path on your computer."
279
288
  errors:
@@ -570,6 +579,7 @@ en:
570
579
  withFlags: "Use --name and --type flags to bypass the prompt."
571
580
  deploy:
572
581
  describe: "Deploy a project build"
582
+ deployBuildIdPrompt: "[--build] Deploy which build?"
573
583
  debug:
574
584
  deploying: "Deploying project at path: {{ path }}"
575
585
  errors:
@@ -702,6 +712,11 @@ en:
702
712
  success: "Successfully opened \"{{ projectName }}\""
703
713
  feedback:
704
714
  describe: "Leave feedback on HubSpot projects or file a bug report"
715
+ feedbackType:
716
+ prompt: "What type of feedback would you like to leave?"
717
+ bug: "[--bug] Report a bug"
718
+ general: "[--general] Tell us about your experience with HubSpot's developer tools"
719
+ openPrompt: "Create a Github issue in your browser?"
705
720
  success: "We opened {{ url }} in your browser."
706
721
  options:
707
722
  bug:
@@ -999,6 +1014,7 @@ en:
999
1014
  installCount: "{{#bold}}The app {{ appName }} has {{ installCount }} production {{ installText }}{{/bold}}"
1000
1015
  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
1016
  confirmation: "You will always be asked to confirm any permanent changes to your app’s configuration before uploading them."
1017
+ confirmationPrompt: "Proceed with local development of this {{#bold}}production{{/bold}} app?"
1002
1018
  devServer:
1003
1019
  cleanupError: "Failed to cleanup local dev server: {{ message }}"
1004
1020
  setupError: "Failed to setup local dev server: {{ message }}"
@@ -1193,8 +1209,6 @@ en:
1193
1209
  invalidOauthClientSecretCopy: "Please copy the actual OAuth2 client secret rather than the asterisks that mask it."
1194
1210
  invalidPersonalAccessKey: "You did not enter a valid access key. Please try again."
1195
1211
  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
1212
  createTemplatePrompt:
1199
1213
  selectTemplate: "Select the type of template to create"
1200
1214
  createModulePrompt:
@@ -1276,15 +1290,6 @@ en:
1276
1290
  errors:
1277
1291
  invalidName: "You entered an invalid name. Please try again."
1278
1292
  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
1293
  previewPrompt:
1289
1294
  enterSrc: "[--src] Enter a local theme directory to preview."
1290
1295
  enterDest: "[--dest] Enter the destination path for the src theme in HubSpot Design Tools."
@@ -1300,8 +1305,6 @@ en:
1300
1305
  prompt: "Open hubspot.com to install this app?"
1301
1306
  reinstallPrompt: "Open hubspot.com to reinstall this app?"
1302
1307
  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
1308
  convertFields:
1306
1309
  positionals:
1307
1310
  src:
@@ -1423,3 +1426,62 @@ en:
1423
1426
  portalMissingScope: "Your account does not have access to this action. Talk to an account admin to request it."
1424
1427
  userMissingScope: "You don't have access to this action. Ask an account admin to change your permissions in Users & Teams settings."
1425
1428
  genericMissingScope: "Your access key does not allow this action. Please generate a new access key by running `hs auth personalaccesskey`."
1429
+ doctor:
1430
+ runningDiagnostics: "Running diagnostics..."
1431
+ diagnosticsComplete: "Diagnostics complete"
1432
+ accountChecks:
1433
+ active: "Default account active"
1434
+ inactive: "Default account isn't active"
1435
+ inactiveSecondary: "Run {{ command }} to remove inactive accounts from your CLI config"
1436
+ unableToDetermine: "Unable to determine if the portal is active"
1437
+ pak:
1438
+ invalid: "Personal access key is invalid"
1439
+ invalidSecondary: "To get a new key, run {{ command }}, deactivate your access key, and generate a new one. Then use that new key to authenticate your account."
1440
+ valid: "Personal Access Key is valid. {{ link }}"
1441
+ viewScopes: "View selected scopes"
1442
+ nodeChecks:
1443
+ unableToDetermine: "Unable to determine what version of node is installed"
1444
+ minimumNotMet: "Minimum Node version is not met. Upgrade to {{ nodeVersion }} or higher"
1445
+ success: "node v{{ nodeVersion }} is installed"
1446
+ npmChecks:
1447
+ notInstalled: "npm is not installed"
1448
+ installed: "npm v{{ npmVersion }} is installed"
1449
+ unableToDetermine: "Unable to determine if npm is installed"
1450
+ hsChecks:
1451
+ notLatest: "Version {{ hsVersion }} outdated"
1452
+ notLatestSecondary: "Run {{ command }} to upgrade to the latest version {{ hsVersion }}"
1453
+ latest: "HubSpot CLI v{{ hsVersion }} up to date"
1454
+ unableToDetermine: "Unable to determine if HubSpot CLI is up to date."
1455
+ unableToDetermineSecondary: "Run {{ command }} to check your installed version; then visit the {{ link }} to validate whether you have the latest version"
1456
+ unableToDetermineSecondaryLink: "npm HubSpot CLI version history"
1457
+ projectDependenciesChecks:
1458
+ missingDependencies: "missing dependencies in {{#bold}}{{ dir }}{{/bold}}"
1459
+ missingDependenciesSecondary: "Run {{ command }} to install all project dependencies locally"
1460
+ unableToDetermine: "Unable to determine if dependencies are installed {{ dir }}"
1461
+ success: "App dependencies are installed and up to date"
1462
+ files:
1463
+ invalidJson: "invalid JSON in {{#bold}}{{ filename }}{{/bold}}"
1464
+ validJson: "JSON files valid"
1465
+ port:
1466
+ inUse: "Port {{ port }} is in use"
1467
+ inUseSecondary: "Make sure it is available if before running {{ command }}"
1468
+ available: "Port {{ port }} available for local development"
1469
+ diagnosis:
1470
+ cli:
1471
+ header: "HubSpot CLI install"
1472
+ cliConfig:
1473
+ header: "CLI configuration"
1474
+ configFileSubHeader: "Config File: {{#bold}}{{ filename }}{{/bold}}"
1475
+ defaultAccountSubHeader: "Default Account: {{accountDetails}}"
1476
+ noConfigFile: "CLI configuration not found"
1477
+ noConfigFileSecondary: "Run {{command}} and follow the prompts to create your CLI configuration file and connect it to your HubSpot account"
1478
+ projectConfig:
1479
+ header: "Project configuration"
1480
+ projectDirSubHeader: "Project dir: {{#bold}}{{ projectDir }}{{/bold}}"
1481
+ projectNameSubHeader: "Project name: {{#bold}}{{ projectName }}{{/bold}}"
1482
+ counts:
1483
+ errors: '{{#bold}}Errors:{{/bold}} {{ count }}'
1484
+ warnings: "{{#bold}}Warning:{{/bold}} {{ count }}"
1485
+
1486
+
1487
+
@@ -6,7 +6,7 @@ const { COMPONENT_TYPES } = require('./projectStructure');
6
6
  const { i18n } = require('./lang');
7
7
  const { promptUser } = require('./prompts/promptUtils');
8
8
  const { DevModeInterface } = require('@hubspot/ui-extensions-dev-server');
9
- const { startPortManagerServer, portManagerHasActiveServers, stopPortManagerServer, requestPorts, } = require('@hubspot/local-dev-lib/portManager');
9
+ const { startPortManagerServer, stopPortManagerServer, requestPorts, } = require('@hubspot/local-dev-lib/portManager');
10
10
  const { getHubSpotApiOrigin, getHubSpotWebsiteOrigin, } = require('@hubspot/local-dev-lib/urls');
11
11
  const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
12
12
  const i18nKey = 'lib.DevServerManager';
@@ -109,10 +109,7 @@ class DevServerManager {
109
109
  await serverInterface.cleanup();
110
110
  }
111
111
  });
112
- const hasActiveServers = await portManagerHasActiveServers();
113
- if (!hasActiveServers) {
114
- await stopPortManagerServer();
115
- }
112
+ await stopPortManagerServer();
116
113
  }
117
114
  }
118
115
  }