@hubspot/cli 7.2.0-beta.0 → 7.2.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.
package/commands/list.js CHANGED
@@ -1,37 +1,68 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const chalk = require('chalk');
5
- const { addAccountOptions, addConfigOptions, addGlobalOptions, addUseEnvironmentOptions, } = require('../lib/commonOpts');
6
- const { trackCommandUsage } = require('../lib/usageTracking');
7
- const { isPathFolder } = require('../lib/filesystem');
8
- const { logger } = require('@hubspot/local-dev-lib/logger');
9
- const { logError } = require('../lib/errorHandlers/index');
10
- const { getDirectoryContentsByPath, } = require('@hubspot/local-dev-lib/api/fileMapper');
11
- const { HUBSPOT_FOLDER, MARKETPLACE_FOLDER } = require('../lib/constants');
12
- const { i18n } = require('../lib/lang');
6
+ exports.describe = exports.command = void 0;
7
+ exports.handler = handler;
8
+ exports.builder = builder;
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const commonOpts_1 = require("../lib/commonOpts");
11
+ const usageTracking_1 = require("../lib/usageTracking");
12
+ const filesystem_1 = require("../lib/filesystem");
13
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
14
+ const index_1 = require("../lib/errorHandlers/index");
15
+ const fileMapper_1 = require("@hubspot/local-dev-lib/api/fileMapper");
16
+ const constants_1 = require("../lib/constants");
17
+ const lang_1 = require("../lib/lang");
18
+ const exitCodes_1 = require("../lib/enums/exitCodes");
13
19
  const i18nKey = 'commands.list';
14
- const { EXIT_CODES } = require('../lib/enums/exitCodes');
20
+ function addColorToContents(fileOrFolder) {
21
+ if (!(0, filesystem_1.isPathFolder)(fileOrFolder)) {
22
+ return chalk_1.default.reset.cyan(fileOrFolder);
23
+ }
24
+ if (fileOrFolder === constants_1.HUBSPOT_FOLDER || fileOrFolder === constants_1.MARKETPLACE_FOLDER) {
25
+ return chalk_1.default.reset.bold.blue(fileOrFolder);
26
+ }
27
+ return chalk_1.default.reset.blue(fileOrFolder);
28
+ }
29
+ function sortContents(a, b) {
30
+ // Pin @hubspot folder to top
31
+ if (a === constants_1.HUBSPOT_FOLDER) {
32
+ return -1;
33
+ }
34
+ else if (b === constants_1.HUBSPOT_FOLDER) {
35
+ return 1;
36
+ }
37
+ // Pin @marketplace folder to top
38
+ if (a === constants_1.MARKETPLACE_FOLDER) {
39
+ return -1;
40
+ }
41
+ else if (b === constants_1.MARKETPLACE_FOLDER) {
42
+ return 1;
43
+ }
44
+ return a.localeCompare(b);
45
+ }
15
46
  exports.command = 'list [path]';
16
- exports.describe = i18n(`${i18nKey}.describe`);
17
- exports.handler = async (options) => {
18
- const { path, derivedAccountId } = options;
47
+ exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
48
+ async function handler(args) {
49
+ const { path, derivedAccountId } = args;
19
50
  const directoryPath = path || '/';
20
51
  let contentsResp;
21
- trackCommandUsage('list', null, derivedAccountId);
22
- logger.debug(i18n(`${i18nKey}.gettingPathContents`, {
52
+ (0, usageTracking_1.trackCommandUsage)('list', undefined, derivedAccountId);
53
+ logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.gettingPathContents`, {
23
54
  path: directoryPath,
24
55
  }));
25
56
  try {
26
- const { data } = await getDirectoryContentsByPath(derivedAccountId, directoryPath);
57
+ const { data } = await (0, fileMapper_1.getDirectoryContentsByPath)(derivedAccountId, directoryPath);
27
58
  contentsResp = data;
28
59
  }
29
60
  catch (e) {
30
- logError(e);
31
- process.exit(EXIT_CODES.SUCCESS);
61
+ (0, index_1.logError)(e);
62
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
32
63
  }
33
64
  if (!contentsResp.folder) {
34
- logger.info(i18n(`${i18nKey}.noFilesFoundAtPath`, {
65
+ logger_1.logger.info((0, lang_1.i18n)(`${i18nKey}.noFilesFoundAtPath`, {
35
66
  path: directoryPath,
36
67
  }));
37
68
  return;
@@ -41,7 +72,7 @@ exports.handler = async (options) => {
41
72
  ? ['@hubspot', ...contentsResp.children]
42
73
  : contentsResp.children;
43
74
  if (contents.length === 0) {
44
- logger.info(i18n(`${i18nKey}.noFilesFoundAtPath`, {
75
+ logger_1.logger.info((0, lang_1.i18n)(`${i18nKey}.noFilesFoundAtPath`, {
45
76
  path: directoryPath,
46
77
  }));
47
78
  return;
@@ -50,43 +81,18 @@ exports.handler = async (options) => {
50
81
  .map(addColorToContents)
51
82
  .sort(sortContents)
52
83
  .join('\n');
53
- logger.log(folderContentsOutput);
54
- };
55
- exports.builder = yargs => {
84
+ logger_1.logger.log(folderContentsOutput);
85
+ process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
86
+ }
87
+ function builder(yargs) {
88
+ (0, commonOpts_1.addConfigOptions)(yargs);
89
+ (0, commonOpts_1.addAccountOptions)(yargs);
90
+ (0, commonOpts_1.addUseEnvironmentOptions)(yargs);
91
+ (0, commonOpts_1.addGlobalOptions)(yargs);
56
92
  yargs.positional('path', {
57
- describe: i18n(`${i18nKey}.positionals.path.describe`),
93
+ describe: (0, lang_1.i18n)(`${i18nKey}.positionals.path.describe`),
58
94
  type: 'string',
59
95
  });
60
- yargs.example([['$0 list'], ['$0 list /'], ['$0 list serverless']]);
61
- addConfigOptions(yargs);
62
- addAccountOptions(yargs);
63
- addUseEnvironmentOptions(yargs);
64
- addGlobalOptions(yargs);
96
+ yargs.example([['$0 list'], ['$0 list /'], ['$0 list my-modules']]);
65
97
  return yargs;
66
- };
67
- const addColorToContents = fileOrFolder => {
68
- if (!isPathFolder(fileOrFolder)) {
69
- return chalk.reset.cyan(fileOrFolder);
70
- }
71
- if (fileOrFolder === HUBSPOT_FOLDER || fileOrFolder === MARKETPLACE_FOLDER) {
72
- return chalk.reset.bold.blue(fileOrFolder);
73
- }
74
- return chalk.reset.blue(fileOrFolder);
75
- };
76
- const sortContents = (a, b) => {
77
- // Pin @hubspot folder to top
78
- if (a === HUBSPOT_FOLDER) {
79
- return -1;
80
- }
81
- else if (b === HUBSPOT_FOLDER) {
82
- return 1;
83
- }
84
- // Pin @marketplace folder to top
85
- if (a === MARKETPLACE_FOLDER) {
86
- return -1;
87
- }
88
- else if (b === MARKETPLACE_FOLDER) {
89
- return 1;
90
- }
91
- return a.localeCompare(b);
92
- };
98
+ }
package/commands/mv.d.ts CHANGED
@@ -1 +1,11 @@
1
+ import { Argv, ArgumentsCamelCase } from 'yargs';
2
+ import { CommonArgs, ConfigArgs, EnvironmentArgs } from '../types/Yargs';
3
+ export declare const command = "mv <srcPath> <destPath>";
4
+ export declare const describe: string | undefined;
5
+ type MvArgs = CommonArgs & ConfigArgs & EnvironmentArgs & {
6
+ srcPath: string;
7
+ destPath: string;
8
+ };
9
+ export declare function handler(args: ArgumentsCamelCase<MvArgs>): Promise<void>;
10
+ export declare function builder(yargs: Argv): Argv<MvArgs>;
1
11
  export {};
package/commands/mv.js CHANGED
@@ -1,58 +1,62 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { logger } = require('@hubspot/local-dev-lib/logger');
5
- const { moveFile } = require('@hubspot/local-dev-lib/api/fileMapper');
6
- const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
7
- const { logError, ApiErrorContext } = require('../lib/errorHandlers/index');
8
- const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, addGlobalOptions, } = require('../lib/commonOpts');
9
- const { trackCommandUsage } = require('../lib/usageTracking');
10
- const { isPathFolder } = require('../lib/filesystem');
11
- const { i18n } = require('../lib/lang');
12
- const { uiBetaTag } = require('../lib/ui');
3
+ exports.describe = exports.command = void 0;
4
+ exports.handler = handler;
5
+ exports.builder = builder;
6
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
7
+ const fileMapper_1 = require("@hubspot/local-dev-lib/api/fileMapper");
8
+ const index_1 = require("@hubspot/local-dev-lib/errors/index");
9
+ const index_2 = require("../lib/errorHandlers/index");
10
+ const commonOpts_1 = require("../lib/commonOpts");
11
+ const usageTracking_1 = require("../lib/usageTracking");
12
+ const filesystem_1 = require("../lib/filesystem");
13
+ const lang_1 = require("../lib/lang");
14
+ const ui_1 = require("../lib/ui");
13
15
  const i18nKey = 'commands.mv';
14
- const getCorrectedDestPath = (srcPath, destPath) => {
15
- if (!isPathFolder(srcPath)) {
16
+ function getCorrectedDestPath(srcPath, destPath) {
17
+ if (!(0, filesystem_1.isPathFolder)(srcPath)) {
16
18
  return destPath;
17
19
  }
18
20
  // Makes sure that nested folders are moved independently
19
21
  return `${destPath}/${srcPath.split('/').pop()}`;
20
- };
22
+ }
21
23
  exports.command = 'mv <srcPath> <destPath>';
22
- exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
23
- exports.handler = async (options) => {
24
- const { srcPath, destPath, derivedAccountId } = options;
25
- trackCommandUsage('mv', null, derivedAccountId);
24
+ exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
25
+ async function handler(args) {
26
+ const { srcPath, destPath, derivedAccountId } = args;
27
+ (0, usageTracking_1.trackCommandUsage)('mv', undefined, derivedAccountId);
26
28
  try {
27
- await moveFile(derivedAccountId, srcPath, getCorrectedDestPath(srcPath, destPath));
28
- logger.success(i18n(`${i18nKey}.move`, {
29
+ await (0, fileMapper_1.moveFile)(derivedAccountId, srcPath, getCorrectedDestPath(srcPath, destPath));
30
+ logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.move`, {
29
31
  accountId: derivedAccountId,
30
32
  destPath,
31
33
  srcPath,
32
34
  }));
33
35
  }
34
36
  catch (error) {
35
- logger.error(i18n(`${i18nKey}.errors.moveFailed`, {
37
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.moveFailed`, {
36
38
  accountId: derivedAccountId,
37
39
  destPath,
38
40
  srcPath,
39
41
  }));
40
- if (isSpecifiedError(error, { statusCode: 409 })) {
41
- logger.error(i18n(`${i18nKey}.errors.sourcePathExists`, {
42
+ if ((0, index_1.isSpecifiedError)(error, { statusCode: 409 })) {
43
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.sourcePathExists`, {
42
44
  destPath,
43
45
  srcPath,
44
46
  }));
45
47
  }
46
48
  else {
47
- logError(error, new ApiErrorContext({
49
+ (0, index_2.logError)(error, new index_2.ApiErrorContext({
48
50
  accountId: derivedAccountId,
49
- srcPath,
50
- destPath,
51
51
  }));
52
52
  }
53
53
  }
54
- };
55
- exports.builder = yargs => {
54
+ }
55
+ function builder(yargs) {
56
+ (0, commonOpts_1.addConfigOptions)(yargs);
57
+ (0, commonOpts_1.addAccountOptions)(yargs);
58
+ (0, commonOpts_1.addUseEnvironmentOptions)(yargs);
59
+ (0, commonOpts_1.addGlobalOptions)(yargs);
56
60
  yargs.positional('srcPath', {
57
61
  describe: 'Remote hubspot path',
58
62
  type: 'string',
@@ -61,9 +65,5 @@ exports.builder = yargs => {
61
65
  describe: 'Remote hubspot path',
62
66
  type: 'string',
63
67
  });
64
- addConfigOptions(yargs);
65
- addAccountOptions(yargs);
66
- addUseEnvironmentOptions(yargs);
67
- addGlobalOptions(yargs);
68
68
  return yargs;
69
- };
69
+ }
@@ -1 +1,11 @@
1
+ import { Argv, ArgumentsCamelCase } from 'yargs';
2
+ import { CommonArgs, ConfigArgs, EnvironmentArgs, AccountArgs } from '../types/Yargs';
3
+ export declare const command = "open [shortcut]";
4
+ export declare const describe: string;
5
+ type OpenArgs = CommonArgs & ConfigArgs & EnvironmentArgs & AccountArgs & {
6
+ shortcut?: string;
7
+ list?: boolean;
8
+ };
9
+ export declare function handler(args: ArgumentsCamelCase<OpenArgs>): Promise<void>;
10
+ export declare function builder(yargs: Argv): Argv<OpenArgs>;
1
11
  export {};
package/commands/open.js CHANGED
@@ -1,50 +1,57 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
3
+ exports.describe = exports.command = void 0;
4
+ exports.handler = handler;
5
+ exports.builder = builder;
6
+ const commonOpts_1 = require("../lib/commonOpts");
7
+ const usageTracking_1 = require("../lib/usageTracking");
8
+ const links_1 = require("../lib/links");
9
+ const promptUtils_1 = require("../lib/prompts/promptUtils");
10
+ const lang_1 = require("../lib/lang");
4
11
  const exitCodes_1 = require("../lib/enums/exitCodes");
5
- const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions, addGlobalOptions, } = require('../lib/commonOpts');
6
- const { trackCommandUsage } = require('../lib/usageTracking');
7
- const { logSiteLinks, getSiteLinksAsArray, openLink } = require('../lib/links');
8
- const { promptUser } = require('../lib/prompts/promptUtils');
9
- const { i18n } = require('../lib/lang');
10
12
  const i18nKey = 'commands.open';
11
13
  const separator = ' => ';
12
- const createListPrompt = async (accountId) => promptUser([
13
- {
14
- type: 'rawlist',
15
- look: false,
16
- name: 'open',
17
- pageSize: 20,
18
- message: i18n(`${i18nKey}.selectLink`),
19
- choices: getSiteLinksAsArray(accountId).map(l => `${l.shortcut}${separator}${l.url}`),
20
- filter: val => val.split(separator)[0],
21
- },
22
- ]);
14
+ async function createListPrompt(accountId) {
15
+ return (0, promptUtils_1.promptUser)([
16
+ {
17
+ type: 'rawlist',
18
+ name: 'open',
19
+ pageSize: 20,
20
+ message: (0, lang_1.i18n)(`${i18nKey}.selectLink`),
21
+ choices: (0, links_1.getSiteLinksAsArray)(accountId).map(l => `${l.shortcut}${separator}${l.url}`),
22
+ filter: val => val.split(separator)[0],
23
+ },
24
+ ]);
25
+ }
23
26
  exports.command = 'open [shortcut]';
24
- exports.describe = i18n(`${i18nKey}.describe`);
25
- exports.handler = async (options) => {
26
- const { shortcut, list, derivedAccountId } = options;
27
- trackCommandUsage('open', null, derivedAccountId);
27
+ exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
28
+ async function handler(args) {
29
+ const { shortcut, list, derivedAccountId } = args;
30
+ (0, usageTracking_1.trackCommandUsage)('open', undefined, derivedAccountId);
28
31
  if (shortcut === undefined && !list) {
29
32
  const choice = await createListPrompt(derivedAccountId);
30
- openLink(derivedAccountId, choice.open);
33
+ (0, links_1.openLink)(derivedAccountId, choice.open);
31
34
  }
32
35
  else if (list) {
33
- logSiteLinks(derivedAccountId);
36
+ (0, links_1.logSiteLinks)(derivedAccountId);
34
37
  }
35
- else {
36
- openLink(derivedAccountId, shortcut);
38
+ else if (shortcut) {
39
+ (0, links_1.openLink)(derivedAccountId, shortcut);
37
40
  }
38
41
  process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
39
- };
40
- exports.builder = yargs => {
42
+ }
43
+ function builder(yargs) {
44
+ (0, commonOpts_1.addConfigOptions)(yargs);
45
+ (0, commonOpts_1.addAccountOptions)(yargs);
46
+ (0, commonOpts_1.addUseEnvironmentOptions)(yargs);
47
+ (0, commonOpts_1.addGlobalOptions)(yargs);
41
48
  yargs.positional('[shortcut]', {
42
- describe: i18n(`${i18nKey}.positionals.shortcut.describe`),
49
+ describe: (0, lang_1.i18n)(`${i18nKey}.positionals.shortcut.describe`),
43
50
  type: 'string',
44
51
  });
45
52
  yargs.option('list', {
46
53
  alias: 'l',
47
- describe: i18n(`${i18nKey}.options.list.describe`),
54
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.list.describe`),
48
55
  type: 'boolean',
49
56
  });
50
57
  yargs.example([
@@ -54,9 +61,5 @@ exports.builder = yargs => {
54
61
  ['$0 open settings/navigation'],
55
62
  ['$0 open sn'],
56
63
  ]);
57
- addConfigOptions(yargs);
58
- addAccountOptions(yargs);
59
- addUseEnvironmentOptions(yargs);
60
- addGlobalOptions(yargs);
61
64
  return yargs;
62
- };
65
+ }
@@ -1 +1,10 @@
1
+ import { Argv, ArgumentsCamelCase } from 'yargs';
2
+ import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs } from '../types/Yargs';
3
+ export declare const command = "remove <path>";
4
+ export declare const describe: string;
5
+ type RemoveArgs = CommonArgs & ConfigArgs & EnvironmentArgs & AccountArgs & {
6
+ path: string;
7
+ };
8
+ export declare function handler(args: ArgumentsCamelCase<RemoveArgs>): Promise<void>;
9
+ export declare function builder(yargs: Argv): Argv<RemoveArgs>;
1
10
  export {};
@@ -1,41 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { deleteFile } = require('@hubspot/local-dev-lib/api/fileMapper');
5
- const { logger } = require('@hubspot/local-dev-lib/logger');
6
- const { logError, ApiErrorContext } = require('../lib/errorHandlers/index');
7
- const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, addGlobalOptions, } = require('../lib/commonOpts');
8
- const { trackCommandUsage } = require('../lib/usageTracking');
9
- const { i18n } = require('../lib/lang');
3
+ exports.describe = exports.command = void 0;
4
+ exports.handler = handler;
5
+ exports.builder = builder;
6
+ const fileMapper_1 = require("@hubspot/local-dev-lib/api/fileMapper");
7
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
8
+ const index_1 = require("../lib/errorHandlers/index");
9
+ const commonOpts_1 = require("../lib/commonOpts");
10
+ const usageTracking_1 = require("../lib/usageTracking");
11
+ const lang_1 = require("../lib/lang");
10
12
  const i18nKey = 'commands.remove';
11
13
  exports.command = 'remove <path>';
12
- exports.describe = i18n(`${i18nKey}.describe`);
13
- exports.handler = async (options) => {
14
- const { path: hsPath, derivedAccountId } = options;
15
- trackCommandUsage('remove', null, derivedAccountId);
14
+ exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
15
+ async function handler(args) {
16
+ const { path: hsPath, derivedAccountId } = args;
17
+ (0, usageTracking_1.trackCommandUsage)('remove', undefined, derivedAccountId);
16
18
  try {
17
- await deleteFile(derivedAccountId, hsPath);
18
- logger.log(i18n(`${i18nKey}.deleted`, { accountId: derivedAccountId, path: hsPath }));
19
+ await (0, fileMapper_1.deleteFile)(derivedAccountId, hsPath);
20
+ logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.deleted`, { accountId: derivedAccountId, path: hsPath }));
19
21
  }
20
22
  catch (error) {
21
- logger.error(i18n(`${i18nKey}.errors.deleteFailed`, {
23
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.deleteFailed`, {
22
24
  accountId: derivedAccountId,
23
25
  path: hsPath,
24
26
  }));
25
- logError(error, new ApiErrorContext({
27
+ (0, index_1.logError)(error, new index_1.ApiErrorContext({
26
28
  accountId: derivedAccountId,
27
29
  request: hsPath,
28
30
  }));
29
31
  }
30
- };
31
- exports.builder = yargs => {
32
+ }
33
+ function builder(yargs) {
34
+ (0, commonOpts_1.addConfigOptions)(yargs);
35
+ (0, commonOpts_1.addAccountOptions)(yargs);
36
+ (0, commonOpts_1.addUseEnvironmentOptions)(yargs);
37
+ (0, commonOpts_1.addGlobalOptions)(yargs);
32
38
  yargs.positional('path', {
33
- describe: i18n(`${i18nKey}.positionals.path.describe`),
39
+ describe: (0, lang_1.i18n)(`${i18nKey}.positionals.path.describe`),
34
40
  type: 'string',
35
41
  });
36
- addConfigOptions(yargs);
37
- addAccountOptions(yargs);
38
- addUseEnvironmentOptions(yargs);
39
- addGlobalOptions(yargs);
40
42
  return yargs;
41
- };
43
+ }
package/lang/en.lyaml CHANGED
@@ -72,6 +72,9 @@ en:
72
72
  describe: "Print information about the default account, or about the account specified with the \"account\" option."
73
73
  errors:
74
74
  notUsingPersonalAccessKey: "This command currently only supports fetching scopes for the personal access key auth type."
75
+ options:
76
+ account:
77
+ describe: "Account name or id to show info for"
75
78
  examples:
76
79
  default: "Print information for the default account"
77
80
  idBased: "Print information for the account with accountId equal to \"1234567\""
@@ -91,14 +94,14 @@ en:
91
94
  other: "Remove {{ count }} inactive accounts from the CLI config?"
92
95
  removeSuccess: "Removed {{ accountName }} from the CLI config."
93
96
  auth:
94
- describe: "Configure authentication for your HubSpot account. This will update the {{ configName }} file that stores your account information."
97
+ describe: "Configure authentication for your HubSpot account."
98
+ verboseDescribe: "Configure authentication for a HubSpot account. This will update the {{ configName }} file that stores your account information.\n\nThe recommended authentication method is {{#bold}}{{ authMethod }}{{/bold}}, which uses an access token tied to a specific user account."
95
99
  errors:
96
100
  noConfigFileFound: "No config file was found. To create a new config file, use the \"hs init\" command."
97
101
  unsupportedAuthType: "Unsupported auth type: {{ type }}. The only supported authentication protocols are {{ supportedProtocols }}."
98
102
  options:
99
103
  authType:
100
- describe: "Authentication mechanism"
101
- defaultDescription: "\"{{ authMethod }}\": An access token tied to a specific user account. This is the recommended way of authenticating with local development tools."
104
+ describe: "Authentication method"
102
105
  account:
103
106
  describe: "HubSpot account to authenticate"
104
107
  success:
@@ -446,11 +449,11 @@ en:
446
449
  success:
447
450
  fetch: "Downloaded HubDB table {{ tableId }} to {{ path }}"
448
451
  init:
449
- describe: "Configure authentication for your HubSpot account. This will create a {{ configName }} file to store your account information."
452
+ describe: "Create a CLI config file and configure authentication for your HubSpot account."
453
+ verboseDescribe: "Configure authentication for a HubSpot account. This will create a {{ configName }} file to store your account information. To configure authentication for additional accounts, run {{ command }}.\n\nThe recommended authentication method is {{#bold}}{{ authMethod }}{{/bold}}, which uses an access token tied to a specific user account."
450
454
  options:
451
455
  authType:
452
- describe: "Authentication mechanism"
453
- defaultDescription: "\"{{ authMethod }}\": An access token tied to a specific user account. This is the recommended way of authenticating with local development tools."
456
+ describe: "Authentication method"
454
457
  account:
455
458
  describe: "HubSpot account to authenticate"
456
459
  useHiddenConfig:
@@ -13,6 +13,7 @@ export declare function addCmsPublishModeOptions(yargs: Argv, { read, write }: {
13
13
  }): Argv;
14
14
  export declare function addTestingOptions(yargs: Argv): Argv;
15
15
  export declare function addUseEnvironmentOptions(yargs: Argv): Argv;
16
+ export declare function addCustomHelpOutput(yargs: Argv, command: string, describe: string): Promise<void>;
16
17
  export declare function setLogLevel(options: Arguments<{
17
18
  debug?: boolean;
18
19
  }>): void;
package/lib/commonOpts.js CHANGED
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.addGlobalOptions = addGlobalOptions;
4
7
  exports.addAccountOptions = addAccountOptions;
@@ -7,13 +10,19 @@ exports.addOverwriteOptions = addOverwriteOptions;
7
10
  exports.addCmsPublishModeOptions = addCmsPublishModeOptions;
8
11
  exports.addTestingOptions = addTestingOptions;
9
12
  exports.addUseEnvironmentOptions = addUseEnvironmentOptions;
13
+ exports.addCustomHelpOutput = addCustomHelpOutput;
10
14
  exports.setLogLevel = setLogLevel;
11
15
  exports.getCommandName = getCommandName;
12
16
  exports.getCmsPublishMode = getCmsPublishMode;
17
+ const chalk_1 = __importDefault(require("chalk"));
18
+ const yargs_parser_1 = __importDefault(require("yargs-parser"));
13
19
  const logger_1 = require("@hubspot/local-dev-lib/logger");
14
20
  const files_1 = require("@hubspot/local-dev-lib/constants/files");
15
21
  const config_1 = require("@hubspot/local-dev-lib/config");
16
22
  const lang_1 = require("./lang");
23
+ const errorHandlers_1 = require("./errorHandlers");
24
+ const exitCodes_1 = require("./enums/exitCodes");
25
+ const ui_1 = require("./ui");
17
26
  const i18nKey = 'lib.commonOpts';
18
27
  function addGlobalOptions(yargs) {
19
28
  yargs.version(false);
@@ -70,6 +79,27 @@ function addUseEnvironmentOptions(yargs) {
70
79
  })
71
80
  .conflicts('use-env', 'account');
72
81
  }
82
+ async function addCustomHelpOutput(yargs, command, describe) {
83
+ try {
84
+ const parsedArgv = (0, yargs_parser_1.default)(process.argv.slice(2));
85
+ if (parsedArgv && parsedArgv.help) {
86
+ // Construct the full command, including positional arguments
87
+ const commandBase = `hs ${parsedArgv._.slice(0, -1).join(' ')}`;
88
+ const fullCommand = `${commandBase.trim()} ${command}`;
89
+ // Format the original help output to be more readable
90
+ let commandHelp = await yargs.getHelp();
91
+ ['Options:', 'Examples:', 'Positionals:'].forEach(header => {
92
+ commandHelp = commandHelp.replace(header, chalk_1.default.bold(header));
93
+ });
94
+ logger_1.logger.log(`${(0, ui_1.uiCommandReference)(fullCommand, false)}\n\n${describe}\n\n${commandHelp}`);
95
+ process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
96
+ }
97
+ }
98
+ catch (e) {
99
+ // Ignore error to allow yargs to show the default help output using the command description
100
+ (0, errorHandlers_1.debugError)(e);
101
+ }
102
+ }
73
103
  function setLogLevel(options) {
74
104
  const { debug } = options;
75
105
  if (debug) {
@@ -1,12 +1,11 @@
1
1
  import { PromptConfig } from '../../types/Prompts';
2
2
  import { AccountType } from '@hubspot/local-dev-lib/types/Accounts';
3
- type AccountNamePromptResponse = {
3
+ export type AccountNamePromptResponse = {
4
4
  name: string;
5
5
  };
6
6
  export declare function getCliAccountNamePromptConfig(defaultName?: string): PromptConfig<AccountNamePromptResponse>;
7
- export declare function cliAccountNamePrompt(defaultName: string): Promise<AccountNamePromptResponse>;
7
+ export declare function cliAccountNamePrompt(defaultName?: string): Promise<AccountNamePromptResponse>;
8
8
  export declare function hubspotAccountNamePrompt({ accountType, currentPortalCount, }: {
9
9
  accountType: AccountType;
10
10
  currentPortalCount?: number;
11
11
  }): Promise<AccountNamePromptResponse>;
12
- export {};
@@ -1,5 +1,6 @@
1
+ import { AccountNamePromptResponse } from './accountNamePrompt';
1
2
  import { PromptConfig } from '../../types/Prompts';
2
- type PersonalAccessKeyPromptResponse = {
3
+ export type PersonalAccessKeyPromptResponse = {
3
4
  personalAccessKey: string;
4
5
  env: string;
5
6
  };
@@ -15,6 +16,7 @@ type ClientSecretPromptResponse = {
15
16
  type ScopesPromptResponse = {
16
17
  scopes: string[];
17
18
  };
19
+ export type OauthPromptResponse = AccountNamePromptResponse & AccountIdPromptResponse & ClientIdPromptResponse & ClientSecretPromptResponse & ScopesPromptResponse;
18
20
  /**
19
21
  * Displays notification to user that we are about to open the browser,
20
22
  * then opens their browser to the personal-access-key shortlink
@@ -23,7 +25,5 @@ export declare function personalAccessKeyPrompt({ env, account, }: {
23
25
  env: string;
24
26
  account?: number;
25
27
  }): Promise<PersonalAccessKeyPromptResponse>;
26
- export declare const OAUTH_FLOW: (PromptConfig<{
27
- name: string;
28
- }> | PromptConfig<AccountIdPromptResponse> | PromptConfig<ClientIdPromptResponse> | PromptConfig<ClientSecretPromptResponse> | PromptConfig<ScopesPromptResponse>)[];
28
+ export declare const OAUTH_FLOW: (PromptConfig<AccountNamePromptResponse> | PromptConfig<AccountIdPromptResponse> | PromptConfig<ClientIdPromptResponse> | PromptConfig<ClientSecretPromptResponse> | PromptConfig<ScopesPromptResponse>)[];
29
29
  export {};
package/lib/ui/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export declare function uiLine(): void;
7
7
  export declare function uiLink(linkText: string, url: string): string;
8
8
  export declare function uiAccountDescription(accountId?: number | null, bold?: boolean): string;
9
9
  export declare function uiInfoSection(title: string, logContent: () => void): void;
10
- export declare function uiCommandReference(command: string): string;
10
+ export declare function uiCommandReference(command: string, withQuotes?: boolean): string;
11
11
  export declare function uiFeatureHighlight(commands: string[], title?: string): void;
12
12
  export declare function uiBetaTag(message: string, log?: boolean): string | undefined;
13
13
  export declare function uiDeprecatedTag(message: string): void;
package/lib/ui/index.js CHANGED
@@ -70,9 +70,9 @@ function uiInfoSection(title, logContent) {
70
70
  logger_1.logger.log('');
71
71
  uiLine();
72
72
  }
73
- function uiCommandReference(command) {
73
+ function uiCommandReference(command, withQuotes = true) {
74
74
  const terminalUISupport = getTerminalUISupport();
75
- const commandReference = `\`${command}\``;
75
+ const commandReference = withQuotes ? `\`${command}\`` : command;
76
76
  return chalk_1.default.bold(terminalUISupport.color
77
77
  ? chalk_1.default.hex(exports.UI_COLORS.MARIGOLD_DARK)(commandReference)
78
78
  : commandReference);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.supportsHyperlinkModule = void 0;
4
- const hasFlag_1 = require("../hasFlag");
4
+ const yargsUtils_1 = require("../yargsUtils");
5
5
  //See https://github.com/jamestalmage/supports-hyperlinks (License: https://github.com/jamestalmage/supports-hyperlinks/blob/master/license)
6
6
  function parseVersion(versionString) {
7
7
  if (/^\d{3,4}$/.test(versionString)) {
@@ -22,7 +22,7 @@ function parseVersion(versionString) {
22
22
  }
23
23
  function supportsHyperlink(stream) {
24
24
  const { env } = process;
25
- if ((0, hasFlag_1.hasFlag)('noHyperlinks')) {
25
+ if ((0, yargsUtils_1.hasFlag)('noHyperlinks')) {
26
26
  return false;
27
27
  }
28
28
  if (stream && !stream.isTTY) {