@hubspot/cli 6.2.0 → 6.2.2-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 (344) hide show
  1. package/README.md +12 -95
  2. package/bin/cli.d.ts +2 -0
  3. package/bin/cli.js +107 -128
  4. package/commands/accounts/clean.d.ts +1 -0
  5. package/commands/accounts/clean.js +82 -116
  6. package/commands/accounts/info.d.ts +1 -0
  7. package/commands/accounts/info.js +32 -43
  8. package/commands/accounts/list.d.ts +1 -0
  9. package/commands/accounts/list.js +65 -92
  10. package/commands/accounts/remove.d.ts +1 -0
  11. package/commands/accounts/remove.js +43 -73
  12. package/commands/accounts/rename.d.ts +1 -0
  13. package/commands/accounts/rename.js +26 -41
  14. package/commands/accounts/use.d.ts +1 -0
  15. package/commands/accounts/use.js +36 -57
  16. package/commands/accounts.d.ts +1 -0
  17. package/commands/accounts.js +16 -18
  18. package/commands/auth.d.ts +1 -0
  19. package/commands/auth.js +133 -200
  20. package/commands/cms/convertFields.d.ts +1 -0
  21. package/commands/cms/convertFields.js +66 -81
  22. package/commands/cms/lighthouseScore.d.ts +1 -0
  23. package/commands/cms/lighthouseScore.js +236 -298
  24. package/commands/cms/reactModules.d.ts +1 -0
  25. package/commands/cms/reactModules.js +46 -53
  26. package/commands/cms.d.ts +1 -0
  27. package/commands/cms.js +11 -13
  28. package/commands/config/set.d.ts +1 -0
  29. package/commands/config/set.js +64 -79
  30. package/commands/config.d.ts +1 -0
  31. package/commands/config.js +7 -9
  32. package/commands/create/api-sample.d.ts +1 -0
  33. package/commands/create/api-sample.js +54 -74
  34. package/commands/create/app.d.ts +1 -0
  35. package/commands/create/app.js +8 -7
  36. package/commands/create/function.d.ts +1 -0
  37. package/commands/create/function.js +15 -14
  38. package/commands/create/index.d.ts +1 -0
  39. package/commands/create/index.js +12 -9
  40. package/commands/create/module.d.ts +1 -0
  41. package/commands/create/module.js +21 -19
  42. package/commands/create/react-app.d.ts +1 -0
  43. package/commands/create/react-app.js +7 -6
  44. package/commands/create/template.d.ts +1 -0
  45. package/commands/create/template.js +23 -24
  46. package/commands/create/vue-app.d.ts +1 -0
  47. package/commands/create/vue-app.js +7 -6
  48. package/commands/create/webpack-serverless.d.ts +1 -0
  49. package/commands/create/webpack-serverless.js +7 -6
  50. package/commands/create/website-theme.d.ts +1 -0
  51. package/commands/create/website-theme.js +15 -15
  52. package/commands/create.d.ts +24 -0
  53. package/commands/create.js +65 -80
  54. package/commands/customObject/create.d.ts +1 -0
  55. package/commands/customObject/create.js +33 -47
  56. package/commands/customObject/schema/create.d.ts +1 -0
  57. package/commands/customObject/schema/create.js +42 -67
  58. package/commands/customObject/schema/delete.d.ts +1 -0
  59. package/commands/customObject/schema/delete.js +28 -39
  60. package/commands/customObject/schema/fetch-all.d.ts +1 -0
  61. package/commands/customObject/schema/fetch-all.js +30 -39
  62. package/commands/customObject/schema/fetch.d.ts +1 -0
  63. package/commands/customObject/schema/fetch.js +48 -63
  64. package/commands/customObject/schema/list.d.ts +1 -0
  65. package/commands/customObject/schema/list.js +14 -17
  66. package/commands/customObject/schema/update.d.ts +1 -0
  67. package/commands/customObject/schema/update.js +46 -72
  68. package/commands/customObject/schema.d.ts +1 -0
  69. package/commands/customObject/schema.js +12 -12
  70. package/commands/customObject.d.ts +1 -0
  71. package/commands/customObject.js +14 -22
  72. package/commands/feedback.d.ts +1 -0
  73. package/commands/feedback.js +25 -33
  74. package/commands/fetch.d.ts +1 -0
  75. package/commands/fetch.js +53 -78
  76. package/commands/filemanager/fetch.d.ts +1 -0
  77. package/commands/filemanager/fetch.js +38 -56
  78. package/commands/filemanager/upload.d.ts +1 -0
  79. package/commands/filemanager/upload.js +88 -128
  80. package/commands/filemanager.d.ts +1 -0
  81. package/commands/filemanager.js +12 -18
  82. package/commands/functions/deploy.d.ts +1 -0
  83. package/commands/functions/deploy.js +76 -99
  84. package/commands/functions/list.d.ts +1 -0
  85. package/commands/functions/list.js +41 -48
  86. package/commands/functions/server.d.ts +1 -0
  87. package/commands/functions/server.js +50 -65
  88. package/commands/functions.d.ts +1 -0
  89. package/commands/functions.js +13 -15
  90. package/commands/hubdb/clear.d.ts +1 -0
  91. package/commands/hubdb/clear.js +37 -56
  92. package/commands/hubdb/create.d.ts +1 -0
  93. package/commands/hubdb/create.js +34 -57
  94. package/commands/hubdb/delete.d.ts +1 -0
  95. package/commands/hubdb/delete.js +29 -44
  96. package/commands/hubdb/fetch.d.ts +1 -0
  97. package/commands/hubdb/fetch.js +30 -46
  98. package/commands/hubdb.d.ts +1 -0
  99. package/commands/hubdb.js +12 -14
  100. package/commands/init.d.ts +1 -0
  101. package/commands/init.js +103 -160
  102. package/commands/lint.d.ts +1 -0
  103. package/commands/lint.js +34 -45
  104. package/commands/list.d.ts +1 -0
  105. package/commands/list.js +74 -101
  106. package/commands/logs.d.ts +1 -0
  107. package/commands/logs.js +98 -121
  108. package/commands/module/marketplace-validate.d.ts +1 -0
  109. package/commands/module/marketplace-validate.js +32 -57
  110. package/commands/module.d.ts +1 -0
  111. package/commands/module.js +7 -9
  112. package/commands/mv.d.ts +1 -0
  113. package/commands/mv.js +53 -71
  114. package/commands/open.d.ts +1 -0
  115. package/commands/open.js +48 -62
  116. package/commands/project/add.d.ts +1 -0
  117. package/commands/project/add.js +47 -70
  118. package/commands/project/cloneApp.d.ts +1 -0
  119. package/commands/project/cloneApp.js +119 -180
  120. package/commands/project/create.d.ts +1 -0
  121. package/commands/project/create.js +49 -81
  122. package/commands/project/deploy.d.ts +1 -0
  123. package/commands/project/deploy.js +105 -182
  124. package/commands/project/dev.d.ts +1 -0
  125. package/commands/project/dev.js +126 -227
  126. package/commands/project/download.d.ts +1 -0
  127. package/commands/project/download.js +73 -123
  128. package/commands/project/installDeps.d.ts +1 -0
  129. package/commands/project/installDeps.js +52 -59
  130. package/commands/project/listBuilds.d.ts +1 -0
  131. package/commands/project/listBuilds.js +97 -139
  132. package/commands/project/logs.d.ts +1 -0
  133. package/commands/project/logs.js +86 -128
  134. package/commands/project/migrateApp.d.ts +1 -0
  135. package/commands/project/migrateApp.js +158 -248
  136. package/commands/project/open.d.ts +1 -0
  137. package/commands/project/open.js +44 -68
  138. package/commands/project/upload.d.ts +1 -0
  139. package/commands/project/upload.js +72 -116
  140. package/commands/project/watch.d.ts +1 -0
  141. package/commands/project/watch.js +94 -152
  142. package/commands/project.d.ts +1 -0
  143. package/commands/project.js +21 -23
  144. package/commands/remove.d.ts +1 -0
  145. package/commands/remove.js +28 -43
  146. package/commands/sandbox/create.d.ts +1 -0
  147. package/commands/sandbox/create.js +143 -187
  148. package/commands/sandbox/delete.d.ts +1 -0
  149. package/commands/sandbox/delete.js +166 -221
  150. package/commands/sandbox.d.ts +1 -0
  151. package/commands/sandbox.js +10 -12
  152. package/commands/secrets/addSecret.d.ts +1 -0
  153. package/commands/secrets/addSecret.js +34 -52
  154. package/commands/secrets/deleteSecret.d.ts +1 -0
  155. package/commands/secrets/deleteSecret.js +33 -50
  156. package/commands/secrets/listSecrets.d.ts +1 -0
  157. package/commands/secrets/listSecrets.js +28 -42
  158. package/commands/secrets/updateSecret.d.ts +1 -0
  159. package/commands/secrets/updateSecret.js +35 -53
  160. package/commands/secrets.d.ts +1 -0
  161. package/commands/secrets.js +12 -13
  162. package/commands/theme/generate-selectors.d.ts +1 -0
  163. package/commands/theme/generate-selectors.js +129 -192
  164. package/commands/theme/marketplace-validate.d.ts +1 -0
  165. package/commands/theme/marketplace-validate.js +32 -57
  166. package/commands/theme/preview.d.ts +1 -0
  167. package/commands/theme/preview.js +170 -195
  168. package/commands/theme.d.ts +1 -0
  169. package/commands/theme.js +9 -11
  170. package/commands/upload.d.ts +1 -0
  171. package/commands/upload.js +199 -287
  172. package/commands/watch.d.ts +1 -0
  173. package/commands/watch.js +128 -172
  174. package/lang/en.lyaml +2 -3
  175. package/lib/DevServerManager.d.ts +1 -0
  176. package/lib/DevServerManager.js +99 -124
  177. package/lib/LocalDevManager.d.ts +1 -0
  178. package/lib/LocalDevManager.js +322 -490
  179. package/lib/accountTypes.d.ts +7 -0
  180. package/lib/accountTypes.js +32 -34
  181. package/lib/buildAccount.d.ts +1 -0
  182. package/lib/buildAccount.js +132 -179
  183. package/lib/commonOpts.d.ts +1 -0
  184. package/lib/commonOpts.js +60 -91
  185. package/lib/configOptions.d.ts +1 -0
  186. package/lib/configOptions.js +110 -0
  187. package/lib/constants.d.ts +84 -0
  188. package/lib/constants.js +64 -91
  189. package/lib/debugInfo.d.ts +1 -0
  190. package/lib/debugInfo.js +14 -13
  191. package/lib/dependencyManagement.d.ts +1 -0
  192. package/lib/dependencyManagement.js +92 -132
  193. package/lib/developerTestAccounts.d.ts +1 -0
  194. package/lib/developerTestAccounts.js +67 -91
  195. package/lib/enums/exitCodes.d.ts +5 -0
  196. package/lib/enums/exitCodes.js +7 -8
  197. package/lib/environment.d.ts +1 -0
  198. package/lib/environment.js +13 -14
  199. package/lib/errorHandlers/index.d.ts +1 -0
  200. package/lib/errorHandlers/index.js +66 -80
  201. package/lib/errorHandlers/suppressError.d.ts +1 -0
  202. package/lib/errorHandlers/suppressError.js +66 -106
  203. package/lib/filesystem.d.ts +2 -0
  204. package/lib/filesystem.js +22 -28
  205. package/lib/generate-selectors.d.ts +1 -0
  206. package/lib/generate-selectors.js +102 -138
  207. package/lib/hasFeature.d.ts +1 -0
  208. package/lib/hasFeature.js +8 -15
  209. package/lib/hasFlag.d.ts +1 -0
  210. package/lib/hasFlag.js +13 -13
  211. package/lib/hublValidate.d.ts +2 -0
  212. package/lib/hublValidate.js +28 -28
  213. package/lib/interpolation.d.ts +1 -0
  214. package/lib/interpolation.js +50 -92
  215. package/lib/interpolationHelpers.d.ts +10 -0
  216. package/lib/interpolationHelpers.js +30 -22
  217. package/lib/lang.d.ts +1 -0
  218. package/lib/lang.js +52 -78
  219. package/lib/links.d.ts +1 -0
  220. package/lib/links.js +94 -114
  221. package/lib/localDev.d.ts +1 -0
  222. package/lib/localDev.js +285 -433
  223. package/lib/marketplace-validate.d.ts +1 -0
  224. package/lib/marketplace-validate.js +105 -126
  225. package/lib/oauth.d.ts +1 -0
  226. package/lib/oauth.js +64 -78
  227. package/lib/polling.d.ts +1 -0
  228. package/lib/polling.js +26 -26
  229. package/lib/process.d.ts +1 -0
  230. package/lib/process.js +41 -53
  231. package/lib/projectLogsManager.d.ts +1 -0
  232. package/lib/projectLogsManager.js +78 -130
  233. package/lib/projectStructure.d.ts +1 -0
  234. package/lib/projectStructure.js +89 -109
  235. package/lib/projects.d.ts +1 -0
  236. package/lib/projects.js +595 -958
  237. package/lib/projectsWatch.d.ts +1 -0
  238. package/lib/projectsWatch.js +127 -228
  239. package/lib/prompts/accountNamePrompt.d.ts +1 -0
  240. package/lib/prompts/accountNamePrompt.js +60 -65
  241. package/lib/prompts/accountsPrompt.d.ts +1 -0
  242. package/lib/prompts/accountsPrompt.js +33 -37
  243. package/lib/prompts/activeInstallConfirmationPrompt.d.ts +1 -0
  244. package/lib/prompts/activeInstallConfirmationPrompt.js +13 -13
  245. package/lib/prompts/cleanUploadPrompt.d.ts +1 -0
  246. package/lib/prompts/cleanUploadPrompt.js +13 -13
  247. package/lib/prompts/cmsFieldPrompt.d.ts +1 -0
  248. package/lib/prompts/cmsFieldPrompt.js +37 -39
  249. package/lib/prompts/createApiSamplePrompt.d.ts +1 -0
  250. package/lib/prompts/createApiSamplePrompt.js +49 -52
  251. package/lib/prompts/createFunctionPrompt.d.ts +1 -0
  252. package/lib/prompts/createFunctionPrompt.js +57 -56
  253. package/lib/prompts/createModulePrompt.d.ts +1 -0
  254. package/lib/prompts/createModulePrompt.js +47 -50
  255. package/lib/prompts/createProjectPrompt.d.ts +1 -0
  256. package/lib/prompts/createProjectPrompt.js +95 -129
  257. package/lib/prompts/createTemplatePrompt.d.ts +1 -0
  258. package/lib/prompts/createTemplatePrompt.js +18 -19
  259. package/lib/prompts/deployBuildIdPrompt.d.ts +1 -0
  260. package/lib/prompts/deployBuildIdPrompt.js +15 -15
  261. package/lib/prompts/downloadProjectPrompt.d.ts +1 -0
  262. package/lib/prompts/downloadProjectPrompt.js +39 -41
  263. package/lib/prompts/feedbackPrompt.d.ts +1 -0
  264. package/lib/prompts/feedbackPrompt.js +29 -30
  265. package/lib/prompts/folderOverwritePrompt.d.ts +1 -0
  266. package/lib/prompts/folderOverwritePrompt.js +10 -10
  267. package/lib/prompts/installPublicAppPrompt.d.ts +1 -0
  268. package/lib/prompts/installPublicAppPrompt.js +29 -42
  269. package/lib/prompts/personalAccessKeyPrompt.d.ts +1 -0
  270. package/lib/prompts/personalAccessKeyPrompt.js +104 -110
  271. package/lib/prompts/previewPrompt.d.ts +1 -0
  272. package/lib/prompts/previewPrompt.js +46 -47
  273. package/lib/prompts/projectAddPrompt.d.ts +1 -0
  274. package/lib/prompts/projectAddPrompt.js +37 -38
  275. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +1 -0
  276. package/lib/prompts/projectDevTargetAccountPrompt.js +150 -193
  277. package/lib/prompts/projectNamePrompt.d.ts +1 -0
  278. package/lib/prompts/projectNamePrompt.js +25 -25
  279. package/lib/prompts/projectsLogsPrompt.d.ts +1 -0
  280. package/lib/prompts/projectsLogsPrompt.js +21 -27
  281. package/lib/prompts/promptUtils.d.ts +1 -0
  282. package/lib/prompts/promptUtils.js +17 -17
  283. package/lib/prompts/sandboxesPrompt.d.ts +1 -0
  284. package/lib/prompts/sandboxesPrompt.js +50 -59
  285. package/lib/prompts/secretPrompt.d.ts +1 -0
  286. package/lib/prompts/secretPrompt.js +15 -16
  287. package/lib/prompts/selectPublicAppPrompt.d.ts +1 -0
  288. package/lib/prompts/selectPublicAppPrompt.js +58 -82
  289. package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -0
  290. package/lib/prompts/setAsDefaultAccountPrompt.js +19 -24
  291. package/lib/prompts/uploadPrompt.d.ts +1 -0
  292. package/lib/prompts/uploadPrompt.js +30 -30
  293. package/lib/regex.d.ts +1 -0
  294. package/lib/regex.js +4 -5
  295. package/lib/sandboxSync.d.ts +1 -0
  296. package/lib/sandboxSync.js +100 -166
  297. package/lib/sandboxes.d.ts +1 -0
  298. package/lib/sandboxes.js +201 -316
  299. package/lib/schema.d.ts +3 -0
  300. package/lib/schema.js +29 -33
  301. package/lib/serverlessLogs.d.ts +1 -0
  302. package/lib/serverlessLogs.js +131 -173
  303. package/lib/ui/SpinniesManager.d.ts +1 -0
  304. package/lib/ui/SpinniesManager.js +198 -254
  305. package/lib/ui/git.d.ts +1 -0
  306. package/lib/ui/git.js +20 -19
  307. package/lib/ui/index.d.ts +1 -0
  308. package/lib/ui/index.js +117 -167
  309. package/lib/ui/serverlessFunctionLogs.d.ts +1 -0
  310. package/lib/ui/serverlessFunctionLogs.js +53 -70
  311. package/lib/ui/spinniesUtils.d.ts +1 -0
  312. package/lib/ui/spinniesUtils.js +111 -133
  313. package/lib/ui/supportHyperlinks.d.ts +1 -0
  314. package/lib/ui/supportHyperlinks.js +49 -62
  315. package/lib/ui/supportsColor.d.ts +1 -0
  316. package/lib/ui/supportsColor.js +81 -109
  317. package/lib/ui/table.d.ts +1 -0
  318. package/lib/ui/table.js +49 -55
  319. package/lib/upload.d.ts +1 -0
  320. package/lib/upload.js +40 -43
  321. package/lib/usageTracking.d.ts +1 -0
  322. package/lib/usageTracking.js +133 -155
  323. package/lib/validation.d.ts +1 -0
  324. package/lib/validation.js +144 -203
  325. package/package.json +84 -48
  326. package/CHANGELOG.md +0 -16
  327. package/commands/__tests__/projects.test.js +0 -105
  328. package/commands/config/set/allowUsageTracking.js +0 -52
  329. package/commands/config/set/defaultMode.js +0 -59
  330. package/commands/config/set/httpTimeout.js +0 -42
  331. package/commands/project/__tests__/deploy.test.js +0 -443
  332. package/commands/project/__tests__/installDeps.test.js +0 -168
  333. package/commands/project/__tests__/logs.test.js +0 -304
  334. package/hubspot.sample.config.yml +0 -28
  335. package/jest.config.js +0 -4
  336. package/lib/__tests__/commonOpts.test.js +0 -83
  337. package/lib/__tests__/dependencyManagement.test.js +0 -243
  338. package/lib/__tests__/downloadProjectPrompt.test.js +0 -31
  339. package/lib/__tests__/projectLogsManager.test.js +0 -212
  340. package/lib/__tests__/projects.test.js +0 -140
  341. package/lib/__tests__/serverlessLogs.test.js +0 -162
  342. package/lib/__tests__/validation.test.js +0 -140
  343. package/lib/getFunctionArrays.js +0 -18
  344. package/lib/prompts/__tests__/projectsLogsPrompt.test.js +0 -46
package/lib/ui/index.js CHANGED
@@ -1,42 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // @ts-nocheck
1
4
  const chalk = require('chalk');
2
5
  const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
3
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
4
7
  const supportsHyperlinks = require('./supportHyperlinks');
5
8
  const supportsColor = require('./supportsColor');
6
9
  const { i18n } = require('../lang');
7
-
8
- const {
9
- HUBSPOT_ACCOUNT_TYPE_STRINGS,
10
- } = require('@hubspot/local-dev-lib/constants/config');
11
-
10
+ const { HUBSPOT_ACCOUNT_TYPE_STRINGS, } = require('@hubspot/local-dev-lib/constants/config');
12
11
  const UI_COLORS = {
13
- SORBET: '#FF8F59',
14
- MARIGOLD: '#f5c26b',
15
- MARIGOLD_DARK: '#dbae60',
12
+ SORBET: '#FF8F59',
13
+ MARIGOLD: '#f5c26b',
14
+ MARIGOLD_DARK: '#dbae60',
16
15
  };
17
-
18
16
  /**
19
17
  * Outputs horizontal line
20
18
  *
21
19
  * @returns
22
20
  */
23
21
  const uiLine = () => {
24
- logger.log('-'.repeat(50));
22
+ logger.log('-'.repeat(50));
25
23
  };
26
-
27
24
  /**
28
25
  * Returns an object that aggregates what the terminal supports (eg. hyperlinks and color)
29
26
  *
30
27
  * @returns {object}
31
28
  */
32
-
33
29
  const getTerminalUISupport = () => {
34
- return {
35
- hyperlinks: supportsHyperlinks.stdout,
36
- color: supportsColor.stdout.hasBasic,
37
- };
30
+ return {
31
+ hyperlinks: supportsHyperlinks.stdout,
32
+ color: supportsColor.stdout.hasBasic,
33
+ };
38
34
  };
39
-
40
35
  /**
41
36
  * Returns a hyperlink or link and description
42
37
  *
@@ -46,28 +41,23 @@ const getTerminalUISupport = () => {
46
41
  * @returns {string}
47
42
  */
48
43
  const uiLink = (linkText, url) => {
49
- const terminalUISupport = getTerminalUISupport();
50
- const encodedUrl = encodeURI(url);
51
-
52
- if (terminalUISupport.hyperlinks) {
53
- const CLOSE_SEQUENCE = '\u001B]8;;\u0007';
54
-
55
- const result = [
56
- '\u001B]8;;',
57
- encodedUrl,
58
- '\u0007',
59
- linkText,
60
- CLOSE_SEQUENCE,
61
- ].join('');
62
-
63
- return terminalUISupport.color ? chalk.cyan(result) : result;
64
- }
65
-
66
- return terminalUISupport.color
67
- ? `${linkText}: ${chalk.reset.cyan(encodedUrl)}`
68
- : `${linkText}: ${encodedUrl}`;
44
+ const terminalUISupport = getTerminalUISupport();
45
+ const encodedUrl = encodeURI(url);
46
+ if (terminalUISupport.hyperlinks) {
47
+ const CLOSE_SEQUENCE = '\u001B]8;;\u0007';
48
+ const result = [
49
+ '\u001B]8;;',
50
+ encodedUrl,
51
+ '\u0007',
52
+ linkText,
53
+ CLOSE_SEQUENCE,
54
+ ].join('');
55
+ return terminalUISupport.color ? chalk.cyan(result) : result;
56
+ }
57
+ return terminalUISupport.color
58
+ ? `${linkText}: ${chalk.reset.cyan(encodedUrl)}`
59
+ : `${linkText}: ${encodedUrl}`;
69
60
  };
70
-
71
61
  /**
72
62
  * Returns formatted account name, account type (if applicable), and ID
73
63
  *
@@ -76,150 +66,110 @@ const uiLink = (linkText, url) => {
76
66
  * @returns {string}
77
67
  */
78
68
  const uiAccountDescription = (accountId, bold = true) => {
79
- const account = getAccountConfig(accountId);
80
- const message = `${account.name} [${
81
- HUBSPOT_ACCOUNT_TYPE_STRINGS[account.accountType]
82
- }] (${account.portalId})`;
83
- return bold ? chalk.bold(message) : message;
69
+ const account = getAccountConfig(accountId);
70
+ const message = `${account.name} [${HUBSPOT_ACCOUNT_TYPE_STRINGS[account.accountType]}] (${account.portalId})`;
71
+ return bold ? chalk.bold(message) : message;
84
72
  };
85
-
86
73
  const uiInfoSection = (title, logContent) => {
87
- uiLine();
88
- logger.log(chalk.bold(title));
89
- logger.log('');
90
- logContent();
91
- logger.log('');
92
- uiLine();
74
+ uiLine();
75
+ logger.log(chalk.bold(title));
76
+ logger.log('');
77
+ logContent();
78
+ logger.log('');
79
+ uiLine();
93
80
  };
94
-
95
81
  const uiCommandReference = command => {
96
- const terminalUISupport = getTerminalUISupport();
97
-
98
- const commandReference = `\`${command}\``;
99
-
100
- return chalk.bold(
101
- terminalUISupport.color
102
- ? chalk.hex(UI_COLORS.MARIGOLD_DARK)(commandReference)
103
- : commandReference
104
- );
82
+ const terminalUISupport = getTerminalUISupport();
83
+ const commandReference = `\`${command}\``;
84
+ return chalk.bold(terminalUISupport.color
85
+ ? chalk.hex(UI_COLORS.MARIGOLD_DARK)(commandReference)
86
+ : commandReference);
105
87
  };
106
-
107
88
  const uiFeatureHighlight = (commands, title) => {
108
- const i18nKey = 'lib.ui.featureHighlight';
109
-
110
- uiInfoSection(title ? title : i18n(`${i18nKey}.defaultTitle`), () => {
111
- commands.forEach((c, i) => {
112
- const commandKey = `${i18nKey}.commandKeys.${c}`;
113
- const message = i18n(`${commandKey}.message`, {
114
- command: uiCommandReference(i18n(`${commandKey}.command`)),
115
- link: uiLink(i18n(`${commandKey}.linkText`), i18n(`${commandKey}.url`)),
116
- });
117
- if (i !== 0) {
118
- logger.log('');
119
- }
120
- logger.log(message);
89
+ const i18nKey = 'lib.ui.featureHighlight';
90
+ uiInfoSection(title ? title : i18n(`${i18nKey}.defaultTitle`), () => {
91
+ commands.forEach((c, i) => {
92
+ const commandKey = `${i18nKey}.commandKeys.${c}`;
93
+ const message = i18n(`${commandKey}.message`, {
94
+ command: uiCommandReference(i18n(`${commandKey}.command`)),
95
+ link: uiLink(i18n(`${commandKey}.linkText`), i18n(`${commandKey}.url`)),
96
+ });
97
+ if (i !== 0) {
98
+ logger.log('');
99
+ }
100
+ logger.log(message);
101
+ });
121
102
  });
122
- });
123
103
  };
124
-
125
104
  const uiBetaTag = (message, log = true) => {
126
- const i18nKey = 'lib.ui';
127
-
128
- const terminalUISupport = getTerminalUISupport();
129
- const tag = i18n(`${i18nKey}.betaTag`);
130
-
131
- const result = `${
132
- terminalUISupport.color ? chalk.hex(UI_COLORS.SORBET)(tag) : tag
133
- } ${message}`;
134
-
135
- if (log) {
136
- logger.log(result);
137
- } else {
138
- return result;
139
- }
105
+ const i18nKey = 'lib.ui';
106
+ const terminalUISupport = getTerminalUISupport();
107
+ const tag = i18n(`${i18nKey}.betaTag`);
108
+ const result = `${terminalUISupport.color ? chalk.hex(UI_COLORS.SORBET)(tag) : tag} ${message}`;
109
+ if (log) {
110
+ logger.log(result);
111
+ }
112
+ else {
113
+ return result;
114
+ }
140
115
  };
141
-
142
116
  const uiDeprecatedTag = (message, log = true) => {
143
- const i18nKey = 'lib.ui';
144
-
145
- const terminalUISupport = getTerminalUISupport();
146
- const tag = i18n(`${i18nKey}.deprecatedTag`);
147
-
148
- const result = `${
149
- terminalUISupport.color ? chalk.yellow(tag) : tag
150
- } ${message}`;
151
-
152
- if (log) {
153
- logger.log(result);
154
- } else {
155
- return result;
156
- }
117
+ const i18nKey = 'lib.ui';
118
+ const terminalUISupport = getTerminalUISupport();
119
+ const tag = i18n(`${i18nKey}.deprecatedTag`);
120
+ const result = `${terminalUISupport.color ? chalk.yellow(tag) : tag} ${message}`;
121
+ if (log) {
122
+ logger.log(result);
123
+ }
124
+ else {
125
+ return result;
126
+ }
157
127
  };
158
-
159
- const uiCommandDisabledBanner = (
160
- command,
161
- url = undefined,
162
- message = undefined
163
- ) => {
164
- const i18nKey = 'lib.ui';
165
-
166
- const tag =
167
- message ||
168
- i18n(`${i18nKey}.disabledMessage`, {
169
- command: uiCommandReference(command),
170
- url: url ? uiLink(i18n(`${i18nKey}.disabledUrlText`), url) : undefined,
171
- npmCommand: uiCommandReference('npm i -g @hubspot/cli@latest'),
172
- });
173
-
174
- logger.log();
175
- uiLine();
176
- logger.error(tag);
177
- uiLine();
178
- logger.log();
128
+ const uiCommandDisabledBanner = (command, url = undefined, message = undefined) => {
129
+ const i18nKey = 'lib.ui';
130
+ const tag = message ||
131
+ i18n(`${i18nKey}.disabledMessage`, {
132
+ command: uiCommandReference(command),
133
+ url: url ? uiLink(i18n(`${i18nKey}.disabledUrlText`), url) : undefined,
134
+ npmCommand: uiCommandReference('npm i -g @hubspot/cli@latest'),
135
+ });
136
+ logger.log();
137
+ uiLine();
138
+ logger.error(tag);
139
+ uiLine();
140
+ logger.log();
179
141
  };
180
-
181
- const uiDeprecatedDescription = (
182
- message,
183
- command,
184
- url = undefined,
185
- log = false
186
- ) => {
187
- const i18nKey = 'lib.ui';
188
-
189
- const tag = i18n(`${i18nKey}.deprecatedDescription`, {
190
- message,
191
- command: uiCommandReference(command),
192
- url,
193
- });
194
- return uiDeprecatedTag(tag, log);
142
+ const uiDeprecatedDescription = (message, command, url = undefined, log = false) => {
143
+ const i18nKey = 'lib.ui';
144
+ const tag = i18n(`${i18nKey}.deprecatedDescription`, {
145
+ message,
146
+ command: uiCommandReference(command),
147
+ url,
148
+ });
149
+ return uiDeprecatedTag(tag, log);
195
150
  };
196
-
197
151
  const uiDeprecatedMessage = (command, url = undefined, message = undefined) => {
198
- const i18nKey = 'lib.ui';
199
-
200
- const tag =
201
- message ||
202
- i18n(`${i18nKey}.deprecatedMessage`, {
203
- command: uiCommandReference(command),
204
- url: url ? uiLink(i18n(`${i18nKey}.deprecatedUrlText`), url) : undefined,
205
- });
206
-
207
- logger.log();
208
- uiDeprecatedTag(tag, true);
209
- logger.log();
152
+ const i18nKey = 'lib.ui';
153
+ const tag = message ||
154
+ i18n(`${i18nKey}.deprecatedMessage`, {
155
+ command: uiCommandReference(command),
156
+ url: url ? uiLink(i18n(`${i18nKey}.deprecatedUrlText`), url) : undefined,
157
+ });
158
+ logger.log();
159
+ uiDeprecatedTag(tag, true);
160
+ logger.log();
210
161
  };
211
-
212
162
  module.exports = {
213
- UI_COLORS,
214
- uiAccountDescription,
215
- uiCommandReference,
216
- uiBetaTag,
217
- uiDeprecatedTag,
218
- uiFeatureHighlight,
219
- uiInfoSection,
220
- uiLine,
221
- uiLink,
222
- uiDeprecatedMessage,
223
- uiDeprecatedDescription,
224
- uiCommandDisabledBanner,
163
+ UI_COLORS,
164
+ uiAccountDescription,
165
+ uiCommandReference,
166
+ uiBetaTag,
167
+ uiDeprecatedTag,
168
+ uiFeatureHighlight,
169
+ uiInfoSection,
170
+ uiLine,
171
+ uiLink,
172
+ uiDeprecatedMessage,
173
+ uiDeprecatedDescription,
174
+ uiCommandDisabledBanner,
225
175
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,103 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // @ts-nocheck
1
4
  const moment = require('moment');
2
5
  const chalk = require('chalk');
3
6
  const { logger, Styles } = require('@hubspot/local-dev-lib/logger');
4
7
  const { i18n } = require('../lang');
5
-
6
8
  const i18nKey = 'lib.ui.serverlessFunctionLogs';
7
-
8
9
  const SEPARATOR = ' - ';
9
10
  const LOG_STATUS_COLORS = {
10
- SUCCESS: Styles.success,
11
- ERROR: Styles.error,
12
- UNHANDLED_ERROR: Styles.error,
13
- HANDLED_ERROR: Styles.error,
11
+ SUCCESS: Styles.success,
12
+ ERROR: Styles.error,
13
+ UNHANDLED_ERROR: Styles.error,
14
+ HANDLED_ERROR: Styles.error,
14
15
  };
15
-
16
16
  function errorHandler(log, options) {
17
- return `${formatLogHeader(log, options)}${formatError(log, options)}`;
17
+ return `${formatLogHeader(log, options)}${formatError(log, options)}`;
18
18
  }
19
-
20
19
  const logHandler = {
21
- ERROR: errorHandler,
22
- UNHANDLED_ERROR: errorHandler,
23
- HANDLED_ERROR: errorHandler,
24
- SUCCESS: (log, options) => {
25
- return `${formatLogHeader(log, options)}${formatSuccess(log, options)}`;
26
- },
20
+ ERROR: errorHandler,
21
+ UNHANDLED_ERROR: errorHandler,
22
+ HANDLED_ERROR: errorHandler,
23
+ SUCCESS: (log, options) => {
24
+ return `${formatLogHeader(log, options)}${formatSuccess(log, options)}`;
25
+ },
27
26
  };
28
-
29
27
  function formatSuccess(log, options) {
30
- if (!log.log || options.compact) {
31
- return '';
32
- }
33
-
34
- return `\n${log.log}`;
28
+ if (!log.log || options.compact) {
29
+ return '';
30
+ }
31
+ return `\n${log.log}`;
35
32
  }
36
-
37
33
  function formatError(log, options) {
38
- if (!log.error || options.compact) {
39
- return '';
40
- }
41
-
42
- return `${log.error.type}: ${log.error.message}\n${formatStackTrace(log)}`;
34
+ if (!log.error || options.compact) {
35
+ return '';
36
+ }
37
+ return `${log.error.type}: ${log.error.message}\n${formatStackTrace(log)}`;
43
38
  }
44
-
45
39
  function formatLogHeader(log, options) {
46
- const color = LOG_STATUS_COLORS[log.status];
47
- const headerInsertion =
48
- options && options.insertions && options.insertions.header;
49
-
50
- return `${formatTimestamp(log)}${SEPARATOR}${color(log.status)}${
51
- headerInsertion ? `${SEPARATOR}${headerInsertion}` : ''
52
- }${SEPARATOR}${formatExecutionTime(log)}`;
40
+ const color = LOG_STATUS_COLORS[log.status];
41
+ const headerInsertion = options && options.insertions && options.insertions.header;
42
+ return `${formatTimestamp(log)}${SEPARATOR}${color(log.status)}${headerInsertion ? `${SEPARATOR}${headerInsertion}` : ''}${SEPARATOR}${formatExecutionTime(log)}`;
53
43
  }
54
-
55
44
  function formatStackTrace(log) {
56
- const stackTrace = (log.error.stackTrace && log.error.stackTrace[0]) || [];
57
- return stackTrace
58
- .map(trace => {
59
- return ` at ${trace}\n`;
45
+ const stackTrace = (log.error.stackTrace && log.error.stackTrace[0]) || [];
46
+ return stackTrace
47
+ .map(trace => {
48
+ return ` at ${trace}\n`;
60
49
  })
61
- .join('');
50
+ .join('');
62
51
  }
63
-
64
52
  function formatTimestamp(log) {
65
- return `${chalk.whiteBright(moment(log.createdAt).toISOString())}`;
53
+ return `${chalk.whiteBright(moment(log.createdAt).toISOString())}`;
66
54
  }
67
-
68
55
  function formatExecutionTime(log) {
69
- return `${chalk.whiteBright('Execution Time:')} ${log.executionTime}ms`;
56
+ return `${chalk.whiteBright('Execution Time:')} ${log.executionTime}ms`;
70
57
  }
71
-
72
58
  function processLog(log, options) {
73
- try {
74
- return logHandler[log.status](log, options);
75
- } catch (e) {
76
- logger.error(
77
- i18n(`${i18nKey}.unableToProcessLog`, {
78
- log: JSON.stringify(log),
79
- })
80
- );
81
- }
59
+ try {
60
+ return logHandler[log.status](log, options);
61
+ }
62
+ catch (e) {
63
+ logger.error(i18n(`${i18nKey}.unableToProcessLog`, {
64
+ log: JSON.stringify(log),
65
+ }));
66
+ }
82
67
  }
83
-
84
68
  function processLogs(logsResp, options) {
85
- if (!logsResp || (logsResp.results && !logsResp.results.length)) {
86
- return 'No logs found.';
87
- } else if (logsResp.results && logsResp.results.length) {
88
- return logsResp.results
89
- .map(log => {
90
- return processLog(log, options);
91
- })
92
- .join('\n');
93
- }
94
- return processLog(logsResp, options);
69
+ if (!logsResp || (logsResp.results && !logsResp.results.length)) {
70
+ return 'No logs found.';
71
+ }
72
+ else if (logsResp.results && logsResp.results.length) {
73
+ return logsResp.results
74
+ .map(log => {
75
+ return processLog(log, options);
76
+ })
77
+ .join('\n');
78
+ }
79
+ return processLog(logsResp, options);
95
80
  }
96
-
97
81
  function outputLogs(logsResp, options) {
98
- logger.log(processLogs(logsResp, options));
82
+ logger.log(processLogs(logsResp, options));
99
83
  }
100
-
101
84
  module.exports = {
102
- outputLogs,
85
+ outputLogs,
103
86
  };
@@ -0,0 +1 @@
1
+ export {};