@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,43 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.trackCommandUsage = trackCommandUsage;
4
+ exports.trackHelpUsage = trackHelpUsage;
5
+ exports.trackConvertFieldsUsage = trackConvertFieldsUsage;
6
+ exports.trackAuthAction = trackAuthAction;
4
7
  exports.trackCommandMetadataUsage = trackCommandMetadataUsage;
5
- // @ts-nocheck
6
- const { trackUsage } = require('@hubspot/local-dev-lib/trackUsage');
7
- const { isTrackingAllowed, getAccountConfig, } = require('@hubspot/local-dev-lib/config');
8
- const { API_KEY_AUTH_METHOD, } = require('@hubspot/local-dev-lib/constants/auth');
9
- const { logger } = require('@hubspot/local-dev-lib/logger');
10
- const { version } = require('../package.json');
11
- const { setLogLevel } = require('./commonOpts');
12
- /* **
13
- Available tracking meta properties
14
-
15
- - action: "The specific action taken in the CLI"
16
- - os: "The user's OS"
17
- - nodeVersion: "The user's version of node.js"
18
- - nodeMajorVersion: "The user's major version of node.js"
19
- - version: "The user's version of the CLI"
20
- - command: "The specific command that the user ran in this interaction"
21
- - authType: "The configured auth type the user has for the CLI"
22
- - step: "The specific step in the auth process"
23
- - assetType: "The CMS asset type"
24
- - mode: "The CLI mode (draft or publish"
25
- - type: "The upload type (file or folder)"
26
- - file: "Whether or not the 'file' flag was used"
27
- - successful: "Whether or not the CLI interaction was successful"
28
-
29
- */
8
+ const trackUsage_1 = require("@hubspot/local-dev-lib/trackUsage");
9
+ const config_1 = require("@hubspot/local-dev-lib/config");
10
+ const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
11
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
12
+ const package_json_1 = require("../package.json");
13
+ const errorHandlers_1 = require("./errorHandlers");
30
14
  const EventClass = {
31
15
  USAGE: 'USAGE',
32
16
  INTERACTION: 'INTERACTION',
33
17
  VIEW: 'VIEW',
34
18
  ACTIVATION: 'ACTIVATION',
35
19
  };
36
- const getNodeVersionData = () => ({
37
- nodeVersion: process.version,
38
- nodeMajorVersion: (process.version || '').split('.')[0],
39
- });
40
- const getPlatform = () => {
20
+ function getNodeVersionData() {
21
+ return {
22
+ nodeVersion: process.version,
23
+ nodeMajorVersion: (process.version || '').split('.')[0],
24
+ };
25
+ }
26
+ function getPlatform() {
41
27
  switch (process.platform) {
42
28
  case 'darwin':
43
29
  return 'macos';
@@ -46,144 +32,130 @@ const getPlatform = () => {
46
32
  default:
47
33
  return process.platform;
48
34
  }
49
- };
50
- function trackCommandUsage(command, meta = {}, accountId) {
51
- if (!isTrackingAllowed()) {
35
+ }
36
+ async function trackCommandUsage(command, meta = {}, accountId) {
37
+ if (!(0, config_1.isTrackingAllowed)()) {
52
38
  return;
53
39
  }
54
- logger.debug('Attempting to track usage of "%s" command', command);
40
+ logger_1.logger.debug('Attempting to track usage of "%s" command', command);
55
41
  let authType = 'unknown';
56
42
  if (accountId) {
57
- const accountConfig = getAccountConfig(accountId);
43
+ const accountConfig = (0, config_1.getAccountConfig)(accountId);
58
44
  authType =
59
45
  accountConfig && accountConfig.authType
60
46
  ? accountConfig.authType
61
- : API_KEY_AUTH_METHOD.value;
47
+ : auth_1.API_KEY_AUTH_METHOD.value;
62
48
  }
63
49
  setImmediate(async () => {
64
50
  const usageTrackingEvent = {
65
51
  action: 'cli-command',
66
52
  os: getPlatform(),
67
53
  ...getNodeVersionData(),
68
- version,
54
+ version: package_json_1.version,
69
55
  command,
70
56
  authType,
71
57
  ...meta,
72
58
  };
73
59
  try {
74
- await trackUsage('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
75
- logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
60
+ await (0, trackUsage_1.trackUsage)('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
61
+ logger_1.logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
76
62
  }
77
63
  catch (e) {
78
- logger.debug('Usage tracking failed: %s', e.message);
64
+ (0, errorHandlers_1.debugError)(e);
79
65
  }
80
66
  });
81
67
  }
82
68
  async function trackHelpUsage(command) {
83
- if (!isTrackingAllowed()) {
69
+ if (!(0, config_1.isTrackingAllowed)()) {
84
70
  return;
85
71
  }
86
72
  try {
87
73
  if (command) {
88
- logger.debug('Tracking help usage of "%s" sub-command', command);
74
+ logger_1.logger.debug('Tracking help usage of "%s" sub-command', command);
89
75
  }
90
76
  else {
91
- logger.debug('Tracking help usage of main command');
77
+ logger_1.logger.debug('Tracking help usage of main command');
92
78
  }
93
- await trackUsage('cli-interaction', EventClass.INTERACTION, {
79
+ await (0, trackUsage_1.trackUsage)('cli-interaction', EventClass.INTERACTION, {
94
80
  action: 'cli-help',
95
81
  os: getPlatform(),
96
82
  ...getNodeVersionData(),
97
- version,
83
+ version: package_json_1.version,
98
84
  command,
99
85
  });
100
86
  }
101
87
  catch (e) {
102
- logger.debug('Usage tracking failed: %s', e.message);
88
+ (0, errorHandlers_1.debugError)(e);
103
89
  }
104
90
  }
105
91
  async function trackConvertFieldsUsage(command) {
106
- if (!isTrackingAllowed()) {
92
+ if (!(0, config_1.isTrackingAllowed)()) {
107
93
  return;
108
94
  }
109
95
  try {
110
- logger.debug('Attempting to track usage of "%s" command', command);
111
- await trackUsage('cli-interaction', EventClass.INTERACTION, {
96
+ logger_1.logger.debug('Attempting to track usage of "%s" command', command);
97
+ await (0, trackUsage_1.trackUsage)('cli-interaction', EventClass.INTERACTION, {
112
98
  action: 'cli-process-fields',
113
99
  os: getPlatform(),
114
100
  ...getNodeVersionData(),
115
- version,
101
+ version: package_json_1.version,
116
102
  command,
117
103
  });
118
104
  }
119
105
  catch (e) {
120
- logger.debug('Usage tracking failed: %s', e.message);
106
+ (0, errorHandlers_1.debugError)(e);
121
107
  }
122
108
  }
123
- const addHelpUsageTracking = (program, command) => {
124
- program.on('--help', () => {
125
- setLogLevel(program);
126
- trackHelpUsage(command);
127
- });
128
- };
129
- const trackAuthAction = async (command, authType, step, accountId) => {
130
- if (!isTrackingAllowed()) {
109
+ async function trackAuthAction(command, authType, step, accountId) {
110
+ if (!(0, config_1.isTrackingAllowed)()) {
131
111
  return;
132
112
  }
133
113
  const usageTrackingEvent = {
134
114
  action: 'cli-auth',
135
115
  os: getPlatform(),
136
116
  ...getNodeVersionData(),
137
- version,
117
+ version: package_json_1.version,
138
118
  command,
139
119
  authType,
140
120
  step,
141
121
  };
142
122
  try {
143
- await trackUsage('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
144
- logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
123
+ await (0, trackUsage_1.trackUsage)('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
124
+ logger_1.logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
145
125
  }
146
126
  catch (e) {
147
- logger.debug('Auth action tracking failed: %s', e.message);
127
+ (0, errorHandlers_1.debugError)(e);
148
128
  }
149
- };
150
- function trackCommandMetadataUsage(command, meta = {}, accountId) {
151
- if (!isTrackingAllowed()) {
129
+ }
130
+ async function trackCommandMetadataUsage(command, meta = {}, accountId) {
131
+ if (!(0, config_1.isTrackingAllowed)()) {
152
132
  return;
153
133
  }
154
- logger.debug('Attempting to track metadata usage of "%s" command', command);
134
+ logger_1.logger.debug('Attempting to track metadata usage of "%s" command', command);
155
135
  let authType = 'unknown';
156
136
  if (accountId) {
157
- const accountConfig = getAccountConfig(accountId);
137
+ const accountConfig = (0, config_1.getAccountConfig)(accountId);
158
138
  authType =
159
139
  accountConfig && accountConfig.authType
160
140
  ? accountConfig.authType
161
- : API_KEY_AUTH_METHOD.value;
141
+ : auth_1.API_KEY_AUTH_METHOD.value;
162
142
  }
163
143
  setImmediate(async () => {
164
144
  const usageTrackingEvent = {
165
145
  action: 'cli-command-metadata',
166
146
  os: getPlatform(),
167
147
  ...getNodeVersionData(),
168
- version,
148
+ version: package_json_1.version,
169
149
  command,
170
150
  authType,
171
151
  ...meta,
172
152
  };
173
153
  try {
174
- await trackUsage('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
175
- logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
154
+ await (0, trackUsage_1.trackUsage)('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
155
+ logger_1.logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
176
156
  }
177
157
  catch (e) {
178
- logger.debug('Metadata usage tracking failed: %s', e.message);
158
+ (0, errorHandlers_1.debugError)(e);
179
159
  }
180
160
  });
181
161
  }
182
- module.exports = {
183
- trackCommandUsage,
184
- trackHelpUsage,
185
- addHelpUsageTracking,
186
- trackConvertFieldsUsage,
187
- trackAuthAction,
188
- trackCommandMetadataUsage,
189
- };
@@ -1 +1,11 @@
1
- export {};
1
+ import { Arguments } from 'yargs';
2
+ import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
3
+ export declare function validateAccount(options: Arguments<{
4
+ account?: string;
5
+ accountId?: string;
6
+ }>): Promise<boolean>;
7
+ export declare function validateCmsPublishMode(options: Arguments<{
8
+ cmsPublishMode?: CmsPublishMode;
9
+ }>): boolean;
10
+ export declare function fileExists(_path: string): boolean;
11
+ export declare function checkAndConvertToJson(_path: string): object | null;
package/lib/validation.js CHANGED
@@ -1,163 +1,177 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const fs = require('fs');
5
- const path = require('path');
6
- const { logger } = require('@hubspot/local-dev-lib/logger');
7
- const { MODE } = require('@hubspot/local-dev-lib/constants/files');
8
- const { API_KEY_AUTH_METHOD, OAUTH_AUTH_METHOD, PERSONAL_ACCESS_KEY_AUTH_METHOD, } = require('@hubspot/local-dev-lib/constants/auth');
9
- const { commaSeparatedValues } = require('@hubspot/local-dev-lib/text');
10
- const { loadConfig, getConfigPath, validateConfig, getAccountConfig, loadConfigFromEnvironment, } = require('@hubspot/local-dev-lib/config');
11
- const { getOauthManager } = require('@hubspot/local-dev-lib/oauth');
12
- const { accessTokenForPersonalAccessKey, } = require('@hubspot/local-dev-lib/personalAccessKey');
13
- const { getAbsoluteFilePath, getCwd, getExt, } = require('@hubspot/local-dev-lib/path');
14
- const { getAccountId, getMode, setLogLevel } = require('./commonOpts');
15
- const { EXIT_CODES } = require('./enums/exitCodes');
16
- const { checkAndWarnGitInclusion } = require('./ui/git');
17
- const { logError } = require('./errorHandlers/index');
18
- async function loadAndValidateOptions(options, shouldValidateAccount = true) {
19
- setLogLevel(options);
20
- const { config: configPath } = options;
21
- loadConfig(configPath, options);
22
- checkAndWarnGitInclusion(getConfigPath());
23
- let validAccount = true;
24
- if (shouldValidateAccount) {
25
- validAccount = await validateAccount(options);
26
- }
27
- if (!(validateConfig() && validAccount)) {
28
- process.exit(EXIT_CODES.ERROR);
29
- }
30
- }
31
- /**
32
- * Validate that an account was passed to the command and that the account's configuration is valid
33
- *
34
- *
35
- * @param {object} command options
36
- * @returns {boolean}
37
- */
36
+ exports.validateAccount = validateAccount;
37
+ exports.validateCmsPublishMode = validateCmsPublishMode;
38
+ exports.fileExists = fileExists;
39
+ exports.checkAndConvertToJson = checkAndConvertToJson;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
43
+ const files_1 = require("@hubspot/local-dev-lib/constants/files");
44
+ const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
45
+ const text_1 = require("@hubspot/local-dev-lib/text");
46
+ const config_1 = require("@hubspot/local-dev-lib/config");
47
+ const oauth_1 = require("@hubspot/local-dev-lib/oauth");
48
+ const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
49
+ const path_1 = require("@hubspot/local-dev-lib/path");
50
+ const commonOpts_1 = require("./commonOpts");
51
+ const index_1 = require("./errorHandlers/index");
38
52
  async function validateAccount(options) {
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;
53
+ const accountId = (0, commonOpts_1.getAccountId)(options);
54
+ const { accountId: accountIdOption, account: accountOption } = options;
43
55
  if (!accountId) {
44
56
  if (accountOption) {
45
- logger.error(`The account "${accountOption}" could not be found in the config`);
57
+ logger_1.logger.error(`The account "${accountOption}" could not be found in the config`);
46
58
  }
47
59
  else if (accountIdOption) {
48
- logger.error(`The account "${accountIdOption}" could not be found in the config`);
60
+ logger_1.logger.error(`The account "${accountIdOption}" could not be found in the config`);
49
61
  }
50
62
  else {
51
- logger.error('An account needs to be supplied either via "--account" or through setting a "defaultPortal"');
63
+ logger_1.logger.error('An account needs to be supplied either via "--account" or through setting a "defaultPortal"');
52
64
  }
53
65
  return false;
54
66
  }
55
- if (accountOption && loadConfigFromEnvironment()) {
67
+ if (accountOption && (0, config_1.loadConfigFromEnvironment)()) {
56
68
  throw new Error('Cannot specify an account when environment variables are supplied. Please unset the environment variables or do not use the "--account" flag.');
57
69
  }
58
- const accountConfig = getAccountConfig(accountId);
70
+ const accountConfig = (0, config_1.getAccountConfig)(accountId);
59
71
  if (!accountConfig) {
60
- logger.error(`The account ${accountId} has not been configured`);
72
+ logger_1.logger.error(`The account ${accountId} has not been configured`);
61
73
  return false;
62
74
  }
63
75
  const { authType, auth, apiKey, personalAccessKey } = accountConfig;
64
76
  if (typeof authType === 'string' && authType !== authType.toLowerCase()) {
65
- logger.error(`Invalid "authType" value "${authType}" for account "${accountId}" in config file: ${getConfigPath()}. Valid values are ${commaSeparatedValues([
66
- PERSONAL_ACCESS_KEY_AUTH_METHOD,
67
- OAUTH_AUTH_METHOD,
68
- API_KEY_AUTH_METHOD,
77
+ logger_1.logger.error(`Invalid "authType" value "${authType}" for account "${accountId}" in config file: ${(0, config_1.getConfigPath)()}. Valid values are ${(0, text_1.commaSeparatedValues)([
78
+ auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD,
79
+ auth_1.OAUTH_AUTH_METHOD,
80
+ auth_1.API_KEY_AUTH_METHOD,
69
81
  ].map(method => method.value))}.`);
70
82
  }
71
83
  if (authType === 'oauth2') {
72
84
  if (typeof auth !== 'object') {
73
- logger.error(`The OAuth2 auth configuration for account ${accountId} is missing`);
85
+ logger_1.logger.error(`The OAuth2 auth configuration for account ${accountId} is missing`);
74
86
  return false;
75
87
  }
76
88
  const { clientId, clientSecret, tokenInfo } = auth;
77
89
  if (!clientId || !clientSecret || !tokenInfo || !tokenInfo.refreshToken) {
78
- logger.error(`The OAuth2 configuration for account ${accountId} is incorrect`);
79
- logger.error('Run "hs auth --type=oauth2" to reauthenticate');
90
+ logger_1.logger.error(`The OAuth2 configuration for account ${accountId} is incorrect`);
91
+ logger_1.logger.error('Run "hs auth --type=oauth2" to reauthenticate');
80
92
  return false;
81
93
  }
82
- const oauth = getOauthManager(accountId, accountConfig);
94
+ const oauth = (0, oauth_1.getOauthManager)(accountId, accountConfig);
83
95
  try {
84
- const accessToken = await oauth.accessToken();
96
+ let accessToken;
97
+ if (oauth) {
98
+ accessToken = await oauth.accessToken();
99
+ }
85
100
  if (!accessToken) {
86
- logger.error(`The OAuth2 access token could not be found for accountId ${accountId}`);
101
+ logger_1.logger.error(`The OAuth2 access token could not be found for accountId ${accountId}`);
87
102
  return false;
88
103
  }
89
104
  }
90
105
  catch (e) {
91
- logger.error(e.message);
106
+ (0, index_1.logError)(e);
92
107
  return false;
93
108
  }
94
109
  }
95
110
  else if (authType === 'personalaccesskey') {
96
111
  if (!personalAccessKey) {
97
- logger.error(`The account "${accountId}" is configured to use a access key for authentication and is missing a "personalAccessKey" in the configuration file`);
112
+ logger_1.logger.error(`The account "${accountId}" is configured to use a access key for authentication and is missing a "personalAccessKey" in the configuration file`);
98
113
  return false;
99
114
  }
100
115
  try {
101
- const accessToken = await accessTokenForPersonalAccessKey(accountId);
116
+ const accessToken = await (0, personalAccessKey_1.accessTokenForPersonalAccessKey)(accountId);
102
117
  if (!accessToken) {
103
- logger.error(`An OAuth2 access token for account "${accountId} could not be retrieved using the "personalAccessKey" provided`);
118
+ logger_1.logger.error(`An OAuth2 access token for account "${accountId} could not be retrieved using the "personalAccessKey" provided`);
104
119
  return false;
105
120
  }
106
121
  }
107
122
  catch (e) {
108
- logError(e);
123
+ (0, index_1.logError)(e);
109
124
  return false;
110
125
  }
111
126
  }
112
127
  else if (!apiKey) {
113
- logger.error(`The accountId ${accountId} is missing authentication configuration`);
128
+ logger_1.logger.error(`The accountId ${accountId} is missing authentication configuration`);
114
129
  return false;
115
130
  }
116
131
  return true;
117
132
  }
118
- /**
119
- * @param {object} command options
120
- * @returns {boolean}
121
- */
122
- function validateMode(options) {
123
- const mode = getMode(options);
124
- if (MODE[mode]) {
133
+ function validateCmsPublishMode(options) {
134
+ const cmsPublishMode = (0, commonOpts_1.getCmsPublishMode)(options);
135
+ if (files_1.CMS_PUBLISH_MODE[cmsPublishMode]) {
125
136
  return true;
126
137
  }
127
- const modesMessage = `Available modes are: ${Object.values(MODE).join(', ')}.`;
128
- if (mode != null) {
129
- logger.error([`The mode "${mode}" is invalid.`, modesMessage].join(' '));
138
+ const modesMessage = `Available CMS publish modes are: ${Object.values(files_1.CMS_PUBLISH_MODE).join(', ')}.`;
139
+ if (cmsPublishMode != null) {
140
+ logger_1.logger.error([
141
+ `The CMS publish mode "${cmsPublishMode}" is invalid.`,
142
+ modesMessage,
143
+ ].join(' '));
130
144
  }
131
145
  else {
132
- logger.error(['The mode option is missing.', modesMessage].join(' '));
146
+ logger_1.logger.error(['The CMS publish mode option is missing.', modesMessage].join(' '));
133
147
  }
134
148
  return false;
135
149
  }
136
- const fileExists = _path => {
150
+ function fileExists(_path) {
137
151
  let isFile;
138
152
  try {
139
- const absoluteSrcPath = path.resolve(getCwd(), _path);
153
+ const absoluteSrcPath = path.resolve((0, path_1.getCwd)(), _path);
140
154
  if (!absoluteSrcPath)
141
155
  return false;
142
156
  const stats = fs.statSync(absoluteSrcPath);
143
157
  isFile = stats.isFile();
144
158
  if (!isFile) {
145
- logger.error(`The path "${_path}" is not a path to a file`);
159
+ logger_1.logger.error(`The path "${_path}" is not a path to a file`);
146
160
  return false;
147
161
  }
148
162
  }
149
163
  catch (e) {
150
- logger.error(`The path "${_path}" is not a path to a file`);
164
+ logger_1.logger.error(`The path "${_path}" is not a path to a file`);
151
165
  return false;
152
166
  }
153
167
  return true;
154
- };
155
- const checkAndConvertToJson = _path => {
156
- const filePath = getAbsoluteFilePath(_path);
168
+ }
169
+ function checkAndConvertToJson(_path) {
170
+ const filePath = (0, path_1.getAbsoluteFilePath)(_path);
157
171
  if (!fileExists(filePath))
158
- return false;
159
- if (getExt(_path) !== 'json') {
160
- logger.error(`The file "${_path}" must be a valid JSON file`);
172
+ return null;
173
+ if ((0, path_1.getExt)(_path) !== 'json') {
174
+ logger_1.logger.error(`The file "${_path}" must be a valid JSON file`);
161
175
  return null;
162
176
  }
163
177
  let result;
@@ -165,15 +179,8 @@ const checkAndConvertToJson = _path => {
165
179
  result = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
166
180
  }
167
181
  catch (e) {
168
- logger.error(`The file "${_path}" contains invalid JSON`);
182
+ logger_1.logger.error(`The file "${_path}" contains invalid JSON`);
169
183
  result = null;
170
184
  }
171
185
  return result;
172
- };
173
- module.exports = {
174
- validateMode,
175
- validateAccount,
176
- checkAndConvertToJson,
177
- fileExists,
178
- loadAndValidateOptions,
179
- };
186
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-beta.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.1.0",
9
9
  "@hubspot/serverless-dev-runtime": "7.0.0",
10
- "@hubspot/theme-preview-dev-server": "0.0.9",
10
+ "@hubspot/theme-preview-dev-server": "0.0.10",
11
11
  "@hubspot/ui-extensions-dev-server": "0.8.33",
12
12
  "archiver": "^7.0.1",
13
13
  "chalk": "^4.1.2",
@@ -26,13 +26,18 @@
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": {
33
+ "@types/archiver": "^6.0.3",
34
+ "@types/express": "^5.0.0",
35
+ "@types/findup-sync": "^4.0.5",
32
36
  "@types/fs-extra": "^11.0.4",
33
37
  "@types/jest": "^29.5.14",
34
38
  "@types/js-yaml": "^4.0.9",
35
39
  "@types/semver": "^7.5.8",
40
+ "@types/tmp": "^0.2.6",
36
41
  "@types/yargs": "^17.0.33",
37
42
  "@typescript-eslint/eslint-plugin": "^8.11.0",
38
43
  "@typescript-eslint/parser": "^8.11.0",
@@ -44,7 +49,7 @@
44
49
  "lint-staged": "^10.5.4",
45
50
  "madge": "^8.0.0",
46
51
  "mock-stdin": "^1.0.0",
47
- "prettier": "^1.19.1",
52
+ "prettier": "^3.4.2",
48
53
  "semver": "^7.6.3",
49
54
  "ts-jest": "^29.2.5",
50
55
  "ts-node": "^10.9.2",
@@ -56,7 +61,8 @@
56
61
  "scripts": {
57
62
  "build": "ts-node ./scripts/build.ts",
58
63
  "lint": "eslint . && prettier --list-different ./**/*.{js,json}",
59
- "prettier:write": "prettier --write ./**/*.{js,json}",
64
+ "list-all-commands": "yarn ts-node ./scripts/get-all-commands.ts",
65
+ "prettier:write": "prettier --write ./**/*.{ts,js,json}",
60
66
  "test": "jest",
61
67
  "test-cli": "yarn --cwd 'acceptance-tests' test-ci",
62
68
  "test-cli-debug": "yarn --cwd 'acceptance-tests' test-debug",
@@ -0,0 +1,43 @@
1
+ import { Build, SubbuildStatus } from '@hubspot/local-dev-lib/types/Build';
2
+ import { Deploy, SubdeployStatus } from '@hubspot/local-dev-lib/types/Deploy';
3
+ export type ProjectTemplate = {
4
+ name: string;
5
+ label: string;
6
+ path: string;
7
+ insertPath: string;
8
+ };
9
+ export type ComponentTemplate = {
10
+ label: string;
11
+ path: string;
12
+ insertPath: string;
13
+ };
14
+ export type ProjectConfig = {
15
+ name: string;
16
+ srcDir: string;
17
+ platformVersion: string;
18
+ };
19
+ export type ProjectTaskStates = {
20
+ BUILDING?: string;
21
+ ENQUEUED?: string;
22
+ DEPLOYING?: string;
23
+ FAILURE: string;
24
+ PENDING: string;
25
+ SUCCESS: string;
26
+ };
27
+ export type ProjectTask = Build | Deploy;
28
+ export type ProjectSubtask = SubbuildStatus | SubdeployStatus;
29
+ export type ProjectPollStatusFunctionText = {
30
+ STATES: ProjectTaskStates;
31
+ STATUS_TEXT: string;
32
+ TYPE_KEY: string;
33
+ SUBTASK_NAME_KEY: string;
34
+ };
35
+ export type ProjectAddComponentData = {
36
+ path: string;
37
+ label: string;
38
+ insertPath: string;
39
+ };
40
+ export type ProjectTemplateRepoConfig = {
41
+ projects?: ProjectTemplate[];
42
+ components?: ComponentTemplate[];
43
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,25 @@
1
+ export type GenericPromptResponse = {
2
+ [key: string]: any;
3
+ };
4
+ type PromptType = 'confirm' | 'list' | 'checkbox' | 'input' | 'password' | 'number' | 'rawlist';
5
+ export type PromptChoices = Array<string | {
6
+ name: string;
7
+ value?: any;
8
+ disabled?: string | boolean;
9
+ }>;
10
+ export type PromptWhen = boolean | (() => boolean);
11
+ type PromptOperand = string | number | boolean | string[] | boolean[] | null;
12
+ export type PromptConfig<T extends GenericPromptResponse> = {
13
+ name: keyof T;
14
+ type?: PromptType;
15
+ message?: string | ((answers: T) => string);
16
+ choices?: PromptChoices;
17
+ when?: PromptWhen;
18
+ pageSize?: number;
19
+ default?: PromptOperand | ((answers: T) => PromptOperand);
20
+ transformer?: (input: string) => string | undefined;
21
+ validate?: (answer?: any) => PromptOperand | Promise<PromptOperand>;
22
+ mask?: string;
23
+ filter?: (input: string) => string;
24
+ };
25
+ export {};