@hubspot/cli 6.4.0 → 7.0.0-experimental.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 (123) hide show
  1. package/bin/cli.js +36 -15
  2. package/commands/{accounts → account}/clean.js +10 -9
  3. package/commands/{accounts → account}/info.js +10 -14
  4. package/commands/{accounts → account}/list.js +16 -13
  5. package/commands/{accounts → account}/remove.js +8 -8
  6. package/commands/{accounts → account}/rename.js +4 -5
  7. package/commands/{accounts → account}/use.js +5 -8
  8. package/commands/account.js +26 -0
  9. package/commands/auth.js +30 -23
  10. package/commands/cms/getReactModule.js +70 -0
  11. package/commands/cms/lighthouseScore.js +19 -19
  12. package/commands/cms.js +4 -3
  13. package/commands/completion.js +22 -0
  14. package/commands/config/set.js +22 -22
  15. package/commands/config.js +2 -2
  16. package/commands/create.js +5 -3
  17. package/commands/customObject/create.js +18 -13
  18. package/commands/customObject/schema/create.js +14 -14
  19. package/commands/customObject/schema/delete.js +29 -9
  20. package/commands/customObject/schema/fetch-all.js +14 -9
  21. package/commands/customObject/schema/fetch.js +22 -12
  22. package/commands/customObject/schema/list.js +3 -4
  23. package/commands/customObject/schema/update.js +27 -16
  24. package/commands/customObject/schema.js +1 -1
  25. package/commands/customObject.js +3 -4
  26. package/commands/doctor.js +2 -0
  27. package/commands/feedback.js +2 -0
  28. package/commands/fetch.js +13 -12
  29. package/commands/filemanager/fetch.js +6 -5
  30. package/commands/filemanager/upload.js +10 -10
  31. package/commands/filemanager.js +0 -4
  32. package/commands/{functions → function}/deploy.js +13 -11
  33. package/commands/{functions → function}/list.js +7 -7
  34. package/commands/{functions → function}/server.js +5 -6
  35. package/commands/function.js +20 -0
  36. package/commands/hubdb/clear.js +14 -8
  37. package/commands/hubdb/create.js +36 -11
  38. package/commands/hubdb/delete.js +31 -8
  39. package/commands/hubdb/fetch.js +14 -7
  40. package/commands/hubdb.js +2 -3
  41. package/commands/init.js +37 -14
  42. package/commands/lint.js +6 -5
  43. package/commands/list.js +5 -5
  44. package/commands/logs.js +24 -13
  45. package/commands/module/marketplace-validate.js +6 -7
  46. package/commands/module.js +2 -1
  47. package/commands/mv.js +11 -11
  48. package/commands/open.js +11 -10
  49. package/commands/project/add.js +2 -3
  50. package/commands/project/cloneApp.js +28 -30
  51. package/commands/project/create.js +8 -8
  52. package/commands/project/deploy.js +16 -13
  53. package/commands/project/dev.js +14 -14
  54. package/commands/project/download.js +18 -13
  55. package/commands/project/listBuilds.js +34 -29
  56. package/commands/project/logs.js +5 -5
  57. package/commands/project/migrateApp.js +27 -25
  58. package/commands/project/open.js +7 -8
  59. package/commands/project/upload.js +27 -29
  60. package/commands/project/watch.js +12 -19
  61. package/commands/project.js +3 -4
  62. package/commands/remove.js +14 -11
  63. package/commands/sandbox/create.js +12 -13
  64. package/commands/sandbox/delete.js +15 -13
  65. package/commands/sandbox.js +3 -4
  66. package/commands/{secrets → secret}/addSecret.js +24 -9
  67. package/commands/secret/deleteSecret.js +71 -0
  68. package/commands/{secrets → secret}/listSecrets.js +6 -6
  69. package/commands/secret/updateSecret.d.ts +1 -0
  70. package/commands/{secrets → secret}/updateSecret.js +20 -10
  71. package/commands/secret.js +22 -0
  72. package/commands/theme/generate-selectors.js +8 -8
  73. package/commands/theme/marketplace-validate.js +10 -11
  74. package/commands/theme/preview.js +6 -7
  75. package/commands/theme.js +3 -1
  76. package/commands/upload.js +28 -24
  77. package/commands/watch.js +19 -19
  78. package/lang/en.lyaml +177 -111
  79. package/lib/buildAccount.js +3 -1
  80. package/lib/commonOpts.d.ts +15 -6
  81. package/lib/commonOpts.js +53 -38
  82. package/lib/configOptions.js +19 -18
  83. package/lib/developerTestAccounts.js +8 -5
  84. package/lib/oauth.js +3 -1
  85. package/lib/projects.js +10 -5
  86. package/lib/prompts/accountsPrompt.js +9 -5
  87. package/lib/prompts/createModulePrompt.js +17 -2
  88. package/lib/prompts/createProjectPrompt.js +5 -5
  89. package/lib/prompts/projectDevTargetAccountPrompt.js +3 -2
  90. package/lib/prompts/promptUtils.d.ts +3 -0
  91. package/lib/prompts/promptUtils.js +14 -2
  92. package/lib/prompts/sandboxesPrompt.js +10 -7
  93. package/lib/prompts/secretPrompt.d.ts +3 -1
  94. package/lib/prompts/secretPrompt.js +32 -19
  95. package/lib/prompts/selectHubDBTablePrompt.d.ts +8 -0
  96. package/lib/prompts/selectHubDBTablePrompt.js +69 -0
  97. package/lib/prompts/setAsDefaultAccountPrompt.js +4 -2
  98. package/lib/sandboxSync.js +5 -2
  99. package/lib/sandboxes.js +12 -7
  100. package/lib/validation.js +14 -13
  101. package/package.json +5 -4
  102. package/commands/accounts.js +0 -30
  103. package/commands/cms/reactModules.js +0 -60
  104. package/commands/functions.js +0 -24
  105. package/commands/secrets/deleteSecret.js +0 -46
  106. package/commands/secrets.js +0 -23
  107. /package/commands/{accounts → account}/clean.d.ts +0 -0
  108. /package/commands/{accounts → account}/info.d.ts +0 -0
  109. /package/commands/{accounts → account}/list.d.ts +0 -0
  110. /package/commands/{accounts → account}/remove.d.ts +0 -0
  111. /package/commands/{accounts → account}/rename.d.ts +0 -0
  112. /package/commands/{accounts → account}/use.d.ts +0 -0
  113. /package/commands/{accounts.d.ts → account.d.ts} +0 -0
  114. /package/commands/cms/{reactModules.d.ts → getReactModule.d.ts} +0 -0
  115. /package/commands/{functions.d.ts → completion.d.ts} +0 -0
  116. /package/commands/{functions/list.d.ts → function/deploy.d.ts} +0 -0
  117. /package/commands/{functions/server.d.ts → function/list.d.ts} +0 -0
  118. /package/commands/{secrets.d.ts → function/server.d.ts} +0 -0
  119. /package/commands/{functions/deploy.d.ts → function.d.ts} +0 -0
  120. /package/commands/{secrets/deleteSecret.d.ts → secret/addSecret.d.ts} +0 -0
  121. /package/commands/{secrets/listSecrets.d.ts → secret/deleteSecret.d.ts} +0 -0
  122. /package/commands/{secrets/updateSecret.d.ts → secret/listSecrets.d.ts} +0 -0
  123. /package/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
@@ -0,0 +1,8 @@
1
+ export declare function selectHubDBTablePrompt({ accountId, options, skipDestPrompt, }: {
2
+ accountId: number;
3
+ options: {
4
+ tableId?: number;
5
+ dest?: string;
6
+ };
7
+ skipDestPrompt?: boolean;
8
+ }): Promise<any>;
@@ -0,0 +1,69 @@
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.selectHubDBTablePrompt = selectHubDBTablePrompt;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const promptUtils_1 = require("./promptUtils");
9
+ const lang_1 = require("../lang");
10
+ const index_1 = require("../errorHandlers/index");
11
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
12
+ const hubdb_1 = require("@hubspot/local-dev-lib/api/hubdb");
13
+ const exitCodes_1 = require("../enums/exitCodes");
14
+ const path_1 = require("@hubspot/local-dev-lib/path");
15
+ const i18nKey = 'lib.prompts.selectHubDBTablePrompt';
16
+ async function fetchHubDBOptions(accountId) {
17
+ try {
18
+ const { data: { results: tables }, } = await (0, hubdb_1.fetchTables)(accountId);
19
+ if (tables.length === 0) {
20
+ logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.errors.noTables`, { accountId }));
21
+ process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
22
+ }
23
+ return tables;
24
+ }
25
+ catch (error) {
26
+ (0, index_1.debugError)(error, { accountId });
27
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.errorFetchingTables`, { accountId }));
28
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
29
+ }
30
+ }
31
+ async function selectHubDBTablePrompt({ accountId, options, skipDestPrompt = true, }) {
32
+ const hubdbTables = (await fetchHubDBOptions(accountId)) || [];
33
+ const id = options.tableId?.toString();
34
+ const isValidTable = options.tableId && hubdbTables.find(table => table.id === id);
35
+ return (0, promptUtils_1.promptUser)([
36
+ {
37
+ name: 'tableId',
38
+ message: (0, lang_1.i18n)(`${i18nKey}.selectTable`),
39
+ when: !id && !isValidTable,
40
+ type: 'list',
41
+ choices: hubdbTables.map(table => {
42
+ return {
43
+ name: `${table.label} (${table.id})`,
44
+ value: table.id,
45
+ };
46
+ }),
47
+ },
48
+ {
49
+ name: 'dest',
50
+ message: (0, lang_1.i18n)(`${i18nKey}.enterDest`),
51
+ when: !options.dest && !skipDestPrompt,
52
+ validate: (input) => {
53
+ if (!input) {
54
+ return (0, lang_1.i18n)(`${i18nKey}.errors.destRequired`);
55
+ }
56
+ if (fs_1.default.existsSync(input)) {
57
+ return (0, lang_1.i18n)(`${i18nKey}.errors.invalidDest`);
58
+ }
59
+ if (!(0, path_1.isValidPath)(input)) {
60
+ return (0, lang_1.i18n)(`${i18nKey}.errors.invalidCharacters`);
61
+ }
62
+ return true;
63
+ },
64
+ filter: (input) => {
65
+ return (0, path_1.untildify)(input);
66
+ },
67
+ },
68
+ ]);
69
+ }
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // @ts-nocheck
4
- const { getConfig, updateDefaultAccount, } = require('@hubspot/local-dev-lib/config');
4
+ const { getConfig, updateDefaultAccount, getConfigDefaultAccount, } = require('@hubspot/local-dev-lib/config');
5
5
  const { promptUser } = require('./promptUtils');
6
6
  const { i18n } = require('../lang');
7
7
  const i18nKey = 'lib.prompts.setAsDefaultAccountPrompt';
8
8
  const setAsDefaultAccountPrompt = async (accountName) => {
9
9
  const config = getConfig();
10
+ // Accounts for deprecated and new config
11
+ const defaultAccount = getConfigDefaultAccount(config);
10
12
  const { setAsDefault } = await promptUser([
11
13
  {
12
14
  name: 'setAsDefault',
13
15
  type: 'confirm',
14
- when: config.defaultPortal !== accountName,
16
+ when: defaultAccount !== accountName,
15
17
  message: i18n(`${i18nKey}.setAsDefaultAccountMessage`),
16
18
  },
17
19
  ]);
@@ -11,6 +11,7 @@ const { debugError, logError, ApiErrorContext, } = require('./errorHandlers/inde
11
11
  const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
12
12
  const { getSandboxTypeAsString } = require('./sandboxes');
13
13
  const { getAccountId } = require('@hubspot/local-dev-lib/config');
14
+ const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
14
15
  const { uiAccountDescription, uiLine, uiLink, uiCommandDisabledBanner, } = require('./ui');
15
16
  const { isDevelopmentSandbox } = require('./accountTypes');
16
17
  const i18nKey = 'lib.sandbox.sync';
@@ -22,8 +23,10 @@ const i18nKey = 'lib.sandbox.sync';
22
23
  * @returns
23
24
  */
24
25
  const syncSandbox = async ({ accountConfig, parentAccountConfig, env, syncTasks, slimInfoMessage = false, }) => {
25
- const accountId = getAccountId(accountConfig.portalId);
26
- const parentAccountId = getAccountId(parentAccountConfig.portalId);
26
+ const id = getAccountIdentifier(accountConfig);
27
+ const accountId = getAccountId(id);
28
+ const parentId = getAccountIdentifier(parentAccountConfig);
29
+ const parentAccountId = getAccountId(parentId);
27
30
  const isDevSandbox = isDevelopmentSandbox(accountConfig);
28
31
  SpinniesManager.init({
29
32
  succeedColor: 'white',
package/lib/sandboxes.js CHANGED
@@ -5,11 +5,12 @@ const { i18n } = require('./lang');
5
5
  const { logger } = require('@hubspot/local-dev-lib/logger');
6
6
  const { getSandboxUsageLimits, } = require('@hubspot/local-dev-lib/api/sandboxHubs');
7
7
  const { fetchTypes } = require('@hubspot/local-dev-lib/api/sandboxSync');
8
- const { getConfig, getAccountId, getEnv, } = require('@hubspot/local-dev-lib/config');
8
+ const { getAccountId, getEnv, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
9
9
  const { promptUser } = require('./prompts/promptUtils');
10
10
  const { isDevelopmentSandbox } = require('./accountTypes');
11
11
  const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
12
12
  const { HUBSPOT_ACCOUNT_TYPES, } = require('@hubspot/local-dev-lib/constants/config');
13
+ const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
13
14
  const { uiAccountDescription } = require('./ui');
14
15
  const { isMissingScopeError, isSpecifiedError, } = require('@hubspot/local-dev-lib/errors/index');
15
16
  const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
@@ -34,9 +35,10 @@ const getSandboxTypeAsString = accountType => {
34
35
  return 'standard';
35
36
  };
36
37
  function getHasSandboxesByType(parentAccountConfig, type) {
37
- const config = getConfig();
38
- const parentPortalId = getAccountId(parentAccountConfig.portalId);
39
- for (const portal of config.portals) {
38
+ const id = getAccountIdentifier(parentAccountConfig);
39
+ const parentPortalId = getAccountId(id);
40
+ const accountsList = getConfigAccounts();
41
+ for (const portal of accountsList) {
40
42
  if ((portal.parentAccountId !== null ||
41
43
  portal.parentAccountId !== undefined) &&
42
44
  portal.parentAccountId === parentPortalId &&
@@ -54,8 +56,10 @@ function getSandboxLimit(error) {
54
56
  }
55
57
  // Fetches available sync types for a given sandbox portal
56
58
  async function getAvailableSyncTypes(parentAccountConfig, config) {
57
- const parentPortalId = getAccountId(parentAccountConfig.portalId);
58
- const portalId = getAccountId(config.portalId);
59
+ const parentId = getAccountIdentifier(parentAccountConfig);
60
+ const parentPortalId = getAccountId(parentId);
61
+ const id = getAccountIdentifier(config);
62
+ const portalId = getAccountId(id);
59
63
  const { data: { results: syncTypes }, } = await fetchTypes(parentPortalId, portalId);
60
64
  if (!syncTypes) {
61
65
  throw new Error('Unable to fetch available sandbox sync types. Please try again.');
@@ -98,7 +102,8 @@ const getSyncTypesWithContactRecordsPrompt = async (accountConfig, syncTasks, sk
98
102
  * @returns {null}
99
103
  */
100
104
  const validateSandboxUsageLimits = async (accountConfig, sandboxType, env) => {
101
- const accountId = getAccountId(accountConfig.portalId);
105
+ const id = getAccountIdentifier(accountConfig);
106
+ const accountId = getAccountId(id);
102
107
  const { data: { usage }, } = await getSandboxUsageLimits(accountId);
103
108
  if (!usage) {
104
109
  throw new Error('Unable to fetch sandbox usage limits. Please try again.');
package/lib/validation.js CHANGED
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
7
- const { MODE } = require('@hubspot/local-dev-lib/constants/files');
7
+ const { CMS_PUBLISH_MODE } = require('@hubspot/local-dev-lib/constants/files');
8
8
  const { API_KEY_AUTH_METHOD, OAUTH_AUTH_METHOD, PERSONAL_ACCESS_KEY_AUTH_METHOD, } = require('@hubspot/local-dev-lib/constants/auth');
9
9
  const { commaSeparatedValues } = require('@hubspot/local-dev-lib/text');
10
10
  const { loadConfig, getConfigPath, validateConfig, getAccountConfig, loadConfigFromEnvironment, } = require('@hubspot/local-dev-lib/config');
11
11
  const { getOauthManager } = require('@hubspot/local-dev-lib/oauth');
12
12
  const { accessTokenForPersonalAccessKey, } = require('@hubspot/local-dev-lib/personalAccessKey');
13
13
  const { getAbsoluteFilePath, getCwd, getExt, } = require('@hubspot/local-dev-lib/path');
14
- const { getAccountId, getMode, setLogLevel } = require('./commonOpts');
14
+ const { getAccountId, getCmsPublishMode, setLogLevel, } = require('./commonOpts');
15
15
  const { EXIT_CODES } = require('./enums/exitCodes');
16
16
  const { checkAndWarnGitInclusion } = require('./ui/git');
17
17
  const { logError } = require('./errorHandlers/index');
@@ -37,9 +37,7 @@ async function loadAndValidateOptions(options, shouldValidateAccount = true) {
37
37
  */
38
38
  async function validateAccount(options) {
39
39
  const accountId = getAccountId(options);
40
- const { portalId: portalIdOption, portal: portalOption, accountId: _accountIdOption, account: _accountOption, } = options;
41
- const accountOption = portalOption || _accountOption;
42
- const accountIdOption = portalIdOption || _accountIdOption;
40
+ const { accountId: accountIdOption, account: accountOption } = options;
43
41
  if (!accountId) {
44
42
  if (accountOption) {
45
43
  logger.error(`The account "${accountOption}" could not be found in the config`);
@@ -119,17 +117,20 @@ async function validateAccount(options) {
119
117
  * @param {object} command options
120
118
  * @returns {boolean}
121
119
  */
122
- function validateMode(options) {
123
- const mode = getMode(options);
124
- if (MODE[mode]) {
120
+ function validateCmsPublishMode(options) {
121
+ const cmsPublishMode = getCmsPublishMode(options);
122
+ if (CMS_PUBLISH_MODE[cmsPublishMode]) {
125
123
  return true;
126
124
  }
127
- const modesMessage = `Available modes are: ${Object.values(MODE).join(', ')}.`;
128
- if (mode != null) {
129
- logger.error([`The mode "${mode}" is invalid.`, modesMessage].join(' '));
125
+ const modesMessage = `Available CMS publish modes are: ${Object.values(CMS_PUBLISH_MODE).join(', ')}.`;
126
+ if (cmsPublishMode != null) {
127
+ logger.error([
128
+ `The CMS publish mode "${cmsPublishMode}" is invalid.`,
129
+ modesMessage,
130
+ ].join(' '));
130
131
  }
131
132
  else {
132
- logger.error(['The mode option is missing.', modesMessage].join(' '));
133
+ logger.error(['The CMS publish mode option is missing.', modesMessage].join(' '));
133
134
  }
134
135
  return false;
135
136
  }
@@ -171,7 +172,7 @@ const checkAndConvertToJson = _path => {
171
172
  return result;
172
173
  };
173
174
  module.exports = {
174
- validateMode,
175
+ validateCmsPublishMode,
175
176
  validateAccount,
176
177
  checkAndConvertToJson,
177
178
  fileExists,
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-experimental.0",
4
4
  "description": "The official CLI for developing on HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "https://github.com/HubSpot/hubspot-cli",
7
7
  "dependencies": {
8
- "@hubspot/local-dev-lib": "2.3.0",
8
+ "@hubspot/local-dev-lib": "3.0.0",
9
9
  "@hubspot/serverless-dev-runtime": "7.0.0",
10
10
  "@hubspot/theme-preview-dev-server": "0.0.9",
11
11
  "@hubspot/ui-extensions-dev-server": "0.8.33",
@@ -26,7 +26,8 @@
26
26
  "table": "^6.6.0",
27
27
  "tmp": "^0.2.1",
28
28
  "update-notifier": "^5.1.0",
29
- "yargs": "17.7.2"
29
+ "yargs": "17.7.2",
30
+ "yargs-parser": "^21.1.1"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@types/fs-extra": "^11.0.4",
@@ -51,7 +52,7 @@
51
52
  "typescript": "^5.6.2"
52
53
  },
53
54
  "optionalDependencies": {
54
- "@hubspot/cms-dev-server": "^0.18.10"
55
+ "@hubspot/cms-dev-server": "^0.18.9"
55
56
  },
56
57
  "scripts": {
57
58
  "build": "ts-node ./scripts/build.ts",
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
5
- const { i18n } = require('../lib/lang');
6
- const list = require('./accounts/list');
7
- const rename = require('./accounts/rename');
8
- const use = require('./accounts/use');
9
- const info = require('./accounts/info');
10
- const remove = require('./accounts/remove');
11
- const clean = require('./accounts/clean');
12
- const i18nKey = 'commands.accounts';
13
- exports.command = 'accounts';
14
- exports.describe = i18n(`${i18nKey}.describe`);
15
- exports.builder = yargs => {
16
- addConfigOptions(yargs);
17
- addAccountOptions(yargs);
18
- yargs
19
- .command({
20
- ...list,
21
- aliases: 'ls',
22
- })
23
- .command(rename)
24
- .command(use)
25
- .command(info)
26
- .command(remove)
27
- .command(clean)
28
- .demandCommand(1, '');
29
- return yargs;
30
- };
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const fs = require('fs');
5
- const { logger } = require('@hubspot/local-dev-lib/logger');
6
- const { retrieveDefaultModule } = require('@hubspot/local-dev-lib/cms/modules');
7
- const { i18n } = require('../../lib/lang');
8
- const path = require('path');
9
- const { trackCommandUsage } = require('../../lib/usageTracking');
10
- const i18nKey = 'commands.cms.subcommands.reactModule';
11
- exports.command = 'get-react-module [--name] [--dest]';
12
- exports.describe = i18n(`${i18nKey}.describe`);
13
- exports.handler = async (options) => {
14
- const { name, dest } = options;
15
- trackCommandUsage('get-react-modules');
16
- const destPath = dest
17
- ? path.join(dest, `${name}`)
18
- : path.join(process.cwd(), `${name}`);
19
- if (fs.existsSync(destPath)) {
20
- logger.error(i18n(`${i18nKey}.errors.pathExists`, {
21
- path: destPath,
22
- }));
23
- return;
24
- }
25
- try {
26
- const modules = await retrieveDefaultModule(name, destPath);
27
- if (!name) {
28
- logger.group(i18n(`${i18nKey}.groupLabel`));
29
- modules.forEach(module => {
30
- logger.log(module.name);
31
- });
32
- logger.groupEnd(i18n(`${i18nKey}.groupLabel`));
33
- }
34
- else {
35
- logger.success(i18n(`${i18nKey}.success.moduleDownloaded`, {
36
- moduleName: name,
37
- path: destPath,
38
- }));
39
- }
40
- }
41
- catch (e) {
42
- if (e.cause && e.cause.code === 'ERR_BAD_REQUEST') {
43
- logger.error(i18n(`${i18nKey}.errors.invalidName`));
44
- }
45
- else {
46
- logger.error(e);
47
- }
48
- }
49
- };
50
- exports.builder = yargs => {
51
- yargs.option('name', {
52
- describe: i18n(`${i18nKey}.options.name.describe`),
53
- type: 'string',
54
- });
55
- yargs.option('dest', {
56
- describe: i18n(`${i18nKey}.options.dest.describe`),
57
- type: 'string',
58
- });
59
- return yargs;
60
- };
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
5
- const list = require('./functions/list');
6
- const deploy = require('./functions/deploy');
7
- const server = require('./functions/server');
8
- const { i18n } = require('../lib/lang');
9
- const i18nKey = 'commands.functions';
10
- exports.command = 'functions';
11
- exports.describe = i18n(`${i18nKey}.describe`);
12
- exports.builder = yargs => {
13
- addConfigOptions(yargs);
14
- addAccountOptions(yargs);
15
- yargs
16
- .command({
17
- ...list,
18
- aliases: 'ls',
19
- })
20
- .command(deploy)
21
- .command(server)
22
- .demandCommand(1, '');
23
- return yargs;
24
- };
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { logger } = require('@hubspot/local-dev-lib/logger');
5
- const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
6
- const { deleteSecret } = require('@hubspot/local-dev-lib/api/secrets');
7
- const { loadAndValidateOptions } = require('../../lib/validation');
8
- const { trackCommandUsage } = require('../../lib/usageTracking');
9
- const { uiAccountDescription } = require('../../lib/ui');
10
- const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
11
- const { i18n } = require('../../lib/lang');
12
- const i18nKey = 'commands.secrets.subcommands.delete';
13
- exports.command = 'delete <name>';
14
- exports.describe = i18n(`${i18nKey}.describe`);
15
- exports.handler = async (options) => {
16
- const { name: secretName } = options;
17
- await loadAndValidateOptions(options);
18
- const accountId = getAccountId(options);
19
- trackCommandUsage('secrets-delete', null, accountId);
20
- try {
21
- await deleteSecret(accountId, secretName);
22
- logger.success(i18n(`${i18nKey}.success.delete`, {
23
- accountIdentifier: uiAccountDescription(accountId),
24
- secretName,
25
- }));
26
- }
27
- catch (err) {
28
- logger.error(i18n(`${i18nKey}.errors.delete`, {
29
- secretName,
30
- }));
31
- logError(err, new ApiErrorContext({
32
- request: 'delete a secret',
33
- accountId,
34
- }));
35
- }
36
- };
37
- exports.builder = yargs => {
38
- addConfigOptions(yargs);
39
- addAccountOptions(yargs);
40
- addUseEnvironmentOptions(yargs);
41
- yargs.positional('name', {
42
- describe: i18n(`${i18nKey}.positionals.name.describe`),
43
- type: 'string',
44
- });
45
- return yargs;
46
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
5
- const addSecretCommand = require('./secrets/addSecret');
6
- const listSecretsCommand = require('./secrets/listSecrets');
7
- const deleteSecretCommand = require('./secrets/deleteSecret');
8
- const updateSecretCommand = require('./secrets/updateSecret');
9
- const { i18n } = require('../lib/lang');
10
- const i18nKey = 'commands.secrets';
11
- exports.command = 'secrets';
12
- exports.describe = i18n(`${i18nKey}.describe`);
13
- exports.builder = yargs => {
14
- addConfigOptions(yargs);
15
- addAccountOptions(yargs);
16
- yargs
17
- .command(listSecretsCommand)
18
- .command(addSecretCommand)
19
- .command(updateSecretCommand)
20
- .command(deleteSecretCommand)
21
- .demandCommand(1, '');
22
- return yargs;
23
- };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes