@hubspot/cli 6.4.0 → 7.0.0-beta.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 (205) hide show
  1. package/bin/cli.js +110 -16
  2. package/bin/hs +2 -0
  3. package/bin/hscms +2 -0
  4. package/bin/silenceErrors.d.ts +2 -0
  5. package/bin/silenceErrors.js +12 -0
  6. package/commands/{accounts → account}/clean.js +10 -11
  7. package/commands/{accounts → account}/info.js +10 -16
  8. package/commands/{accounts → account}/list.js +16 -16
  9. package/commands/{accounts → account}/remove.js +12 -15
  10. package/commands/{accounts → account}/rename.js +4 -7
  11. package/commands/{accounts → account}/use.js +8 -14
  12. package/commands/account.js +26 -0
  13. package/commands/auth.js +30 -24
  14. package/commands/cms/getReactModule.js +70 -0
  15. package/commands/cms/lighthouseScore.js +19 -21
  16. package/commands/cms.js +4 -3
  17. package/commands/completion.js +22 -0
  18. package/commands/config/set.js +22 -24
  19. package/commands/config.js +2 -2
  20. package/commands/create.js +6 -3
  21. package/commands/customObject/create.js +19 -15
  22. package/commands/customObject/schema/create.js +15 -16
  23. package/commands/customObject/schema/delete.js +29 -11
  24. package/commands/customObject/schema/fetch-all.js +14 -11
  25. package/commands/customObject/schema/fetch.js +22 -14
  26. package/commands/customObject/schema/list.js +3 -6
  27. package/commands/customObject/schema/update.js +28 -18
  28. package/commands/customObject/schema.js +1 -1
  29. package/commands/customObject.js +3 -4
  30. package/commands/doctor.js +4 -2
  31. package/commands/feedback.js +2 -0
  32. package/commands/fetch.js +13 -13
  33. package/commands/filemanager/fetch.js +6 -7
  34. package/commands/filemanager/upload.js +10 -12
  35. package/commands/filemanager.js +1 -8
  36. package/commands/{functions → function}/deploy.js +13 -13
  37. package/commands/{functions → function}/list.js +7 -9
  38. package/commands/{functions → function}/server.js +5 -8
  39. package/commands/function.js +16 -0
  40. package/commands/hubdb/clear.js +14 -10
  41. package/commands/hubdb/create.js +37 -13
  42. package/commands/hubdb/delete.js +31 -10
  43. package/commands/hubdb/fetch.js +14 -9
  44. package/commands/hubdb.js +2 -3
  45. package/commands/init.js +37 -14
  46. package/commands/lint.js +6 -7
  47. package/commands/list.js +5 -7
  48. package/commands/logs.js +24 -15
  49. package/commands/module/marketplace-validate.js +6 -9
  50. package/commands/module.js +2 -1
  51. package/commands/mv.js +11 -13
  52. package/commands/open.js +11 -10
  53. package/commands/project/add.js +2 -5
  54. package/commands/project/cloneApp.js +28 -32
  55. package/commands/project/create.js +8 -10
  56. package/commands/project/deploy.js +19 -16
  57. package/commands/project/dev.js +17 -18
  58. package/commands/project/download.js +18 -15
  59. package/commands/project/listBuilds.js +36 -32
  60. package/commands/project/logs.js +6 -8
  61. package/commands/project/migrateApp.js +27 -27
  62. package/commands/project/open.js +9 -11
  63. package/commands/project/upload.js +30 -32
  64. package/commands/project/watch.js +17 -24
  65. package/commands/project.js +3 -4
  66. package/commands/remove.js +14 -13
  67. package/commands/sandbox/create.js +12 -15
  68. package/commands/sandbox/delete.js +19 -20
  69. package/commands/sandbox.js +4 -8
  70. package/commands/{secrets → secret}/addSecret.js +25 -12
  71. package/commands/secret/deleteSecret.js +71 -0
  72. package/commands/{secrets → secret}/listSecrets.js +7 -9
  73. package/commands/{secrets → secret}/updateSecret.js +21 -13
  74. package/commands/secret.js +22 -0
  75. package/commands/theme/generate-selectors.js +8 -8
  76. package/commands/theme/marketplace-validate.js +10 -13
  77. package/commands/theme/preview.js +7 -10
  78. package/commands/theme.js +3 -1
  79. package/commands/upload.js +32 -26
  80. package/commands/watch.js +19 -20
  81. package/lang/en.lyaml +200 -126
  82. package/lib/DevServerManager.js +1 -1
  83. package/lib/LocalDevManager.js +4 -4
  84. package/lib/buildAccount.js +5 -11
  85. package/lib/commonOpts.d.ts +15 -6
  86. package/lib/commonOpts.js +53 -39
  87. package/lib/configOptions.d.ts +13 -1
  88. package/lib/configOptions.js +54 -57
  89. package/lib/constants.d.ts +1 -4
  90. package/lib/dependencyManagement.d.ts +4 -1
  91. package/lib/dependencyManagement.js +2 -2
  92. package/lib/developerTestAccounts.d.ts +5 -1
  93. package/lib/developerTestAccounts.js +45 -39
  94. package/lib/doctor/DiagnosticInfoBuilder.js +8 -4
  95. package/lib/doctor/Doctor.js +11 -6
  96. package/lib/generateSelectors.d.ts +19 -0
  97. package/lib/generateSelectors.js +23 -23
  98. package/lib/localDev.js +3 -2
  99. package/lib/marketplaceValidate.d.ts +6 -1
  100. package/lib/marketplaceValidate.js +76 -77
  101. package/lib/oauth.d.ts +2 -1
  102. package/lib/oauth.js +49 -37
  103. package/lib/polling.d.ts +8 -0
  104. package/lib/polling.js +9 -12
  105. package/lib/projects/ProjectLogsManager.d.ts +20 -0
  106. package/lib/projects/ProjectLogsManager.js +105 -0
  107. package/lib/projects/buildAndDeploy.d.ts +16 -0
  108. package/lib/projects/buildAndDeploy.js +342 -0
  109. package/lib/projects/index.d.ts +24 -0
  110. package/lib/projects/index.js +256 -0
  111. package/lib/projects/structure.d.ts +78 -0
  112. package/lib/projects/structure.js +151 -0
  113. package/lib/projects/upload.d.ts +8 -0
  114. package/lib/projects/upload.js +107 -0
  115. package/lib/projects/urls.d.ts +4 -0
  116. package/lib/projects/urls.js +27 -0
  117. package/lib/{projectsWatch.js → projects/watch.js} +3 -3
  118. package/lib/prompts/accountNamePrompt.d.ts +11 -0
  119. package/lib/prompts/accountNamePrompt.js +45 -46
  120. package/lib/prompts/accountsPrompt.d.ts +1 -1
  121. package/lib/prompts/accountsPrompt.js +21 -19
  122. package/lib/prompts/cmsFieldPrompt.d.ts +1 -1
  123. package/lib/prompts/cmsFieldPrompt.js +23 -24
  124. package/lib/prompts/createApiSamplePrompt.d.ts +17 -0
  125. package/lib/prompts/createApiSamplePrompt.js +47 -44
  126. package/lib/prompts/createFunctionPrompt.d.ts +7 -0
  127. package/lib/prompts/createFunctionPrompt.js +17 -20
  128. package/lib/prompts/createModulePrompt.d.ts +8 -0
  129. package/lib/prompts/createModulePrompt.js +29 -17
  130. package/lib/prompts/createProjectPrompt.d.ts +13 -0
  131. package/lib/prompts/createProjectPrompt.js +48 -49
  132. package/lib/prompts/createTemplatePrompt.d.ts +8 -0
  133. package/lib/prompts/createTemplatePrompt.js +15 -17
  134. package/lib/prompts/downloadProjectPrompt.d.ts +8 -0
  135. package/lib/prompts/downloadProjectPrompt.js +25 -23
  136. package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
  137. package/lib/prompts/installPublicAppPrompt.js +21 -19
  138. package/lib/prompts/personalAccessKeyPrompt.d.ts +28 -0
  139. package/lib/prompts/personalAccessKeyPrompt.js +46 -52
  140. package/lib/prompts/previewPrompt.d.ts +14 -0
  141. package/lib/prompts/previewPrompt.js +24 -24
  142. package/lib/prompts/projectAddPrompt.d.ts +9 -0
  143. package/lib/prompts/projectAddPrompt.js +11 -14
  144. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
  145. package/lib/prompts/projectDevTargetAccountPrompt.js +87 -69
  146. package/lib/prompts/projectsLogsPrompt.d.ts +11 -0
  147. package/lib/prompts/projectsLogsPrompt.js +8 -11
  148. package/lib/prompts/promptUtils.d.ts +7 -6
  149. package/lib/prompts/promptUtils.js +21 -8
  150. package/lib/prompts/sandboxesPrompt.d.ts +8 -0
  151. package/lib/prompts/sandboxesPrompt.js +43 -45
  152. package/lib/prompts/secretPrompt.d.ts +12 -0
  153. package/lib/prompts/secretPrompt.js +32 -19
  154. package/lib/prompts/selectHubDBTablePrompt.d.ts +12 -0
  155. package/lib/prompts/selectHubDBTablePrompt.js +69 -0
  156. package/lib/prompts/selectPublicAppPrompt.d.ts +8 -0
  157. package/lib/prompts/selectPublicAppPrompt.js +28 -27
  158. package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -1
  159. package/lib/prompts/setAsDefaultAccountPrompt.js +12 -14
  160. package/lib/prompts/uploadPrompt.d.ts +8 -0
  161. package/lib/prompts/uploadPrompt.js +18 -18
  162. package/lib/sandboxSync.js +5 -2
  163. package/lib/sandboxes.js +12 -7
  164. package/lib/ui/index.d.ts +1 -1
  165. package/lib/ui/index.js +1 -1
  166. package/lib/usageTracking.d.ts +21 -2
  167. package/lib/usageTracking.js +53 -81
  168. package/lib/validation.d.ts +11 -1
  169. package/lib/validation.js +98 -91
  170. package/package.json +12 -6
  171. package/types/Projects.d.ts +43 -0
  172. package/types/Projects.js +2 -0
  173. package/types/Prompts.d.ts +25 -0
  174. package/types/Prompts.js +2 -0
  175. package/commands/accounts.js +0 -30
  176. package/commands/cms/reactModules.js +0 -60
  177. package/commands/functions.js +0 -24
  178. package/commands/secrets/deleteSecret.js +0 -46
  179. package/commands/secrets.js +0 -23
  180. package/lib/ProjectLogsManager.js +0 -91
  181. package/lib/projectStructure.js +0 -116
  182. package/lib/projects.d.ts +0 -4
  183. package/lib/projects.js +0 -681
  184. package/lib/projectsWatch.d.ts +0 -1
  185. package/lib/prompts/cleanUploadPrompt.d.ts +0 -1
  186. package/lib/prompts/cleanUploadPrompt.js +0 -20
  187. /package/commands/{accounts → account}/clean.d.ts +0 -0
  188. /package/commands/{accounts → account}/info.d.ts +0 -0
  189. /package/commands/{accounts → account}/list.d.ts +0 -0
  190. /package/commands/{accounts → account}/remove.d.ts +0 -0
  191. /package/commands/{accounts → account}/rename.d.ts +0 -0
  192. /package/commands/{accounts → account}/use.d.ts +0 -0
  193. /package/commands/{accounts.d.ts → account.d.ts} +0 -0
  194. /package/commands/cms/{reactModules.d.ts → getReactModule.d.ts} +0 -0
  195. /package/commands/{functions.d.ts → completion.d.ts} +0 -0
  196. /package/commands/{functions/list.d.ts → function/deploy.d.ts} +0 -0
  197. /package/commands/{functions/server.d.ts → function/list.d.ts} +0 -0
  198. /package/commands/{secrets.d.ts → function/server.d.ts} +0 -0
  199. /package/commands/{functions/deploy.d.ts → function.d.ts} +0 -0
  200. /package/commands/{secrets/deleteSecret.d.ts → secret/addSecret.d.ts} +0 -0
  201. /package/commands/{secrets/listSecrets.d.ts → secret/deleteSecret.d.ts} +0 -0
  202. /package/commands/{secrets/updateSecret.d.ts → secret/listSecrets.d.ts} +0 -0
  203. /package/{lib/ProjectLogsManager.d.ts → commands/secret/updateSecret.d.ts} +0 -0
  204. /package/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
  205. /package/lib/{projectStructure.d.ts → projects/watch.d.ts} +0 -0
@@ -1,71 +1,69 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { promptUser } = require('./promptUtils');
5
- const { i18n } = require('../lang');
6
- const { uiAccountDescription } = require('../ui');
7
- const { HUBSPOT_ACCOUNT_TYPES, } = require('@hubspot/local-dev-lib/constants/config');
8
- const { isSandbox } = require('../accountTypes');
3
+ exports.sandboxTypePrompt = sandboxTypePrompt;
4
+ exports.deleteSandboxPrompt = deleteSandboxPrompt;
5
+ const promptUtils_1 = require("./promptUtils");
6
+ const lang_1 = require("../lang");
7
+ const ui_1 = require("../ui");
8
+ const config_1 = require("@hubspot/local-dev-lib/constants/config");
9
+ const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
10
+ const accountTypes_1 = require("../accountTypes");
11
+ const config_2 = require("@hubspot/local-dev-lib/config");
9
12
  const i18nKey = 'lib.prompts.sandboxesPrompt';
10
- const mapSandboxAccountChoices = portals => portals
11
- .filter(p => isSandbox(p))
12
- .map(p => {
13
- return {
14
- name: uiAccountDescription(p.portalId, false),
15
- value: p.name || p.portalId,
16
- };
17
- });
18
- const mapNonSandboxAccountChoices = portals => portals
19
- .filter(p => !isSandbox(p))
20
- .map(p => {
21
- return {
22
- name: `${p.name} (${p.portalId})`,
23
- value: p.name || p.portalId,
24
- };
25
- });
26
- const sandboxTypePrompt = () => {
27
- return promptUser([
13
+ function mapSandboxAccountChoices(portals) {
14
+ return (portals
15
+ ?.filter(p => (0, accountTypes_1.isSandbox)(p))
16
+ .map(p => ({
17
+ name: (0, ui_1.uiAccountDescription)((0, getAccountIdentifier_1.getAccountIdentifier)(p), false),
18
+ value: p.name || (0, getAccountIdentifier_1.getAccountIdentifier)(p),
19
+ })) || []);
20
+ }
21
+ function mapNonSandboxAccountChoices(portals) {
22
+ return (portals
23
+ ?.filter(p => !(0, accountTypes_1.isSandbox)(p))
24
+ .map(p => ({
25
+ name: `${p.name} (${(0, getAccountIdentifier_1.getAccountIdentifier)(p)})`,
26
+ value: p.name || (0, getAccountIdentifier_1.getAccountIdentifier)(p),
27
+ })) || []);
28
+ }
29
+ async function sandboxTypePrompt() {
30
+ return (0, promptUtils_1.promptUser)([
28
31
  {
29
32
  name: 'type',
30
- message: i18n(`${i18nKey}.type.message`),
33
+ message: (0, lang_1.i18n)(`${i18nKey}.type.message`),
31
34
  type: 'list',
32
- look: false,
33
35
  choices: [
34
36
  {
35
- name: i18n(`${i18nKey}.type.developer`),
36
- value: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
37
+ name: (0, lang_1.i18n)(`${i18nKey}.type.developer`),
38
+ value: config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
37
39
  },
38
40
  {
39
- name: i18n(`${i18nKey}.type.standard`),
40
- value: HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
41
+ name: (0, lang_1.i18n)(`${i18nKey}.type.standard`),
42
+ value: config_1.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
41
43
  },
42
44
  ],
43
- default: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
45
+ default: config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
44
46
  },
45
47
  ]);
46
- };
47
- const deleteSandboxPrompt = (config, promptParentAccount = false) => {
48
+ }
49
+ function deleteSandboxPrompt(promptParentAccount = false) {
50
+ const accountsList = (0, config_2.getConfigAccounts)();
48
51
  const choices = promptParentAccount
49
- ? mapNonSandboxAccountChoices(config.portals)
50
- : mapSandboxAccountChoices(config.portals);
52
+ ? mapNonSandboxAccountChoices(accountsList)
53
+ : mapSandboxAccountChoices(accountsList);
51
54
  if (!choices.length) {
52
- return undefined;
55
+ return;
53
56
  }
54
- return promptUser([
57
+ return (0, promptUtils_1.promptUser)([
55
58
  {
56
59
  name: 'account',
57
- message: i18n(promptParentAccount
60
+ message: (0, lang_1.i18n)(promptParentAccount
58
61
  ? `${i18nKey}.selectParentAccountName`
59
62
  : `${i18nKey}.selectAccountName`),
60
63
  type: 'list',
61
- look: false,
62
64
  pageSize: 20,
63
65
  choices,
64
- default: config.defaultPortal,
66
+ default: (0, config_2.getConfigDefaultAccount)(),
65
67
  },
66
68
  ]);
67
- };
68
- module.exports = {
69
- sandboxTypePrompt,
70
- deleteSandboxPrompt,
71
- };
69
+ }
@@ -1 +1,13 @@
1
+ type SecretValuePromptResponse = {
2
+ secretValue: string;
3
+ };
4
+ export declare function secretValuePrompt(): Promise<SecretValuePromptResponse>;
5
+ type SecretNamePromptResponse = {
6
+ secretName: string;
7
+ };
8
+ export declare function secretNamePrompt(): Promise<SecretNamePromptResponse>;
9
+ type SecretListPromptResponse = {
10
+ secretToModify: string;
11
+ };
12
+ export declare function secretListPrompt(secrets: string[], message: string): Promise<SecretListPromptResponse>;
1
13
  export {};
@@ -1,24 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { promptUser } = require('./promptUtils');
5
- const { i18n } = require('../lang');
3
+ exports.secretValuePrompt = secretValuePrompt;
4
+ exports.secretNamePrompt = secretNamePrompt;
5
+ exports.secretListPrompt = secretListPrompt;
6
+ const promptUtils_1 = require("./promptUtils");
7
+ const lang_1 = require("../lang");
6
8
  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
- };
19
9
  function secretValuePrompt() {
20
- return promptUser([SECRET_VALUE_PROMPT]);
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
+ ]);
21
37
  }
22
- module.exports = {
23
- secretValuePrompt,
24
- };
@@ -0,0 +1,12 @@
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<{
9
+ tableId: any;
10
+ } & {
11
+ dest: any;
12
+ }>;
@@ -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 +1,9 @@
1
+ type PublicAppPromptResponse = {
2
+ appId: number;
3
+ };
4
+ export declare function selectPublicAppPrompt({ accountId, accountName, isMigratingApp, }: {
5
+ accountId: number | null;
6
+ accountName: string;
7
+ isMigratingApp?: boolean;
8
+ }): Promise<PublicAppPromptResponse>;
1
9
  export {};
@@ -1,17 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { promptUser } = require('./promptUtils');
5
- const { i18n } = require('../lang');
6
- const { uiLine } = require('../ui');
7
- const { logError } = require('../errorHandlers/index');
8
- const { logger } = require('@hubspot/local-dev-lib/logger');
9
- const { fetchPublicAppsForPortal, } = require('@hubspot/local-dev-lib/api/appsDev');
10
- const { EXIT_CODES } = require('../enums/exitCodes');
3
+ exports.selectPublicAppPrompt = selectPublicAppPrompt;
4
+ const promptUtils_1 = require("./promptUtils");
5
+ const lang_1 = require("../lang");
6
+ const ui_1 = require("../ui");
7
+ const index_1 = require("../errorHandlers/index");
8
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
9
+ const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
10
+ const exitCodes_1 = require("../enums/exitCodes");
11
11
  const i18nKey = 'lib.prompts.selectPublicAppPrompt';
12
- const fetchPublicAppOptions = async (accountId, accountName, isMigratingApp = false) => {
12
+ async function fetchPublicAppOptions(accountId, accountName, isMigratingApp = false) {
13
13
  try {
14
- const { data: { results: publicApps }, } = await fetchPublicAppsForPortal(accountId);
14
+ if (!accountId) {
15
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noAccountId`));
16
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
17
+ }
18
+ const { data: { results: publicApps }, } = await (0, appsDev_1.fetchPublicAppsForPortal)(accountId);
15
19
  const filteredPublicApps = publicApps.filter(app => !app.projectId && !app.sourceId);
16
20
  if (!filteredPublicApps.length ||
17
21
  (isMigratingApp &&
@@ -22,29 +26,29 @@ const fetchPublicAppOptions = async (accountId, accountName, isMigratingApp = fa
22
26
  const messageTranslationKey = isMigratingApp
23
27
  ? 'noAppsMigrationMessage'
24
28
  : 'noAppsCloneMessage';
25
- uiLine();
26
- logger.error(i18n(`${i18nKey}.errors.${headerTranslationKey}`));
27
- logger.log(i18n(`${i18nKey}.errors.${messageTranslationKey}`, { accountName }));
28
- uiLine();
29
- process.exit(EXIT_CODES.SUCCESS);
29
+ (0, ui_1.uiLine)();
30
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.${headerTranslationKey}`));
31
+ logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.errors.${messageTranslationKey}`, { accountName }));
32
+ (0, ui_1.uiLine)();
33
+ process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
30
34
  }
31
35
  return filteredPublicApps;
32
36
  }
33
37
  catch (error) {
34
- logError(error, { accountId });
35
- logger.error(i18n(`${i18nKey}.errors.errorFetchingApps`));
36
- process.exit(EXIT_CODES.ERROR);
38
+ (0, index_1.logError)(error, accountId ? { accountId } : undefined);
39
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.errorFetchingApps`));
40
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
37
41
  }
38
- };
39
- const selectPublicAppPrompt = async ({ accountId, accountName, isMigratingApp = false, }) => {
42
+ }
43
+ async function selectPublicAppPrompt({ accountId, accountName, isMigratingApp = false, }) {
40
44
  const publicApps = await fetchPublicAppOptions(accountId, accountName, isMigratingApp);
41
45
  const translationKey = isMigratingApp
42
46
  ? 'selectAppIdMigrate'
43
47
  : 'selectAppIdClone';
44
- return promptUser([
48
+ return (0, promptUtils_1.promptUser)([
45
49
  {
46
50
  name: 'appId',
47
- message: i18n(`${i18nKey}.${translationKey}`, {
51
+ message: (0, lang_1.i18n)(`${i18nKey}.${translationKey}`, {
48
52
  accountName,
49
53
  }),
50
54
  type: 'list',
@@ -53,7 +57,7 @@ const selectPublicAppPrompt = async ({ accountId, accountName, isMigratingApp =
53
57
  if (isMigratingApp && preventProjectMigrations && listingInfo) {
54
58
  return {
55
59
  name: `${app.name} (${app.id})`,
56
- disabled: i18n(`${i18nKey}.errors.cannotBeMigrated`),
60
+ disabled: (0, lang_1.i18n)(`${i18nKey}.errors.cannotBeMigrated`),
57
61
  };
58
62
  }
59
63
  return {
@@ -63,7 +67,4 @@ const selectPublicAppPrompt = async ({ accountId, accountName, isMigratingApp =
63
67
  }),
64
68
  },
65
69
  ]);
66
- };
67
- module.exports = {
68
- selectPublicAppPrompt,
69
- };
70
+ }
@@ -1 +1 @@
1
- export {};
1
+ export declare function setAsDefaultAccountPrompt(accountName: string): Promise<boolean>;
@@ -1,25 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { getConfig, updateDefaultAccount, } = require('@hubspot/local-dev-lib/config');
5
- const { promptUser } = require('./promptUtils');
6
- const { i18n } = require('../lang');
3
+ exports.setAsDefaultAccountPrompt = setAsDefaultAccountPrompt;
4
+ const config_1 = require("@hubspot/local-dev-lib/config");
5
+ const promptUtils_1 = require("./promptUtils");
6
+ const lang_1 = require("../lang");
7
7
  const i18nKey = 'lib.prompts.setAsDefaultAccountPrompt';
8
- const setAsDefaultAccountPrompt = async (accountName) => {
9
- const config = getConfig();
10
- const { setAsDefault } = await promptUser([
8
+ async function setAsDefaultAccountPrompt(accountName) {
9
+ // Accounts for deprecated and new config
10
+ const defaultAccount = (0, config_1.getConfigDefaultAccount)();
11
+ const { setAsDefault } = await (0, promptUtils_1.promptUser)([
11
12
  {
12
13
  name: 'setAsDefault',
13
14
  type: 'confirm',
14
- when: config.defaultPortal !== accountName,
15
- message: i18n(`${i18nKey}.setAsDefaultAccountMessage`),
15
+ when: defaultAccount !== accountName,
16
+ message: (0, lang_1.i18n)(`${i18nKey}.setAsDefaultAccountMessage`),
16
17
  },
17
18
  ]);
18
19
  if (setAsDefault) {
19
- updateDefaultAccount(accountName);
20
+ (0, config_1.updateDefaultAccount)(accountName);
20
21
  }
21
22
  return setAsDefault;
22
- };
23
- module.exports = {
24
- setAsDefaultAccountPrompt,
25
- };
23
+ }
@@ -1 +1,9 @@
1
+ type UploadPromptResponse = {
2
+ src: string;
3
+ dest: string;
4
+ };
5
+ export declare function uploadPrompt(promptOptions?: {
6
+ src?: string;
7
+ dest?: string;
8
+ }): Promise<UploadPromptResponse>;
1
9
  export {};
@@ -1,39 +1,39 @@
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 path = require('path');
5
- const { getCwd } = require('@hubspot/local-dev-lib/path');
6
- const { promptUser } = require('./promptUtils');
7
- const { i18n } = require('../lang');
6
+ exports.uploadPrompt = uploadPrompt;
7
+ const path_1 = __importDefault(require("path"));
8
+ const path_2 = require("@hubspot/local-dev-lib/path");
9
+ const promptUtils_1 = require("./promptUtils");
10
+ const lang_1 = require("../lang");
8
11
  const i18nKey = 'lib.prompts.uploadPrompt';
9
- const uploadPrompt = (promptOptions = {}) => {
10
- return promptUser([
12
+ async function uploadPrompt(promptOptions = {}) {
13
+ return (0, promptUtils_1.promptUser)([
11
14
  {
12
15
  name: 'src',
13
- message: i18n(`${i18nKey}.enterSrc`),
16
+ message: (0, lang_1.i18n)(`${i18nKey}.enterSrc`),
14
17
  when: !promptOptions.src,
15
18
  default: '.',
16
- validate: input => {
19
+ validate: (input) => {
17
20
  if (!input) {
18
- return i18n(`${i18nKey}.errors.srcRequired`);
21
+ return (0, lang_1.i18n)(`${i18nKey}.errors.srcRequired`);
19
22
  }
20
23
  return true;
21
24
  },
22
25
  },
23
26
  {
24
27
  name: 'dest',
25
- message: i18n(`${i18nKey}.enterDest`),
28
+ message: (0, lang_1.i18n)(`${i18nKey}.enterDest`),
26
29
  when: !promptOptions.dest,
27
- default: path.basename(getCwd()),
28
- validate: input => {
30
+ default: path_1.default.basename((0, path_2.getCwd)()),
31
+ validate: (input) => {
29
32
  if (!input) {
30
- return i18n(`${i18nKey}.errors.destRequired`);
33
+ return (0, lang_1.i18n)(`${i18nKey}.errors.destRequired`);
31
34
  }
32
35
  return true;
33
36
  },
34
37
  },
35
38
  ]);
36
- };
37
- module.exports = {
38
- uploadPrompt,
39
- };
39
+ }
@@ -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/ui/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare const UI_COLORS: {
5
5
  };
6
6
  export declare function uiLine(): void;
7
7
  export declare function uiLink(linkText: string, url: string): string;
8
- export declare function uiAccountDescription(accountId: number, bold?: boolean): string;
8
+ export declare function uiAccountDescription(accountId?: number | null, bold?: boolean): string;
9
9
  export declare function uiInfoSection(title: string, logContent: () => void): void;
10
10
  export declare function uiCommandReference(command: string): string;
11
11
  export declare function uiFeatureHighlight(commands: string[], title: string): void;
package/lib/ui/index.js CHANGED
@@ -55,7 +55,7 @@ function uiLink(linkText, url) {
55
55
  : `${linkText}: ${encodedUrl}`;
56
56
  }
57
57
  function uiAccountDescription(accountId, bold = true) {
58
- const account = (0, config_1.getAccountConfig)(accountId);
58
+ const account = (0, config_1.getAccountConfig)(accountId || undefined);
59
59
  let message;
60
60
  if (account && account.accountType) {
61
61
  message = `${account.name} [${HUBSPOT_ACCOUNT_TYPE_STRINGS[account.accountType]}] (${accountId})`;
@@ -1,2 +1,21 @@
1
- export declare function trackCommandUsage(command: any, meta: {} | undefined, accountId: any): void;
2
- export declare function trackCommandMetadataUsage(command: any, meta: {} | undefined, accountId: any): void;
1
+ type Meta = {
2
+ action?: string;
3
+ os?: string;
4
+ nodeVersion?: string;
5
+ nodeMajorVersion?: string;
6
+ version?: string;
7
+ command?: string;
8
+ authType?: string;
9
+ step?: string;
10
+ assetType?: string;
11
+ mode?: string;
12
+ type?: string | number;
13
+ file?: boolean;
14
+ successful?: boolean;
15
+ };
16
+ export declare function trackCommandUsage(command: string, meta?: Meta, accountId?: number): Promise<void>;
17
+ export declare function trackHelpUsage(command: string): Promise<void>;
18
+ export declare function trackConvertFieldsUsage(command: string): Promise<void>;
19
+ export declare function trackAuthAction(command: string, authType: string, step: string, accountId: number): Promise<void>;
20
+ export declare function trackCommandMetadataUsage(command: string, meta?: Meta, accountId?: number): Promise<void>;
21
+ export {};