@hubspot/cli 7.0.0-experimental.0 → 7.0.0-experimental.1

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 (128) hide show
  1. package/bin/cli.js +15 -36
  2. package/commands/{account → accounts}/clean.js +9 -10
  3. package/commands/{account → accounts}/info.js +14 -10
  4. package/commands/{account → accounts}/list.js +13 -16
  5. package/commands/{account → accounts}/remove.js +8 -8
  6. package/commands/{account → accounts}/rename.js +5 -4
  7. package/commands/{account → accounts}/use.js +8 -5
  8. package/commands/accounts.js +30 -0
  9. package/commands/auth.js +23 -30
  10. package/commands/cms/lighthouseScore.js +19 -19
  11. package/commands/cms/reactModules.js +60 -0
  12. package/commands/cms.js +3 -4
  13. package/commands/config/set.js +22 -22
  14. package/commands/config.js +2 -2
  15. package/commands/create.js +3 -5
  16. package/commands/customObject/create.js +13 -18
  17. package/commands/customObject/schema/create.js +14 -14
  18. package/commands/customObject/schema/delete.js +9 -29
  19. package/commands/customObject/schema/fetch-all.js +9 -14
  20. package/commands/customObject/schema/fetch.js +12 -22
  21. package/commands/customObject/schema/list.js +4 -3
  22. package/commands/customObject/schema/update.js +16 -27
  23. package/commands/customObject/schema.js +1 -1
  24. package/commands/customObject.js +4 -3
  25. package/commands/doctor.js +0 -2
  26. package/commands/feedback.js +0 -2
  27. package/commands/fetch.js +12 -13
  28. package/commands/filemanager/fetch.js +5 -6
  29. package/commands/filemanager/upload.js +10 -10
  30. package/commands/filemanager.js +4 -0
  31. package/commands/{function → functions}/deploy.js +11 -13
  32. package/commands/{function → functions}/list.js +7 -7
  33. package/commands/{function → functions}/server.js +6 -5
  34. package/commands/functions.js +24 -0
  35. package/commands/hubdb/clear.js +8 -14
  36. package/commands/hubdb/create.js +11 -36
  37. package/commands/hubdb/delete.js +8 -31
  38. package/commands/hubdb/fetch.js +7 -14
  39. package/commands/hubdb.js +3 -2
  40. package/commands/init.js +14 -37
  41. package/commands/lint.js +5 -6
  42. package/commands/list.js +5 -5
  43. package/commands/logs.js +13 -24
  44. package/commands/module/marketplace-validate.js +7 -6
  45. package/commands/module.js +1 -2
  46. package/commands/mv.js +11 -11
  47. package/commands/open.js +10 -11
  48. package/commands/project/add.js +3 -2
  49. package/commands/project/cloneApp.js +30 -28
  50. package/commands/project/create.js +8 -8
  51. package/commands/project/deploy.js +13 -16
  52. package/commands/project/dev.js +14 -14
  53. package/commands/project/download.js +13 -18
  54. package/commands/project/listBuilds.js +29 -34
  55. package/commands/project/logs.js +5 -5
  56. package/commands/project/migrateApp.js +25 -27
  57. package/commands/project/open.js +8 -7
  58. package/commands/project/upload.js +29 -27
  59. package/commands/project/watch.js +19 -12
  60. package/commands/project.js +4 -3
  61. package/commands/remove.js +11 -14
  62. package/commands/sandbox/create.js +13 -12
  63. package/commands/sandbox/delete.js +13 -15
  64. package/commands/sandbox.js +4 -3
  65. package/commands/{secret → secrets}/addSecret.js +9 -24
  66. package/commands/secrets/deleteSecret.js +46 -0
  67. package/commands/{secret → secrets}/listSecrets.js +6 -6
  68. package/commands/{secret → secrets}/updateSecret.js +10 -20
  69. package/commands/secrets.js +23 -0
  70. package/commands/theme/generate-selectors.js +8 -8
  71. package/commands/theme/marketplace-validate.js +11 -10
  72. package/commands/theme/preview.js +7 -6
  73. package/commands/theme.js +1 -3
  74. package/commands/upload.js +24 -28
  75. package/commands/watch.js +19 -19
  76. package/lang/en.lyaml +111 -177
  77. package/lib/LocalDevManager.js +1 -1
  78. package/lib/buildAccount.js +1 -3
  79. package/lib/commonOpts.d.ts +6 -15
  80. package/lib/commonOpts.js +38 -54
  81. package/lib/configOptions.js +18 -19
  82. package/lib/dependencyManagement.d.ts +4 -1
  83. package/lib/dependencyManagement.js +2 -2
  84. package/lib/developerTestAccounts.js +5 -8
  85. package/lib/doctor/Doctor.js +7 -3
  86. package/lib/localDev.js +1 -1
  87. package/lib/oauth.js +1 -3
  88. package/lib/projects.js +5 -10
  89. package/lib/prompts/accountsPrompt.js +5 -9
  90. package/lib/prompts/createModulePrompt.js +2 -17
  91. package/lib/prompts/createProjectPrompt.js +5 -5
  92. package/lib/prompts/projectDevTargetAccountPrompt.js +2 -3
  93. package/lib/prompts/promptUtils.d.ts +0 -3
  94. package/lib/prompts/promptUtils.js +2 -14
  95. package/lib/prompts/sandboxesPrompt.js +7 -10
  96. package/lib/prompts/secretPrompt.d.ts +1 -3
  97. package/lib/prompts/secretPrompt.js +19 -32
  98. package/lib/prompts/setAsDefaultAccountPrompt.js +2 -4
  99. package/lib/sandboxSync.js +2 -5
  100. package/lib/sandboxes.js +7 -12
  101. package/lib/validation.js +13 -14
  102. package/package.json +5 -6
  103. package/commands/account.js +0 -26
  104. package/commands/cms/getReactModule.js +0 -70
  105. package/commands/completion.js +0 -22
  106. package/commands/function.js +0 -20
  107. package/commands/secret/deleteSecret.js +0 -71
  108. package/commands/secret.d.ts +0 -1
  109. package/commands/secret.js +0 -22
  110. package/lib/prompts/selectHubDBTablePrompt.d.ts +0 -8
  111. package/lib/prompts/selectHubDBTablePrompt.js +0 -69
  112. /package/commands/{account → accounts}/clean.d.ts +0 -0
  113. /package/commands/{account → accounts}/info.d.ts +0 -0
  114. /package/commands/{account → accounts}/list.d.ts +0 -0
  115. /package/commands/{account → accounts}/remove.d.ts +0 -0
  116. /package/commands/{account → accounts}/rename.d.ts +0 -0
  117. /package/commands/{account → accounts}/use.d.ts +0 -0
  118. /package/commands/{account.d.ts → accounts.d.ts} +0 -0
  119. /package/commands/cms/{getReactModule.d.ts → reactModules.d.ts} +0 -0
  120. /package/commands/{function → functions}/deploy.d.ts +0 -0
  121. /package/commands/{function → functions}/list.d.ts +0 -0
  122. /package/commands/{function → functions}/server.d.ts +0 -0
  123. /package/commands/{completion.d.ts → functions.d.ts} +0 -0
  124. /package/commands/{secret → secrets}/addSecret.d.ts +0 -0
  125. /package/commands/{secret → secrets}/deleteSecret.d.ts +0 -0
  126. /package/commands/{secret → secrets}/listSecrets.d.ts +0 -0
  127. /package/commands/{secret → secrets}/updateSecret.d.ts +0 -0
  128. /package/commands/{function.d.ts → secrets.d.ts} +0 -0
@@ -5,24 +5,22 @@ const { promptUser } = require('./promptUtils');
5
5
  const { i18n } = require('../lang');
6
6
  const { uiAccountDescription } = require('../ui');
7
7
  const { HUBSPOT_ACCOUNT_TYPES, } = require('@hubspot/local-dev-lib/constants/config');
8
- const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
9
8
  const { isSandbox } = require('../accountTypes');
10
- const { getConfigDefaultAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
11
9
  const i18nKey = 'lib.prompts.sandboxesPrompt';
12
10
  const mapSandboxAccountChoices = portals => portals
13
11
  .filter(p => isSandbox(p))
14
12
  .map(p => {
15
13
  return {
16
- name: uiAccountDescription(getAccountIdentifier(p), false),
17
- value: p.name || getAccountIdentifier(p),
14
+ name: uiAccountDescription(p.portalId, false),
15
+ value: p.name || p.portalId,
18
16
  };
19
17
  });
20
18
  const mapNonSandboxAccountChoices = portals => portals
21
19
  .filter(p => !isSandbox(p))
22
20
  .map(p => {
23
21
  return {
24
- name: `${p.name} (${getAccountIdentifier(p)})`,
25
- value: p.name || getAccountIdentifier(p),
22
+ name: `${p.name} (${p.portalId})`,
23
+ value: p.name || p.portalId,
26
24
  };
27
25
  });
28
26
  const sandboxTypePrompt = () => {
@@ -47,10 +45,9 @@ const sandboxTypePrompt = () => {
47
45
  ]);
48
46
  };
49
47
  const deleteSandboxPrompt = (config, promptParentAccount = false) => {
50
- const accountsList = getConfigAccounts();
51
48
  const choices = promptParentAccount
52
- ? mapNonSandboxAccountChoices(accountsList)
53
- : mapSandboxAccountChoices(accountsList);
49
+ ? mapNonSandboxAccountChoices(config.portals)
50
+ : mapSandboxAccountChoices(config.portals);
54
51
  if (!choices.length) {
55
52
  return undefined;
56
53
  }
@@ -64,7 +61,7 @@ const deleteSandboxPrompt = (config, promptParentAccount = false) => {
64
61
  look: false,
65
62
  pageSize: 20,
66
63
  choices,
67
- default: getConfigDefaultAccount(config),
64
+ default: config.defaultPortal,
68
65
  },
69
66
  ]);
70
67
  };
@@ -1,3 +1 @@
1
- export declare function secretValuePrompt(): any;
2
- export declare function secretNamePrompt(): any;
3
- export declare function secretListPrompt(secrets: string, message: string): any;
1
+ export {};
@@ -1,37 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.secretValuePrompt = secretValuePrompt;
4
- exports.secretNamePrompt = secretNamePrompt;
5
- exports.secretListPrompt = secretListPrompt;
6
- const promptUtils_1 = require("./promptUtils");
7
- const lang_1 = require("../lang");
3
+ // @ts-nocheck
4
+ const { promptUser } = require('./promptUtils');
5
+ const { i18n } = require('../lang');
8
6
  const i18nKey = 'lib.prompts.secretPrompt';
7
+ const SECRET_VALUE_PROMPT = {
8
+ name: 'secretValue',
9
+ type: 'password',
10
+ mask: '*',
11
+ message: i18n(`${i18nKey}.enterValue`),
12
+ validate(val) {
13
+ if (typeof val !== 'string') {
14
+ return i18n(`${i18nKey}.errors.invalidValue`);
15
+ }
16
+ return true;
17
+ },
18
+ };
9
19
  function secretValuePrompt() {
10
- return (0, promptUtils_1.promptUser)([
11
- {
12
- name: 'secretValue',
13
- type: 'password',
14
- mask: '*',
15
- message: (0, lang_1.i18n)(`${i18nKey}.enterValue`),
16
- },
17
- ]);
18
- }
19
- function secretNamePrompt() {
20
- return (0, promptUtils_1.promptUser)([
21
- {
22
- name: 'secretName',
23
- type: 'input',
24
- message: (0, lang_1.i18n)(`${i18nKey}.enterName`),
25
- },
26
- ]);
27
- }
28
- function secretListPrompt(secrets, message) {
29
- return (0, promptUtils_1.promptUser)([
30
- {
31
- name: 'secretToModify',
32
- type: 'list',
33
- choices: secrets,
34
- message,
35
- },
36
- ]);
20
+ return promptUser([SECRET_VALUE_PROMPT]);
37
21
  }
22
+ module.exports = {
23
+ secretValuePrompt,
24
+ };
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // @ts-nocheck
4
- const { getConfig, updateDefaultAccount, getConfigDefaultAccount, } = require('@hubspot/local-dev-lib/config');
4
+ const { getConfig, updateDefaultAccount, } = 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);
12
10
  const { setAsDefault } = await promptUser([
13
11
  {
14
12
  name: 'setAsDefault',
15
13
  type: 'confirm',
16
- when: defaultAccount !== accountName,
14
+ when: config.defaultPortal !== accountName,
17
15
  message: i18n(`${i18nKey}.setAsDefaultAccountMessage`),
18
16
  },
19
17
  ]);
@@ -11,7 +11,6 @@ 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');
15
14
  const { uiAccountDescription, uiLine, uiLink, uiCommandDisabledBanner, } = require('./ui');
16
15
  const { isDevelopmentSandbox } = require('./accountTypes');
17
16
  const i18nKey = 'lib.sandbox.sync';
@@ -23,10 +22,8 @@ const i18nKey = 'lib.sandbox.sync';
23
22
  * @returns
24
23
  */
25
24
  const syncSandbox = async ({ accountConfig, parentAccountConfig, env, syncTasks, slimInfoMessage = false, }) => {
26
- const id = getAccountIdentifier(accountConfig);
27
- const accountId = getAccountId(id);
28
- const parentId = getAccountIdentifier(parentAccountConfig);
29
- const parentAccountId = getAccountId(parentId);
25
+ const accountId = getAccountId(accountConfig.portalId);
26
+ const parentAccountId = getAccountId(parentAccountConfig.portalId);
30
27
  const isDevSandbox = isDevelopmentSandbox(accountConfig);
31
28
  SpinniesManager.init({
32
29
  succeedColor: 'white',
package/lib/sandboxes.js CHANGED
@@ -5,12 +5,11 @@ 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 { getAccountId, getEnv, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
8
+ const { getConfig, getAccountId, getEnv, } = 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');
14
13
  const { uiAccountDescription } = require('./ui');
15
14
  const { isMissingScopeError, isSpecifiedError, } = require('@hubspot/local-dev-lib/errors/index');
16
15
  const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
@@ -35,10 +34,9 @@ const getSandboxTypeAsString = accountType => {
35
34
  return 'standard';
36
35
  };
37
36
  function getHasSandboxesByType(parentAccountConfig, type) {
38
- const id = getAccountIdentifier(parentAccountConfig);
39
- const parentPortalId = getAccountId(id);
40
- const accountsList = getConfigAccounts();
41
- for (const portal of accountsList) {
37
+ const config = getConfig();
38
+ const parentPortalId = getAccountId(parentAccountConfig.portalId);
39
+ for (const portal of config.portals) {
42
40
  if ((portal.parentAccountId !== null ||
43
41
  portal.parentAccountId !== undefined) &&
44
42
  portal.parentAccountId === parentPortalId &&
@@ -56,10 +54,8 @@ function getSandboxLimit(error) {
56
54
  }
57
55
  // Fetches available sync types for a given sandbox portal
58
56
  async function getAvailableSyncTypes(parentAccountConfig, config) {
59
- const parentId = getAccountIdentifier(parentAccountConfig);
60
- const parentPortalId = getAccountId(parentId);
61
- const id = getAccountIdentifier(config);
62
- const portalId = getAccountId(id);
57
+ const parentPortalId = getAccountId(parentAccountConfig.portalId);
58
+ const portalId = getAccountId(config.portalId);
63
59
  const { data: { results: syncTypes }, } = await fetchTypes(parentPortalId, portalId);
64
60
  if (!syncTypes) {
65
61
  throw new Error('Unable to fetch available sandbox sync types. Please try again.');
@@ -102,8 +98,7 @@ const getSyncTypesWithContactRecordsPrompt = async (accountConfig, syncTasks, sk
102
98
  * @returns {null}
103
99
  */
104
100
  const validateSandboxUsageLimits = async (accountConfig, sandboxType, env) => {
105
- const id = getAccountIdentifier(accountConfig);
106
- const accountId = getAccountId(id);
101
+ const accountId = getAccountId(accountConfig.portalId);
107
102
  const { data: { usage }, } = await getSandboxUsageLimits(accountId);
108
103
  if (!usage) {
109
104
  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 { CMS_PUBLISH_MODE } = require('@hubspot/local-dev-lib/constants/files');
7
+ const { 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, getCmsPublishMode, setLogLevel, } = require('./commonOpts');
14
+ const { getAccountId, getMode, 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,7 +37,9 @@ async function loadAndValidateOptions(options, shouldValidateAccount = true) {
37
37
  */
38
38
  async function validateAccount(options) {
39
39
  const accountId = getAccountId(options);
40
- const { accountId: accountIdOption, account: accountOption } = options;
40
+ const { portalId: portalIdOption, portal: portalOption, accountId: _accountIdOption, account: _accountOption, } = options;
41
+ const accountOption = portalOption || _accountOption;
42
+ const accountIdOption = portalIdOption || _accountIdOption;
41
43
  if (!accountId) {
42
44
  if (accountOption) {
43
45
  logger.error(`The account "${accountOption}" could not be found in the config`);
@@ -117,20 +119,17 @@ async function validateAccount(options) {
117
119
  * @param {object} command options
118
120
  * @returns {boolean}
119
121
  */
120
- function validateCmsPublishMode(options) {
121
- const cmsPublishMode = getCmsPublishMode(options);
122
- if (CMS_PUBLISH_MODE[cmsPublishMode]) {
122
+ function validateMode(options) {
123
+ const mode = getMode(options);
124
+ if (MODE[mode]) {
123
125
  return true;
124
126
  }
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(' '));
127
+ const modesMessage = `Available modes are: ${Object.values(MODE).join(', ')}.`;
128
+ if (mode != null) {
129
+ logger.error([`The mode "${mode}" is invalid.`, modesMessage].join(' '));
131
130
  }
132
131
  else {
133
- logger.error(['The CMS publish mode option is missing.', modesMessage].join(' '));
132
+ logger.error(['The mode option is missing.', modesMessage].join(' '));
134
133
  }
135
134
  return false;
136
135
  }
@@ -172,7 +171,7 @@ const checkAndConvertToJson = _path => {
172
171
  return result;
173
172
  };
174
173
  module.exports = {
175
- validateCmsPublishMode,
174
+ validateMode,
176
175
  validateAccount,
177
176
  checkAndConvertToJson,
178
177
  fileExists,
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.0.0-experimental.0",
3
+ "version": "7.0.0-experimental.1",
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": "3.0.0",
8
+ "@hubspot/local-dev-lib": "2.3.0",
9
9
  "@hubspot/serverless-dev-runtime": "7.0.0",
10
10
  "@hubspot/theme-preview-dev-server": "0.0.9",
11
- "@hubspot/ui-extensions-dev-server": "0.8.33",
11
+ "@hubspot/ui-extensions-dev-server": "0.8.39",
12
12
  "archiver": "^7.0.1",
13
13
  "chalk": "^4.1.2",
14
14
  "chokidar": "^3.0.1",
@@ -26,8 +26,7 @@
26
26
  "table": "^6.6.0",
27
27
  "tmp": "^0.2.1",
28
28
  "update-notifier": "^5.1.0",
29
- "yargs": "17.7.2",
30
- "yargs-parser": "^21.1.1"
29
+ "yargs": "17.7.2"
31
30
  },
32
31
  "devDependencies": {
33
32
  "@types/fs-extra": "^11.0.4",
@@ -52,7 +51,7 @@
52
51
  "typescript": "^5.6.2"
53
52
  },
54
53
  "optionalDependencies": {
55
- "@hubspot/cms-dev-server": "^0.18.9"
54
+ "@hubspot/cms-dev-server": "^0.18.10"
56
55
  },
57
56
  "scripts": {
58
57
  "build": "ts-node ./scripts/build.ts",
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { addGlobalOptions } = require('../lib/commonOpts');
5
- const { i18n } = require('../lib/lang');
6
- const list = require('./account/list');
7
- const rename = require('./account/rename');
8
- const use = require('./account/use');
9
- const info = require('./account/info');
10
- const remove = require('./account/remove');
11
- const clean = require('./account/clean');
12
- const i18nKey = 'commands.account';
13
- exports.command = ['account', 'accounts'];
14
- exports.describe = i18n(`${i18nKey}.describe`);
15
- exports.builder = yargs => {
16
- addGlobalOptions(yargs);
17
- yargs
18
- .command(list)
19
- .command(rename)
20
- .command(use)
21
- .command(info)
22
- .command(remove)
23
- .command(clean)
24
- .demandCommand(1, '');
25
- return yargs;
26
- };
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const fs = require('fs');
5
- const path = require('path');
6
- const { getCwd } = require('@hubspot/local-dev-lib/path');
7
- const { logger } = require('@hubspot/local-dev-lib/logger');
8
- const { retrieveDefaultModule } = require('@hubspot/local-dev-lib/cms/modules');
9
- const { i18n } = require('../../lib/lang');
10
- const { logError } = require('../../lib/errorHandlers/index');
11
- const { trackCommandUsage } = require('../../lib/usageTracking');
12
- const { listPrompt } = require('../../lib/prompts/promptUtils');
13
- const { EXIT_CODES } = require('../../lib/enums/exitCodes');
14
- const i18nKey = 'commands.cms.subcommands.getReactModule';
15
- exports.command = 'get-react-module [name] [dest]';
16
- exports.describe = i18n(`${i18nKey}.describe`);
17
- exports.handler = async (options) => {
18
- const { name, dest } = options;
19
- trackCommandUsage('get-react-modules');
20
- let moduleToRetrieve = name;
21
- if (!moduleToRetrieve) {
22
- let availableModules;
23
- try {
24
- availableModules = await retrieveDefaultModule(null, '');
25
- }
26
- catch (e) {
27
- logError(e);
28
- }
29
- const moduleChoice = await listPrompt(i18n(`${i18nKey}.selectModulePrompt`), {
30
- choices: availableModules.map(module => module.name),
31
- });
32
- moduleToRetrieve = moduleChoice;
33
- }
34
- const destPath = dest
35
- ? path.join(path.resolve(getCwd(), dest), `${moduleToRetrieve}`)
36
- : path.join(getCwd(), `${moduleToRetrieve}`);
37
- if (fs.existsSync(destPath)) {
38
- logger.error(i18n(`${i18nKey}.errors.pathExists`, {
39
- path: destPath,
40
- }));
41
- return;
42
- }
43
- try {
44
- await retrieveDefaultModule(moduleToRetrieve, destPath);
45
- logger.success(i18n(`${i18nKey}.success.moduleDownloaded`, {
46
- moduleName: moduleToRetrieve,
47
- path: destPath,
48
- }));
49
- }
50
- catch (e) {
51
- if (e.cause && e.cause.code === 'ERR_BAD_REQUEST') {
52
- logger.error(i18n(`${i18nKey}.errors.invalidName`));
53
- }
54
- else {
55
- logError(e);
56
- }
57
- }
58
- process.exit(EXIT_CODES.SUCCESS);
59
- };
60
- exports.builder = yargs => {
61
- yargs.positional('name', {
62
- describe: i18n(`${i18nKey}.positionals.name.describe`),
63
- type: 'string',
64
- });
65
- yargs.positional('dest', {
66
- describe: i18n(`${i18nKey}.positionals.dest.describe`),
67
- type: 'string',
68
- });
69
- return yargs;
70
- };
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const yargsParser = require('yargs-parser');
5
- const { i18n } = require('../lib/lang');
6
- const { trackCommandUsage } = require('../lib/usageTracking');
7
- const i18nKey = 'commands.completion';
8
- exports.command = 'completion';
9
- exports.describe = i18n(`${i18nKey}.describe`);
10
- exports.handler = async () => {
11
- await trackCommandUsage('completion');
12
- };
13
- exports.builder = yargs => {
14
- const { help } = yargsParser(process.argv.slice(2));
15
- if (!help) {
16
- yargs.completion();
17
- }
18
- yargs.example([
19
- ['$0 completion >> ~/.zshrc', i18n(`${i18nKey}.examples.default`)],
20
- ]);
21
- return yargs;
22
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { addGlobalOptions } = require('../lib/commonOpts');
5
- const list = require('./function/list');
6
- const deploy = require('./function/deploy');
7
- const server = require('./function/server');
8
- const { i18n } = require('../lib/lang');
9
- const i18nKey = 'commands.function';
10
- exports.command = ['function', 'functions'];
11
- exports.describe = i18n(`${i18nKey}.describe`);
12
- exports.builder = yargs => {
13
- addGlobalOptions(yargs);
14
- yargs
15
- .command(list)
16
- .command(deploy)
17
- .command(server)
18
- .demandCommand(1, '');
19
- return yargs;
20
- };
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const secretPrompt_1 = require("../../lib/prompts/secretPrompt");
5
- const promptUtils_1 = require("../../lib/prompts/promptUtils");
6
- const exitCodes_1 = require("../../lib/enums/exitCodes");
7
- const { logger } = require('@hubspot/local-dev-lib/logger');
8
- const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
9
- const { deleteSecret, fetchSecrets, } = require('@hubspot/local-dev-lib/api/secrets');
10
- const { loadAndValidateOptions } = require('../../lib/validation');
11
- const { trackCommandUsage } = require('../../lib/usageTracking');
12
- const { uiAccountDescription } = require('../../lib/ui');
13
- const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
14
- const { i18n } = require('../../lib/lang');
15
- const i18nKey = 'commands.secrets.subcommands.delete';
16
- exports.command = 'delete [name]';
17
- exports.describe = i18n(`${i18nKey}.describe`);
18
- exports.handler = async (options) => {
19
- const { name, derivedAccountId, force } = options;
20
- let secretName = name;
21
- await loadAndValidateOptions(options);
22
- trackCommandUsage('secrets-delete', null, derivedAccountId);
23
- try {
24
- const { data: { results: secrets }, } = await fetchSecrets(derivedAccountId);
25
- if (secretName && !secrets.includes(secretName)) {
26
- logger.error(i18n(`${i18nKey}.errors.noSecret`, { secretName }));
27
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
28
- }
29
- if (!secretName) {
30
- const { secretToModify } = await (0, secretPrompt_1.secretListPrompt)(secrets, i18n(`${i18nKey}.selectSecret`));
31
- secretName = secretToModify;
32
- }
33
- const confirmDelete = force ||
34
- (await (0, promptUtils_1.confirmPrompt)(i18n(`${i18nKey}.confirmDelete`, { secretName }), {
35
- defaultAnswer: false,
36
- }));
37
- if (!confirmDelete) {
38
- logger.success(i18n(`${i18nKey}.deleteCanceled`));
39
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
40
- }
41
- await deleteSecret(derivedAccountId, secretName);
42
- logger.success(i18n(`${i18nKey}.success.delete`, {
43
- accountIdentifier: uiAccountDescription(derivedAccountId),
44
- secretName,
45
- }));
46
- }
47
- catch (err) {
48
- logger.error(i18n(`${i18nKey}.errors.delete`, {
49
- secretName,
50
- }));
51
- logError(err, new ApiErrorContext({
52
- request: 'delete a secret',
53
- accountId: derivedAccountId,
54
- }));
55
- }
56
- };
57
- exports.builder = yargs => {
58
- addConfigOptions(yargs);
59
- addAccountOptions(yargs);
60
- addUseEnvironmentOptions(yargs);
61
- yargs
62
- .positional('name', {
63
- describe: i18n(`${i18nKey}.positionals.name.describe`),
64
- type: 'string',
65
- })
66
- .options('force', {
67
- describe: 'Force the deletion',
68
- type: 'boolean',
69
- });
70
- return yargs;
71
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { addGlobalOptions } = require('../lib/commonOpts');
5
- const addSecretCommand = require('./secret/addSecret');
6
- const listSecretsCommand = require('./secret/listSecrets');
7
- const deleteSecretCommand = require('./secret/deleteSecret');
8
- const updateSecretCommand = require('./secret/updateSecret');
9
- const { i18n } = require('../lib/lang');
10
- const i18nKey = 'commands.secret';
11
- exports.command = ['secret', 'secrets'];
12
- exports.describe = i18n(`${i18nKey}.describe`);
13
- exports.builder = yargs => {
14
- addGlobalOptions(yargs);
15
- yargs
16
- .command(listSecretsCommand)
17
- .command(addSecretCommand)
18
- .command(updateSecretCommand)
19
- .command(deleteSecretCommand)
20
- .demandCommand(1, '');
21
- return yargs;
22
- };
@@ -1,8 +0,0 @@
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>;
@@ -1,69 +0,0 @@
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
- }
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
File without changes