@hubspot/cli 6.4.1-beta.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 (203) 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 +3 -3
  84. package/lib/buildAccount.js +5 -11
  85. package/lib/commonOpts.d.ts +15 -6
  86. package/lib/commonOpts.js +53 -38
  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/developerTestAccounts.d.ts +5 -1
  91. package/lib/developerTestAccounts.js +45 -39
  92. package/lib/doctor/DiagnosticInfoBuilder.js +8 -4
  93. package/lib/doctor/Doctor.js +4 -3
  94. package/lib/generateSelectors.d.ts +19 -0
  95. package/lib/generateSelectors.js +23 -23
  96. package/lib/localDev.js +2 -1
  97. package/lib/marketplaceValidate.d.ts +6 -1
  98. package/lib/marketplaceValidate.js +76 -77
  99. package/lib/oauth.d.ts +2 -1
  100. package/lib/oauth.js +49 -37
  101. package/lib/polling.d.ts +8 -0
  102. package/lib/polling.js +9 -12
  103. package/lib/projects/ProjectLogsManager.d.ts +20 -0
  104. package/lib/projects/ProjectLogsManager.js +105 -0
  105. package/lib/projects/buildAndDeploy.d.ts +16 -0
  106. package/lib/projects/buildAndDeploy.js +342 -0
  107. package/lib/projects/index.d.ts +24 -0
  108. package/lib/projects/index.js +256 -0
  109. package/lib/projects/structure.d.ts +78 -0
  110. package/lib/projects/structure.js +151 -0
  111. package/lib/projects/upload.d.ts +8 -0
  112. package/lib/projects/upload.js +107 -0
  113. package/lib/projects/urls.d.ts +4 -0
  114. package/lib/projects/urls.js +27 -0
  115. package/lib/{projectsWatch.js → projects/watch.js} +3 -3
  116. package/lib/prompts/accountNamePrompt.d.ts +11 -0
  117. package/lib/prompts/accountNamePrompt.js +45 -46
  118. package/lib/prompts/accountsPrompt.d.ts +1 -1
  119. package/lib/prompts/accountsPrompt.js +21 -19
  120. package/lib/prompts/cmsFieldPrompt.d.ts +1 -1
  121. package/lib/prompts/cmsFieldPrompt.js +23 -24
  122. package/lib/prompts/createApiSamplePrompt.d.ts +17 -0
  123. package/lib/prompts/createApiSamplePrompt.js +47 -44
  124. package/lib/prompts/createFunctionPrompt.d.ts +7 -0
  125. package/lib/prompts/createFunctionPrompt.js +17 -20
  126. package/lib/prompts/createModulePrompt.d.ts +8 -0
  127. package/lib/prompts/createModulePrompt.js +29 -17
  128. package/lib/prompts/createProjectPrompt.d.ts +13 -0
  129. package/lib/prompts/createProjectPrompt.js +48 -49
  130. package/lib/prompts/createTemplatePrompt.d.ts +8 -0
  131. package/lib/prompts/createTemplatePrompt.js +15 -17
  132. package/lib/prompts/downloadProjectPrompt.d.ts +8 -0
  133. package/lib/prompts/downloadProjectPrompt.js +25 -23
  134. package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
  135. package/lib/prompts/installPublicAppPrompt.js +21 -19
  136. package/lib/prompts/personalAccessKeyPrompt.d.ts +28 -0
  137. package/lib/prompts/personalAccessKeyPrompt.js +46 -52
  138. package/lib/prompts/previewPrompt.d.ts +14 -0
  139. package/lib/prompts/previewPrompt.js +24 -24
  140. package/lib/prompts/projectAddPrompt.d.ts +9 -0
  141. package/lib/prompts/projectAddPrompt.js +11 -14
  142. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
  143. package/lib/prompts/projectDevTargetAccountPrompt.js +87 -69
  144. package/lib/prompts/projectsLogsPrompt.d.ts +11 -0
  145. package/lib/prompts/projectsLogsPrompt.js +8 -11
  146. package/lib/prompts/promptUtils.d.ts +7 -6
  147. package/lib/prompts/promptUtils.js +21 -8
  148. package/lib/prompts/sandboxesPrompt.d.ts +8 -0
  149. package/lib/prompts/sandboxesPrompt.js +43 -45
  150. package/lib/prompts/secretPrompt.d.ts +12 -0
  151. package/lib/prompts/secretPrompt.js +32 -19
  152. package/lib/prompts/selectHubDBTablePrompt.d.ts +12 -0
  153. package/lib/prompts/selectHubDBTablePrompt.js +69 -0
  154. package/lib/prompts/selectPublicAppPrompt.d.ts +8 -0
  155. package/lib/prompts/selectPublicAppPrompt.js +28 -27
  156. package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -1
  157. package/lib/prompts/setAsDefaultAccountPrompt.js +12 -14
  158. package/lib/prompts/uploadPrompt.d.ts +8 -0
  159. package/lib/prompts/uploadPrompt.js +18 -18
  160. package/lib/sandboxSync.js +5 -2
  161. package/lib/sandboxes.js +12 -7
  162. package/lib/ui/index.d.ts +1 -1
  163. package/lib/ui/index.js +1 -1
  164. package/lib/usageTracking.d.ts +21 -2
  165. package/lib/usageTracking.js +53 -81
  166. package/lib/validation.d.ts +11 -1
  167. package/lib/validation.js +98 -91
  168. package/package.json +12 -6
  169. package/types/Projects.d.ts +43 -0
  170. package/types/Projects.js +2 -0
  171. package/types/Prompts.d.ts +25 -0
  172. package/types/Prompts.js +2 -0
  173. package/commands/accounts.js +0 -30
  174. package/commands/cms/reactModules.js +0 -60
  175. package/commands/functions.js +0 -24
  176. package/commands/secrets/deleteSecret.js +0 -46
  177. package/commands/secrets.js +0 -23
  178. package/lib/ProjectLogsManager.js +0 -91
  179. package/lib/projectStructure.js +0 -116
  180. package/lib/projects.d.ts +0 -4
  181. package/lib/projects.js +0 -681
  182. package/lib/projectsWatch.d.ts +0 -1
  183. package/lib/prompts/cleanUploadPrompt.d.ts +0 -1
  184. package/lib/prompts/cleanUploadPrompt.js +0 -20
  185. /package/commands/{accounts → account}/clean.d.ts +0 -0
  186. /package/commands/{accounts → account}/info.d.ts +0 -0
  187. /package/commands/{accounts → account}/list.d.ts +0 -0
  188. /package/commands/{accounts → account}/remove.d.ts +0 -0
  189. /package/commands/{accounts → account}/rename.d.ts +0 -0
  190. /package/commands/{accounts → account}/use.d.ts +0 -0
  191. /package/commands/{accounts.d.ts → account.d.ts} +0 -0
  192. /package/commands/cms/{reactModules.d.ts → getReactModule.d.ts} +0 -0
  193. /package/commands/{functions.d.ts → completion.d.ts} +0 -0
  194. /package/commands/{functions/list.d.ts → function/deploy.d.ts} +0 -0
  195. /package/commands/{functions/server.d.ts → function/list.d.ts} +0 -0
  196. /package/commands/{secrets.d.ts → function/server.d.ts} +0 -0
  197. /package/commands/{functions/deploy.d.ts → function.d.ts} +0 -0
  198. /package/commands/{secrets/deleteSecret.d.ts → secret/addSecret.d.ts} +0 -0
  199. /package/commands/{secrets/listSecrets.d.ts → secret/deleteSecret.d.ts} +0 -0
  200. /package/commands/{secrets/updateSecret.d.ts → secret/listSecrets.d.ts} +0 -0
  201. /package/{lib/ProjectLogsManager.d.ts → commands/secret/updateSecret.d.ts} +0 -0
  202. /package/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
  203. /package/lib/{projectStructure.d.ts → projects/watch.d.ts} +0 -0
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { getProjectConfig, ensureProjectExists } = require('./projects');
5
- const { fetchProjectComponentsMetadata, } = require('@hubspot/local-dev-lib/api/projects');
6
- const { i18n } = require('./lang');
7
- const { uiLink } = require('./ui');
8
- const i18nKey = 'commands.project.subcommands.logs';
9
- class ProjectLogsManager {
10
- reset() {
11
- Object.keys(this).forEach(key => {
12
- if (Object.hasOwn(this, key)) {
13
- this[key] = undefined;
14
- }
15
- });
16
- }
17
- async init(accountId) {
18
- const { projectConfig } = await getProjectConfig();
19
- if (!projectConfig || !projectConfig.name) {
20
- throw new Error(i18n(`${i18nKey}.errors.noProjectConfig`));
21
- }
22
- const { name: projectName } = projectConfig;
23
- this.projectName = projectName;
24
- this.accountId = accountId;
25
- this.functions = [];
26
- const { project } = await ensureProjectExists(this.accountId, this.projectName, {
27
- allowCreate: false,
28
- });
29
- if (!project ||
30
- !project.deployedBuild ||
31
- !project.deployedBuild.subbuildStatuses) {
32
- throw new Error(i18n(`${i18nKey}.errors.failedToFetchProjectDetails`));
33
- }
34
- this.projectId = project.id;
35
- await this.fetchFunctionDetails();
36
- }
37
- async fetchFunctionDetails() {
38
- if (!this.projectId) {
39
- throw new Error(i18n(`${i18nKey}.errors.noProjectConfig`));
40
- }
41
- const { data: { topLevelComponentMetadata }, } = await fetchProjectComponentsMetadata(this.accountId, this.projectId);
42
- const apps = topLevelComponentMetadata.filter(componentMetadata => {
43
- const { type } = componentMetadata;
44
- return type && type.name === 'PRIVATE_APP';
45
- });
46
- if (!this.functions) {
47
- this.functions = [];
48
- }
49
- apps.forEach(app => {
50
- this.functions.push(...app.featureComponents.filter(component => component.type.name === 'APP_FUNCTION'));
51
- });
52
- if (this.functions.length === 0) {
53
- throw new Error(i18n(`${i18nKey}.errors.noFunctionsInProject`, {
54
- link: uiLink(i18n(`${i18nKey}.errors.noFunctionsLinkText`), 'https://developers.hubspot.com/docs/platform/serverless-functions'),
55
- }));
56
- }
57
- }
58
- getFunctionNames() {
59
- if (!this.functions) {
60
- return [];
61
- }
62
- return this.functions.map(serverlessFunction => serverlessFunction.componentName);
63
- }
64
- setFunction(functionName) {
65
- if (!this.functions) {
66
- throw new Error(i18n(`${i18nKey}.errors.noFunctionsInProject`, {
67
- link: uiLink(i18n(`${i18nKey}.errors.noFunctionsLinkText`), 'https://developers.hubspot.com/docs/platform/serverless-functions'),
68
- }), {
69
- projectName: this.projectName,
70
- });
71
- }
72
- this.selectedFunction = this.functions.find(serverlessFunction => serverlessFunction.componentName === functionName);
73
- if (!this.selectedFunction) {
74
- throw new Error(i18n(`${i18nKey}.errors.noFunctionWithName`, { name: functionName }));
75
- }
76
- this.functionName = functionName;
77
- if (!this.selectedFunction.deployOutput) {
78
- throw new Error(i18n(`${i18nKey}.errors.functionNotDeployed`, { name: functionName }));
79
- }
80
- this.appId = this.selectedFunction.deployOutput.appId;
81
- if (this.selectedFunction.deployOutput.endpoint) {
82
- this.endpointName = this.selectedFunction.deployOutput.endpoint.path;
83
- this.method = this.selectedFunction.deployOutput.endpoint.method;
84
- this.isPublicFunction = true;
85
- }
86
- else {
87
- this.isPublicFunction = false;
88
- }
89
- }
90
- }
91
- module.exports = new ProjectLogsManager();
@@ -1,116 +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 { walk } = require('@hubspot/local-dev-lib/fs');
7
- const { logger } = require('@hubspot/local-dev-lib/logger');
8
- const { logError } = require('./errorHandlers/index');
9
- const COMPONENT_TYPES = Object.freeze({
10
- privateApp: 'private-app',
11
- publicApp: 'public-app',
12
- hublTheme: 'hubl-theme',
13
- });
14
- const CONFIG_FILES = {
15
- [COMPONENT_TYPES.privateApp]: 'app.json',
16
- [COMPONENT_TYPES.publicApp]: 'public-app.json',
17
- [COMPONENT_TYPES.hublTheme]: 'theme.json',
18
- };
19
- function getTypeFromConfigFile(configFile) {
20
- for (const key in CONFIG_FILES) {
21
- if (CONFIG_FILES[key] === configFile) {
22
- return key;
23
- }
24
- }
25
- return null;
26
- }
27
- function loadConfigFile(configPath) {
28
- if (configPath) {
29
- try {
30
- const source = fs.readFileSync(configPath);
31
- const parsedConfig = JSON.parse(source);
32
- return parsedConfig;
33
- }
34
- catch (e) {
35
- logger.debug(e);
36
- }
37
- }
38
- return null;
39
- }
40
- function getAppCardConfigs(appConfig, appPath) {
41
- const cardConfigs = [];
42
- let cards;
43
- if (appConfig && appConfig.extensions && appConfig.extensions.crm) {
44
- cards = appConfig.extensions.crm.cards;
45
- }
46
- if (cards) {
47
- cards.forEach(({ file }) => {
48
- if (typeof file === 'string') {
49
- const cardConfigPath = path.join(appPath, file);
50
- const cardConfig = loadConfigFile(cardConfigPath);
51
- if (cardConfig) {
52
- cardConfigs.push(cardConfig);
53
- }
54
- }
55
- });
56
- }
57
- return cardConfigs;
58
- }
59
- function getIsLegacyApp(appConfig, appPath) {
60
- const cardConfigs = getAppCardConfigs(appConfig, appPath);
61
- if (!cardConfigs.length) {
62
- // Assume any app that does not have any cards is not legacy
63
- return false;
64
- }
65
- let hasAnyReactExtensions = false;
66
- cardConfigs.forEach(cardConfig => {
67
- if (!hasAnyReactExtensions) {
68
- const isReactExtension = cardConfig &&
69
- !!cardConfig.data &&
70
- !!cardConfig.data.module &&
71
- !!cardConfig.data.module.file;
72
- hasAnyReactExtensions = isReactExtension;
73
- }
74
- });
75
- return !hasAnyReactExtensions;
76
- }
77
- async function findProjectComponents(projectSourceDir) {
78
- const components = [];
79
- let projectFiles = [];
80
- try {
81
- projectFiles = await walk(projectSourceDir);
82
- }
83
- catch (e) {
84
- logError(e);
85
- }
86
- projectFiles.forEach(projectFile => {
87
- // Find app components
88
- const { base, dir } = path.parse(projectFile);
89
- if (Object.values(CONFIG_FILES).includes(base)) {
90
- const parsedAppConfig = loadConfigFile(projectFile);
91
- if (parsedAppConfig) {
92
- const isLegacy = getIsLegacyApp(parsedAppConfig, dir);
93
- const isHublTheme = base === CONFIG_FILES[COMPONENT_TYPES.hublTheme];
94
- components.push({
95
- type: getTypeFromConfigFile(base),
96
- config: parsedAppConfig,
97
- runnable: !isLegacy && !isHublTheme,
98
- path: dir,
99
- });
100
- }
101
- }
102
- });
103
- return components;
104
- }
105
- function getProjectComponentTypes(components) {
106
- const projectContents = {};
107
- components.forEach(({ type }) => (projectContents[type] = true));
108
- return projectContents;
109
- }
110
- module.exports = {
111
- CONFIG_FILES,
112
- COMPONENT_TYPES,
113
- findProjectComponents,
114
- getAppCardConfigs,
115
- getProjectComponentTypes,
116
- };
package/lib/projects.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare const getProjectConfig: (_dir: any) => Promise<{
2
- projectDir: any;
3
- projectConfig: any;
4
- } | undefined>;