@hubspot/cli 6.2.0 → 6.2.2-experimental.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 (347) hide show
  1. package/bin/cli.d.ts +2 -0
  2. package/bin/cli.js +107 -128
  3. package/commands/accounts/clean.d.ts +4 -0
  4. package/commands/accounts/clean.js +80 -116
  5. package/commands/accounts/info.d.ts +4 -0
  6. package/commands/accounts/info.js +30 -43
  7. package/commands/accounts/list.d.ts +4 -0
  8. package/commands/accounts/list.js +63 -92
  9. package/commands/accounts/remove.d.ts +4 -0
  10. package/commands/accounts/remove.js +41 -73
  11. package/commands/accounts/rename.d.ts +4 -0
  12. package/commands/accounts/rename.js +24 -41
  13. package/commands/accounts/use.d.ts +4 -0
  14. package/commands/accounts/use.js +34 -57
  15. package/commands/accounts.d.ts +3 -0
  16. package/commands/accounts.js +14 -18
  17. package/commands/auth.d.ts +4 -0
  18. package/commands/auth.js +131 -200
  19. package/commands/cms/convertFields.d.ts +4 -0
  20. package/commands/cms/convertFields.js +64 -81
  21. package/commands/cms/lighthouseScore.d.ts +4 -0
  22. package/commands/cms/lighthouseScore.js +234 -298
  23. package/commands/cms/reactModules.d.ts +4 -0
  24. package/commands/cms/reactModules.js +44 -53
  25. package/commands/cms.d.ts +3 -0
  26. package/commands/cms.js +9 -13
  27. package/commands/config/set/allowUsageTracking.d.ts +4 -0
  28. package/commands/config/set/allowUsageTracking.js +31 -38
  29. package/commands/config/set/defaultMode.d.ts +4 -0
  30. package/commands/config/set/defaultMode.js +32 -43
  31. package/commands/config/set/httpTimeout.d.ts +4 -0
  32. package/commands/config/set/httpTimeout.js +21 -30
  33. package/commands/config/set.d.ts +4 -0
  34. package/commands/config/set.js +61 -76
  35. package/commands/config.d.ts +3 -0
  36. package/commands/config.js +5 -9
  37. package/commands/create/api-sample.d.ts +13 -0
  38. package/commands/create/api-sample.js +52 -74
  39. package/commands/create/app.d.ts +10 -0
  40. package/commands/create/app.js +6 -7
  41. package/commands/create/function.d.ts +6 -0
  42. package/commands/create/function.js +13 -14
  43. package/commands/create/index.d.ts +109 -0
  44. package/commands/create/index.js +10 -9
  45. package/commands/create/module.d.ts +11 -0
  46. package/commands/create/module.js +19 -19
  47. package/commands/create/react-app.d.ts +9 -0
  48. package/commands/create/react-app.js +5 -6
  49. package/commands/create/template.d.ts +12 -0
  50. package/commands/create/template.js +21 -24
  51. package/commands/create/vue-app.d.ts +9 -0
  52. package/commands/create/vue-app.js +5 -6
  53. package/commands/create/webpack-serverless.d.ts +9 -0
  54. package/commands/create/webpack-serverless.js +5 -6
  55. package/commands/create/website-theme.d.ts +9 -0
  56. package/commands/create/website-theme.js +13 -15
  57. package/commands/create.d.ts +4 -0
  58. package/commands/create.js +62 -80
  59. package/commands/customObject/create.d.ts +4 -0
  60. package/commands/customObject/create.js +31 -47
  61. package/commands/customObject/schema/create.d.ts +4 -0
  62. package/commands/customObject/schema/create.js +40 -67
  63. package/commands/customObject/schema/delete.d.ts +4 -0
  64. package/commands/customObject/schema/delete.js +26 -39
  65. package/commands/customObject/schema/fetch-all.d.ts +4 -0
  66. package/commands/customObject/schema/fetch-all.js +28 -39
  67. package/commands/customObject/schema/fetch.d.ts +4 -0
  68. package/commands/customObject/schema/fetch.js +46 -63
  69. package/commands/customObject/schema/list.d.ts +3 -0
  70. package/commands/customObject/schema/list.js +12 -17
  71. package/commands/customObject/schema/update.d.ts +4 -0
  72. package/commands/customObject/schema/update.js +44 -72
  73. package/commands/customObject/schema.d.ts +3 -0
  74. package/commands/customObject/schema.js +10 -12
  75. package/commands/customObject.d.ts +3 -0
  76. package/commands/customObject.js +12 -22
  77. package/commands/feedback.d.ts +4 -0
  78. package/commands/feedback.js +23 -33
  79. package/commands/fetch.d.ts +4 -0
  80. package/commands/fetch.js +51 -78
  81. package/commands/filemanager/fetch.d.ts +4 -0
  82. package/commands/filemanager/fetch.js +36 -56
  83. package/commands/filemanager/upload.d.ts +4 -0
  84. package/commands/filemanager/upload.js +86 -128
  85. package/commands/filemanager.d.ts +3 -0
  86. package/commands/filemanager.js +10 -18
  87. package/commands/functions/deploy.d.ts +4 -0
  88. package/commands/functions/deploy.js +74 -99
  89. package/commands/functions/list.d.ts +4 -0
  90. package/commands/functions/list.js +29 -47
  91. package/commands/functions/server.d.ts +4 -0
  92. package/commands/functions/server.js +48 -65
  93. package/commands/functions.d.ts +3 -0
  94. package/commands/functions.js +11 -15
  95. package/commands/hubdb/clear.d.ts +4 -0
  96. package/commands/hubdb/clear.js +35 -56
  97. package/commands/hubdb/create.d.ts +4 -0
  98. package/commands/hubdb/create.js +32 -57
  99. package/commands/hubdb/delete.d.ts +4 -0
  100. package/commands/hubdb/delete.js +27 -44
  101. package/commands/hubdb/fetch.d.ts +4 -0
  102. package/commands/hubdb/fetch.js +28 -46
  103. package/commands/hubdb.d.ts +3 -0
  104. package/commands/hubdb.js +10 -14
  105. package/commands/init.d.ts +4 -0
  106. package/commands/init.js +101 -160
  107. package/commands/lint.d.ts +4 -0
  108. package/commands/lint.js +32 -45
  109. package/commands/list.d.ts +4 -0
  110. package/commands/list.js +72 -101
  111. package/commands/logs.d.ts +4 -0
  112. package/commands/logs.js +96 -121
  113. package/commands/module/marketplace-validate.d.ts +4 -0
  114. package/commands/module/marketplace-validate.js +30 -57
  115. package/commands/module.d.ts +3 -0
  116. package/commands/module.js +5 -9
  117. package/commands/mv.d.ts +4 -0
  118. package/commands/mv.js +51 -71
  119. package/commands/open.d.ts +4 -0
  120. package/commands/open.js +46 -62
  121. package/commands/project/add.d.ts +4 -0
  122. package/commands/project/add.js +45 -70
  123. package/commands/project/cloneApp.d.ts +4 -0
  124. package/commands/project/cloneApp.js +117 -180
  125. package/commands/project/create.d.ts +4 -0
  126. package/commands/project/create.js +47 -81
  127. package/commands/project/deploy.d.ts +4 -0
  128. package/commands/project/deploy.js +103 -182
  129. package/commands/project/dev.d.ts +4 -0
  130. package/commands/project/dev.js +123 -227
  131. package/commands/project/download.d.ts +4 -0
  132. package/commands/project/download.js +71 -123
  133. package/commands/project/installDeps.d.ts +6 -0
  134. package/commands/project/installDeps.js +50 -59
  135. package/commands/project/listBuilds.d.ts +4 -0
  136. package/commands/project/listBuilds.js +95 -139
  137. package/commands/project/logs.d.ts +4 -0
  138. package/commands/project/logs.js +84 -128
  139. package/commands/project/migrateApp.d.ts +4 -0
  140. package/commands/project/migrateApp.js +156 -248
  141. package/commands/project/open.d.ts +4 -0
  142. package/commands/project/open.js +42 -68
  143. package/commands/project/upload.d.ts +4 -0
  144. package/commands/project/upload.js +70 -116
  145. package/commands/project/watch.d.ts +4 -0
  146. package/commands/project/watch.js +92 -152
  147. package/commands/project.d.ts +3 -0
  148. package/commands/project.js +19 -23
  149. package/commands/remove.d.ts +4 -0
  150. package/commands/remove.js +26 -43
  151. package/commands/sandbox/create.d.ts +4 -0
  152. package/commands/sandbox/create.js +141 -187
  153. package/commands/sandbox/delete.d.ts +4 -0
  154. package/commands/sandbox/delete.js +164 -221
  155. package/commands/sandbox.d.ts +3 -0
  156. package/commands/sandbox.js +8 -12
  157. package/commands/secrets/addSecret.d.ts +4 -0
  158. package/commands/secrets/addSecret.js +32 -52
  159. package/commands/secrets/deleteSecret.d.ts +4 -0
  160. package/commands/secrets/deleteSecret.js +31 -50
  161. package/commands/secrets/listSecrets.d.ts +4 -0
  162. package/commands/secrets/listSecrets.js +26 -42
  163. package/commands/secrets/updateSecret.d.ts +4 -0
  164. package/commands/secrets/updateSecret.js +33 -53
  165. package/commands/secrets.d.ts +3 -0
  166. package/commands/secrets.js +10 -13
  167. package/commands/theme/generate-selectors.d.ts +4 -0
  168. package/commands/theme/generate-selectors.js +127 -192
  169. package/commands/theme/marketplace-validate.d.ts +4 -0
  170. package/commands/theme/marketplace-validate.js +30 -57
  171. package/commands/theme/preview.d.ts +4 -0
  172. package/commands/theme/preview.js +161 -196
  173. package/commands/theme.d.ts +3 -0
  174. package/commands/theme.js +7 -11
  175. package/commands/upload.d.ts +4 -0
  176. package/commands/upload.js +197 -287
  177. package/commands/watch.d.ts +4 -0
  178. package/commands/watch.js +126 -172
  179. package/lang/en.lyaml +2 -3
  180. package/lib/DevServerManager.d.ts +35 -0
  181. package/lib/DevServerManager.js +97 -124
  182. package/lib/LocalDevManager.d.ts +41 -0
  183. package/lib/LocalDevManager.js +320 -490
  184. package/lib/accountTypes.d.ts +6 -0
  185. package/lib/accountTypes.js +16 -32
  186. package/lib/buildAccount.d.ts +22 -0
  187. package/lib/buildAccount.js +130 -179
  188. package/lib/commonOpts.d.ts +20 -0
  189. package/lib/commonOpts.js +58 -91
  190. package/lib/constants.d.ts +83 -0
  191. package/lib/constants.js +61 -71
  192. package/lib/debugInfo.d.ts +3 -0
  193. package/lib/debugInfo.js +12 -13
  194. package/lib/dependencyManagement.d.ts +7 -0
  195. package/lib/dependencyManagement.js +90 -132
  196. package/lib/developerTestAccounts.d.ts +7 -0
  197. package/lib/developerTestAccounts.js +65 -91
  198. package/lib/enums/exitCodes.d.ts +5 -0
  199. package/lib/enums/exitCodes.js +5 -7
  200. package/lib/environment.d.ts +1 -0
  201. package/lib/environment.js +10 -10
  202. package/lib/errorHandlers/index.d.ts +19 -0
  203. package/lib/errorHandlers/index.js +64 -80
  204. package/lib/errorHandlers/suppressError.d.ts +1 -0
  205. package/lib/errorHandlers/suppressError.js +64 -106
  206. package/lib/filesystem.d.ts +2 -0
  207. package/lib/filesystem.js +16 -24
  208. package/lib/generate-selectors.d.ts +6 -0
  209. package/lib/generate-selectors.js +99 -137
  210. package/lib/getFunctionArrays.d.ts +1 -0
  211. package/lib/getFunctionArrays.js +12 -13
  212. package/lib/hasFeature.d.ts +1 -0
  213. package/lib/hasFeature.js +5 -11
  214. package/lib/hasFlag.d.ts +2 -0
  215. package/lib/hasFlag.js +6 -10
  216. package/lib/hublValidate.d.ts +4 -0
  217. package/lib/hublValidate.js +20 -24
  218. package/lib/interpolation.d.ts +10 -0
  219. package/lib/interpolation.js +48 -92
  220. package/lib/interpolationHelpers.d.ts +6 -0
  221. package/lib/interpolationHelpers.js +19 -19
  222. package/lib/lang.d.ts +3 -0
  223. package/lib/lang.js +50 -78
  224. package/lib/links.d.ts +127 -0
  225. package/lib/links.js +92 -114
  226. package/lib/localDev.d.ts +11 -0
  227. package/lib/localDev.js +283 -433
  228. package/lib/marketplace-validate.d.ts +5 -0
  229. package/lib/marketplace-validate.js +103 -126
  230. package/lib/oauth.d.ts +1 -0
  231. package/lib/oauth.js +62 -78
  232. package/lib/polling.d.ts +1 -0
  233. package/lib/polling.js +24 -26
  234. package/lib/process.d.ts +2 -0
  235. package/lib/process.js +39 -53
  236. package/lib/projectLogsManager.d.ts +19 -0
  237. package/lib/projectLogsManager.js +76 -130
  238. package/lib/projectStructure.d.ts +13 -0
  239. package/lib/projectStructure.js +87 -109
  240. package/lib/projects.d.ts +40 -0
  241. package/lib/projects.js +589 -957
  242. package/lib/projectsWatch.d.ts +1 -0
  243. package/lib/projectsWatch.js +122 -228
  244. package/lib/prompts/accountNamePrompt.d.ts +11 -0
  245. package/lib/prompts/accountNamePrompt.js +58 -65
  246. package/lib/prompts/accountsPrompt.d.ts +3 -0
  247. package/lib/prompts/accountsPrompt.js +31 -37
  248. package/lib/prompts/activeInstallConfirmationPrompt.d.ts +1 -0
  249. package/lib/prompts/activeInstallConfirmationPrompt.js +11 -13
  250. package/lib/prompts/cleanUploadPrompt.d.ts +1 -0
  251. package/lib/prompts/cleanUploadPrompt.js +11 -13
  252. package/lib/prompts/cmsFieldPrompt.d.ts +1 -0
  253. package/lib/prompts/cmsFieldPrompt.js +35 -39
  254. package/lib/prompts/createApiSamplePrompt.d.ts +1 -0
  255. package/lib/prompts/createApiSamplePrompt.js +47 -52
  256. package/lib/prompts/createFunctionPrompt.d.ts +1 -0
  257. package/lib/prompts/createFunctionPrompt.js +55 -56
  258. package/lib/prompts/createModulePrompt.d.ts +1 -0
  259. package/lib/prompts/createModulePrompt.js +45 -50
  260. package/lib/prompts/createProjectPrompt.d.ts +1 -0
  261. package/lib/prompts/createProjectPrompt.js +88 -127
  262. package/lib/prompts/createTemplatePrompt.d.ts +1 -0
  263. package/lib/prompts/createTemplatePrompt.js +16 -19
  264. package/lib/prompts/deployBuildIdPrompt.d.ts +1 -0
  265. package/lib/prompts/deployBuildIdPrompt.js +13 -15
  266. package/lib/prompts/downloadProjectPrompt.d.ts +1 -0
  267. package/lib/prompts/downloadProjectPrompt.js +36 -40
  268. package/lib/prompts/feedbackPrompt.d.ts +2 -0
  269. package/lib/prompts/feedbackPrompt.js +27 -30
  270. package/lib/prompts/folderOverwritePrompt.d.ts +1 -0
  271. package/lib/prompts/folderOverwritePrompt.js +8 -10
  272. package/lib/prompts/installPublicAppPrompt.d.ts +1 -0
  273. package/lib/prompts/installPublicAppPrompt.js +27 -42
  274. package/lib/prompts/personalAccessKeyPrompt.d.ts +69 -0
  275. package/lib/prompts/personalAccessKeyPrompt.js +102 -110
  276. package/lib/prompts/previewPrompt.d.ts +2 -0
  277. package/lib/prompts/previewPrompt.js +44 -47
  278. package/lib/prompts/projectAddPrompt.d.ts +1 -0
  279. package/lib/prompts/projectAddPrompt.js +35 -38
  280. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +4 -0
  281. package/lib/prompts/projectDevTargetAccountPrompt.js +148 -193
  282. package/lib/prompts/projectNamePrompt.d.ts +1 -0
  283. package/lib/prompts/projectNamePrompt.js +23 -25
  284. package/lib/prompts/projectsLogsPrompt.d.ts +5 -0
  285. package/lib/prompts/projectsLogsPrompt.js +19 -27
  286. package/lib/prompts/promptUtils.d.ts +2 -0
  287. package/lib/prompts/promptUtils.js +15 -17
  288. package/lib/prompts/sandboxesPrompt.d.ts +2 -0
  289. package/lib/prompts/sandboxesPrompt.js +48 -59
  290. package/lib/prompts/secretPrompt.d.ts +1 -0
  291. package/lib/prompts/secretPrompt.js +13 -16
  292. package/lib/prompts/selectPublicAppPrompt.d.ts +5 -0
  293. package/lib/prompts/selectPublicAppPrompt.js +55 -81
  294. package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -0
  295. package/lib/prompts/setAsDefaultAccountPrompt.js +17 -24
  296. package/lib/prompts/uploadPrompt.d.ts +1 -0
  297. package/lib/prompts/uploadPrompt.js +28 -30
  298. package/lib/regex.d.ts +1 -0
  299. package/lib/regex.js +2 -2
  300. package/lib/sandboxSync.d.ts +8 -0
  301. package/lib/sandboxSync.js +98 -166
  302. package/lib/sandboxes.d.ts +40 -0
  303. package/lib/sandboxes.js +199 -316
  304. package/lib/schema.d.ts +2 -0
  305. package/lib/schema.js +20 -26
  306. package/lib/serverlessLogs.d.ts +8 -0
  307. package/lib/serverlessLogs.js +128 -172
  308. package/lib/ui/SpinniesManager.d.ts +61 -0
  309. package/lib/ui/SpinniesManager.js +196 -254
  310. package/lib/ui/git.d.ts +1 -0
  311. package/lib/ui/git.js +18 -19
  312. package/lib/ui/index.d.ts +36 -0
  313. package/lib/ui/index.js +115 -167
  314. package/lib/ui/serverlessFunctionLogs.d.ts +1 -0
  315. package/lib/ui/serverlessFunctionLogs.js +51 -70
  316. package/lib/ui/spinniesUtils.d.ts +60 -0
  317. package/lib/ui/spinniesUtils.js +109 -133
  318. package/lib/ui/supportHyperlinks.d.ts +3 -0
  319. package/lib/ui/supportHyperlinks.js +46 -61
  320. package/lib/ui/supportsColor.d.ts +13 -0
  321. package/lib/ui/supportsColor.js +78 -108
  322. package/lib/ui/table.d.ts +2 -0
  323. package/lib/ui/table.js +47 -55
  324. package/lib/upload.d.ts +1 -0
  325. package/lib/upload.js +37 -42
  326. package/lib/usageTracking.d.ts +6 -0
  327. package/lib/usageTracking.js +131 -155
  328. package/lib/validation.d.ts +16 -0
  329. package/lib/validation.js +142 -203
  330. package/package.json +78 -48
  331. package/CHANGELOG.md +0 -16
  332. package/LICENSE +0 -12
  333. package/README.md +0 -154
  334. package/commands/__tests__/projects.test.js +0 -105
  335. package/commands/project/__tests__/deploy.test.js +0 -443
  336. package/commands/project/__tests__/installDeps.test.js +0 -168
  337. package/commands/project/__tests__/logs.test.js +0 -304
  338. package/hubspot.sample.config.yml +0 -28
  339. package/jest.config.js +0 -4
  340. package/lib/__tests__/commonOpts.test.js +0 -83
  341. package/lib/__tests__/dependencyManagement.test.js +0 -243
  342. package/lib/__tests__/downloadProjectPrompt.test.js +0 -31
  343. package/lib/__tests__/projectLogsManager.test.js +0 -212
  344. package/lib/__tests__/projects.test.js +0 -140
  345. package/lib/__tests__/serverlessLogs.test.js +0 -162
  346. package/lib/__tests__/validation.test.js +0 -140
  347. package/lib/prompts/__tests__/projectsLogsPrompt.test.js +0 -46
package/commands/watch.js CHANGED
@@ -1,18 +1,10 @@
1
+ "use strict";
1
2
  const fs = require('fs');
2
3
  const path = require('path');
3
-
4
4
  const { watch } = require('@hubspot/local-dev-lib/cms/watch');
5
5
  const { getCwd } = require('@hubspot/local-dev-lib/path');
6
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
7
-
8
- const {
9
- addConfigOptions,
10
- addAccountOptions,
11
- addModeOptions,
12
- addUseEnvironmentOptions,
13
- getAccountId,
14
- getMode,
15
- } = require('../lib/commonOpts');
7
+ const { addConfigOptions, addAccountOptions, addModeOptions, addUseEnvironmentOptions, getAccountId, getMode, } = require('../lib/commonOpts');
16
8
  const { uploadPrompt } = require('../lib/prompts/uploadPrompt');
17
9
  const { validateMode, loadAndValidateOptions } = require('../lib/validation');
18
10
  const { trackCommandUsage } = require('../lib/usageTracking');
@@ -20,172 +12,134 @@ const { i18n } = require('../lib/lang');
20
12
  const { getUploadableFileList } = require('../lib/upload');
21
13
  const { logError, ApiErrorContext } = require('../lib/errorHandlers/index');
22
14
  const i18nKey = 'commands.watch';
23
-
24
15
  const { EXIT_CODES } = require('../lib/enums/exitCodes');
25
-
26
16
  exports.command = 'watch [--src] [--dest]';
27
17
  exports.describe = i18n(`${i18nKey}.describe`);
28
-
29
- exports.handler = async options => {
30
- const { remove, initialUpload, disableInitial, notify } = options;
31
-
32
- await loadAndValidateOptions(options);
33
-
34
- if (!validateMode(options)) {
35
- process.exit(EXIT_CODES.ERROR);
36
- }
37
-
38
- const accountId = getAccountId(options);
39
- const mode = getMode(options);
40
-
41
- const uploadPromptAnswers = await uploadPrompt(options);
42
-
43
- const src = options.src || uploadPromptAnswers.src;
44
- const dest = options.dest || uploadPromptAnswers.dest;
45
-
46
- const absoluteSrcPath = path.resolve(getCwd(), src);
47
- try {
48
- const stats = fs.statSync(absoluteSrcPath);
49
- if (!stats.isDirectory()) {
50
- logger.log(
51
- i18n(`${i18nKey}.errors.invalidPath`, {
52
- path: src,
53
- })
54
- );
55
- return;
18
+ exports.handler = async (options) => {
19
+ const { remove, initialUpload, disableInitial, notify } = options;
20
+ await loadAndValidateOptions(options);
21
+ if (!validateMode(options)) {
22
+ process.exit(EXIT_CODES.ERROR);
56
23
  }
57
- } catch (e) {
58
- logger.log(
59
- i18n(`${i18nKey}.errors.invalidPath`, {
60
- path: src,
61
- })
62
- );
63
- return;
64
- }
65
-
66
- if (!dest) {
67
- logger.log(i18n(`${i18nKey}.errors.destinationRequired`));
68
- return;
69
- }
70
-
71
- let filesToUpload = [];
72
-
73
- if (disableInitial) {
74
- logger.info(i18n(`${i18nKey}.warnings.disableInitial`));
75
- } else if (!initialUpload) {
76
- logger.info(i18n(`${i18nKey}.warnings.notUploaded`, { path: src }));
77
- logger.info(i18n(`${i18nKey}.warnings.initialUpload`));
78
- }
79
-
80
- if (initialUpload) {
81
- filesToUpload = await getUploadableFileList(
82
- absoluteSrcPath,
83
- options.convertFields
84
- );
85
- }
86
-
87
- trackCommandUsage('watch', { mode }, accountId);
88
-
89
- const postInitialUploadCallback = null;
90
- const onUploadFolderError = error => {
91
- logger.error(
92
- i18n(`${i18nKey}.errors.folderFailed`, {
93
- src,
94
- dest,
95
- accountId,
96
- })
97
- );
98
- logError(error, {
99
- accountId,
100
- });
101
- };
102
- const onQueueAddError = null;
103
- const onUploadFileError = (file, dest, accountId) => error => {
104
- logger.error(
105
- i18n(`${i18nKey}.errors.fileFailed`, {
106
- file,
107
- dest,
108
- accountId,
109
- })
110
- );
111
- logError(
112
- error,
113
- new ApiErrorContext({
114
- accountId,
115
- request: dest,
116
- payload: file,
117
- })
118
- );
119
- };
120
- watch(
121
- accountId,
122
- absoluteSrcPath,
123
- dest,
124
- {
125
- mode,
126
- remove,
127
- disableInitial: initialUpload ? false : true,
128
- notify,
129
- commandOptions: options,
130
- filePaths: filesToUpload,
131
- },
132
- postInitialUploadCallback,
133
- onUploadFolderError,
134
- onQueueAddError,
135
- onUploadFileError
136
- );
24
+ const accountId = getAccountId(options);
25
+ const mode = getMode(options);
26
+ const uploadPromptAnswers = await uploadPrompt(options);
27
+ const src = options.src || uploadPromptAnswers.src;
28
+ const dest = options.dest || uploadPromptAnswers.dest;
29
+ const absoluteSrcPath = path.resolve(getCwd(), src);
30
+ try {
31
+ const stats = fs.statSync(absoluteSrcPath);
32
+ if (!stats.isDirectory()) {
33
+ logger.log(i18n(`${i18nKey}.errors.invalidPath`, {
34
+ path: src,
35
+ }));
36
+ return;
37
+ }
38
+ }
39
+ catch (e) {
40
+ logger.log(i18n(`${i18nKey}.errors.invalidPath`, {
41
+ path: src,
42
+ }));
43
+ return;
44
+ }
45
+ if (!dest) {
46
+ logger.log(i18n(`${i18nKey}.errors.destinationRequired`));
47
+ return;
48
+ }
49
+ let filesToUpload = [];
50
+ if (disableInitial) {
51
+ logger.info(i18n(`${i18nKey}.warnings.disableInitial`));
52
+ }
53
+ else if (!initialUpload) {
54
+ logger.info(i18n(`${i18nKey}.warnings.notUploaded`, { path: src }));
55
+ logger.info(i18n(`${i18nKey}.warnings.initialUpload`));
56
+ }
57
+ if (initialUpload) {
58
+ filesToUpload = await getUploadableFileList(absoluteSrcPath, options.convertFields);
59
+ }
60
+ trackCommandUsage('watch', { mode }, accountId);
61
+ const postInitialUploadCallback = null;
62
+ const onUploadFolderError = error => {
63
+ logger.error(i18n(`${i18nKey}.errors.folderFailed`, {
64
+ src,
65
+ dest,
66
+ accountId,
67
+ }));
68
+ logError(error, {
69
+ accountId,
70
+ });
71
+ };
72
+ const onQueueAddError = null;
73
+ const onUploadFileError = (file, dest, accountId) => error => {
74
+ logger.error(i18n(`${i18nKey}.errors.fileFailed`, {
75
+ file,
76
+ dest,
77
+ accountId,
78
+ }));
79
+ logError(error, new ApiErrorContext({
80
+ accountId,
81
+ request: dest,
82
+ payload: file,
83
+ }));
84
+ };
85
+ watch(accountId, absoluteSrcPath, dest, {
86
+ mode,
87
+ remove,
88
+ disableInitial: initialUpload ? false : true,
89
+ notify,
90
+ commandOptions: options,
91
+ filePaths: filesToUpload,
92
+ }, postInitialUploadCallback, onUploadFolderError, onQueueAddError, onUploadFileError);
137
93
  };
138
-
139
94
  exports.builder = yargs => {
140
- addConfigOptions(yargs);
141
- addAccountOptions(yargs);
142
- addModeOptions(yargs, { write: true });
143
- addUseEnvironmentOptions(yargs);
144
-
145
- yargs.positional('src', {
146
- describe: i18n(`${i18nKey}.positionals.src.describe`),
147
- type: 'string',
148
- });
149
- yargs.positional('dest', {
150
- describe: i18n(`${i18nKey}.positionals.dest.describe`),
151
- type: 'string',
152
- });
153
- yargs.option('fieldOptions', {
154
- describe: i18n(`${i18nKey}.options.options.describe`),
155
- type: 'array',
156
- default: [''],
157
- hidden: true,
158
- });
159
- yargs.option('remove', {
160
- alias: 'r',
161
- describe: i18n(`${i18nKey}.options.remove.describe`),
162
- type: 'boolean',
163
- });
164
- yargs.option('initial-upload', {
165
- alias: 'i',
166
- describe: i18n(`${i18nKey}.options.initialUpload.describe`),
167
- type: 'boolean',
168
- });
169
- yargs.option('disable-initial', {
170
- describe: i18n(`${i18nKey}.options.disableInitial.describe`),
171
- type: 'boolean',
172
- hidden: true,
173
- });
174
- yargs.option('notify', {
175
- alias: 'n',
176
- describe: i18n(`${i18nKey}.options.notify.describe`),
177
- type: 'string',
178
- requiresArg: true,
179
- });
180
- yargs.option('convertFields', {
181
- describe: i18n(`${i18nKey}.options.convertFields.describe`),
182
- type: 'boolean',
183
- default: false,
184
- });
185
- yargs.option('saveOutput', {
186
- describe: i18n(`${i18nKey}.options.saveOutput.describe`),
187
- type: 'boolean',
188
- default: false,
189
- });
190
- return yargs;
95
+ addConfigOptions(yargs);
96
+ addAccountOptions(yargs);
97
+ addModeOptions(yargs, { write: true });
98
+ addUseEnvironmentOptions(yargs);
99
+ yargs.positional('src', {
100
+ describe: i18n(`${i18nKey}.positionals.src.describe`),
101
+ type: 'string',
102
+ });
103
+ yargs.positional('dest', {
104
+ describe: i18n(`${i18nKey}.positionals.dest.describe`),
105
+ type: 'string',
106
+ });
107
+ yargs.option('fieldOptions', {
108
+ describe: i18n(`${i18nKey}.options.options.describe`),
109
+ type: 'array',
110
+ default: [''],
111
+ hidden: true,
112
+ });
113
+ yargs.option('remove', {
114
+ alias: 'r',
115
+ describe: i18n(`${i18nKey}.options.remove.describe`),
116
+ type: 'boolean',
117
+ });
118
+ yargs.option('initial-upload', {
119
+ alias: 'i',
120
+ describe: i18n(`${i18nKey}.options.initialUpload.describe`),
121
+ type: 'boolean',
122
+ });
123
+ yargs.option('disable-initial', {
124
+ describe: i18n(`${i18nKey}.options.disableInitial.describe`),
125
+ type: 'boolean',
126
+ hidden: true,
127
+ });
128
+ yargs.option('notify', {
129
+ alias: 'n',
130
+ describe: i18n(`${i18nKey}.options.notify.describe`),
131
+ type: 'string',
132
+ requiresArg: true,
133
+ });
134
+ yargs.option('convertFields', {
135
+ describe: i18n(`${i18nKey}.options.convertFields.describe`),
136
+ type: 'boolean',
137
+ default: false,
138
+ });
139
+ yargs.option('saveOutput', {
140
+ describe: i18n(`${i18nKey}.options.saveOutput.describe`),
141
+ type: 'boolean',
142
+ default: false,
143
+ });
144
+ return yargs;
191
145
  };
package/lang/en.lyaml CHANGED
@@ -183,8 +183,6 @@ en:
183
183
  noSamples: "Currently there are no samples available, please, try again later."
184
184
  info:
185
185
  sampleChosen: "You've chosen {{ sampleType }} sample written on {{ sampleLanguage }} language"
186
- loading:
187
- apiSamples: "Loading available API samples"
188
186
  success:
189
187
  sampleCreated: "Please, follow {{ filePath }}/README.md to find out how to run the sample"
190
188
  module:
@@ -335,7 +333,8 @@ en:
335
333
  notFunctionsFolder: "Specified path {{ functionPath }} is not a .functions folder."
336
334
  examples:
337
335
  default: "Build and deploy a new bundle for all functions within the myFunctionFolder.functions folder"
338
- loading: "Building and deploying bundle for \"{{ functionPath }}\" on account \"{{ accountId }}\".\n"
336
+ loading: "Building and deploying bundle for \"{{ functionPath }}\" on {{ account }}"
337
+ loadingFailed: "Failed to build and deploy bundle for \"{{ functionPath }}\" on {{ account }}"
339
338
  positionals:
340
339
  path:
341
340
  describe: "Path to .functions folder"
@@ -0,0 +1,35 @@
1
+ declare const _exports: DevServerManager;
2
+ export = _exports;
3
+ declare class DevServerManager {
4
+ initialized: boolean;
5
+ started: boolean;
6
+ componentsByType: {};
7
+ server: any;
8
+ path: any;
9
+ devServers: {
10
+ [x: string]: {
11
+ componentType: "private-app";
12
+ serverInterface: import("@hubspot/ui-extensions-dev-server").DevModeInterfaceNonSingleton;
13
+ } | {
14
+ componentType: "public-app";
15
+ serverInterface: import("@hubspot/ui-extensions-dev-server").DevModeInterfaceNonSingleton;
16
+ };
17
+ };
18
+ iterateDevServers(callback: any): Promise<void>;
19
+ arrangeComponentsByType(components: any): any;
20
+ setup({ components, onUploadRequired, accountId, setActiveApp }: {
21
+ components: any;
22
+ onUploadRequired: any;
23
+ accountId: any;
24
+ setActiveApp: any;
25
+ }): Promise<void>;
26
+ start({ accountId, projectConfig }: {
27
+ accountId: any;
28
+ projectConfig: any;
29
+ }): Promise<void>;
30
+ fileChange({ filePath, event }: {
31
+ filePath: any;
32
+ event: any;
33
+ }): void;
34
+ cleanup(): Promise<void>;
35
+ }
@@ -1,144 +1,117 @@
1
+ "use strict";
1
2
  const { logger } = require('@hubspot/local-dev-lib/logger');
2
3
  const { COMPONENT_TYPES } = require('./projectStructure');
3
4
  const { i18n } = require('./lang');
4
5
  const { promptUser } = require('./prompts/promptUtils');
5
6
  const { DevModeInterface } = require('@hubspot/ui-extensions-dev-server');
6
- const {
7
- startPortManagerServer,
8
- portManagerHasActiveServers,
9
- stopPortManagerServer,
10
- requestPorts,
11
- } = require('@hubspot/local-dev-lib/portManager');
12
- const {
13
- getHubSpotApiOrigin,
14
- getHubSpotWebsiteOrigin,
15
- } = require('@hubspot/local-dev-lib/urls');
7
+ const { startPortManagerServer, portManagerHasActiveServers, stopPortManagerServer, requestPorts, } = require('@hubspot/local-dev-lib/portManager');
8
+ const { getHubSpotApiOrigin, getHubSpotWebsiteOrigin, } = require('@hubspot/local-dev-lib/urls');
16
9
  const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
17
-
18
10
  const i18nKey = 'lib.DevServerManager';
19
-
20
11
  const SERVER_KEYS = {
21
- privateApp: 'privateApp',
22
- publicApp: 'publicApp',
12
+ privateApp: 'privateApp',
13
+ publicApp: 'publicApp',
23
14
  };
24
-
25
15
  class DevServerManager {
26
- constructor() {
27
- this.initialized = false;
28
- this.started = false;
29
- this.componentsByType = {};
30
- this.server = null;
31
- this.path = null;
32
- this.devServers = {
33
- [SERVER_KEYS.privateApp]: {
34
- componentType: COMPONENT_TYPES.privateApp,
35
- serverInterface: DevModeInterface,
36
- },
37
- [SERVER_KEYS.publicApp]: {
38
- componentType: COMPONENT_TYPES.publicApp,
39
- serverInterface: DevModeInterface,
40
- },
41
- };
42
- }
43
-
44
- async iterateDevServers(callback) {
45
- const serverKeys = Object.keys(this.devServers);
46
-
47
- for (let i = 0; i < serverKeys.length; i++) {
48
- const serverKey = serverKeys[i];
49
- const devServer = this.devServers[serverKey];
50
-
51
- const compatibleComponents =
52
- this.componentsByType[devServer.componentType] || {};
53
-
54
- if (Object.keys(compatibleComponents).length) {
55
- await callback(devServer.serverInterface, compatibleComponents);
56
- } else {
57
- logger.debug(i18n(`${i18nKey}.noCompatibleComponents`, { serverKey }));
58
- }
59
- }
60
- }
61
-
62
- arrangeComponentsByType(components) {
63
- return components.reduce((acc, component) => {
64
- if (!acc[component.type]) {
65
- acc[component.type] = {};
66
- }
67
-
68
- acc[component.type][component.config.name] = component;
69
-
70
- return acc;
71
- }, {});
72
- }
73
-
74
- async setup({ components, onUploadRequired, accountId, setActiveApp }) {
75
- this.componentsByType = this.arrangeComponentsByType(components);
76
- const { env } = getAccountConfig(accountId);
77
- await startPortManagerServer();
78
- await this.iterateDevServers(
79
- async (serverInterface, compatibleComponents) => {
80
- if (serverInterface.setup) {
81
- await serverInterface.setup({
82
- components: compatibleComponents,
83
- onUploadRequired,
84
- promptUser,
85
- logger,
86
- urls: {
87
- api: getHubSpotApiOrigin(env),
88
- web: getHubSpotWebsiteOrigin(env),
16
+ constructor() {
17
+ this.initialized = false;
18
+ this.started = false;
19
+ this.componentsByType = {};
20
+ this.server = null;
21
+ this.path = null;
22
+ this.devServers = {
23
+ [SERVER_KEYS.privateApp]: {
24
+ componentType: COMPONENT_TYPES.privateApp,
25
+ serverInterface: DevModeInterface,
26
+ },
27
+ [SERVER_KEYS.publicApp]: {
28
+ componentType: COMPONENT_TYPES.publicApp,
29
+ serverInterface: DevModeInterface,
89
30
  },
90
- setActiveApp,
91
- });
31
+ };
32
+ }
33
+ async iterateDevServers(callback) {
34
+ const serverKeys = Object.keys(this.devServers);
35
+ for (let i = 0; i < serverKeys.length; i++) {
36
+ const serverKey = serverKeys[i];
37
+ const devServer = this.devServers[serverKey];
38
+ const compatibleComponents = this.componentsByType[devServer.componentType] || {};
39
+ if (Object.keys(compatibleComponents).length) {
40
+ await callback(devServer.serverInterface, compatibleComponents);
41
+ }
42
+ else {
43
+ logger.debug(i18n(`${i18nKey}.noCompatibleComponents`, { serverKey }));
44
+ }
45
+ }
46
+ }
47
+ arrangeComponentsByType(components) {
48
+ return components.reduce((acc, component) => {
49
+ if (!acc[component.type]) {
50
+ acc[component.type] = {};
51
+ }
52
+ acc[component.type][component.config.name] = component;
53
+ return acc;
54
+ }, {});
55
+ }
56
+ async setup({ components, onUploadRequired, accountId, setActiveApp }) {
57
+ this.componentsByType = this.arrangeComponentsByType(components);
58
+ const { env } = getAccountConfig(accountId);
59
+ await startPortManagerServer();
60
+ await this.iterateDevServers(async (serverInterface, compatibleComponents) => {
61
+ if (serverInterface.setup) {
62
+ await serverInterface.setup({
63
+ components: compatibleComponents,
64
+ onUploadRequired,
65
+ promptUser,
66
+ logger,
67
+ urls: {
68
+ api: getHubSpotApiOrigin(env),
69
+ web: getHubSpotWebsiteOrigin(env),
70
+ },
71
+ setActiveApp,
72
+ });
73
+ }
74
+ });
75
+ this.initialized = true;
76
+ }
77
+ async start({ accountId, projectConfig }) {
78
+ if (this.initialized) {
79
+ await this.iterateDevServers(async (serverInterface) => {
80
+ if (serverInterface.start) {
81
+ await serverInterface.start({
82
+ accountId,
83
+ projectConfig,
84
+ requestPorts,
85
+ });
86
+ }
87
+ });
92
88
  }
93
- }
94
- );
95
-
96
- this.initialized = true;
97
- }
98
-
99
- async start({ accountId, projectConfig }) {
100
- if (this.initialized) {
101
- await this.iterateDevServers(async serverInterface => {
102
- if (serverInterface.start) {
103
- await serverInterface.start({
104
- accountId,
105
- projectConfig,
106
- requestPorts,
107
- });
89
+ else {
90
+ throw new Error(i18n(`${i18nKey}.notInitialized`));
108
91
  }
109
- });
110
- } else {
111
- throw new Error(i18n(`${i18nKey}.notInitialized`));
92
+ this.started = true;
112
93
  }
113
-
114
- this.started = true;
115
- }
116
-
117
- fileChange({ filePath, event }) {
118
- if (this.started) {
119
- this.iterateDevServers(async serverInterface => {
120
- if (serverInterface.fileChange) {
121
- await serverInterface.fileChange(filePath, event);
94
+ fileChange({ filePath, event }) {
95
+ if (this.started) {
96
+ this.iterateDevServers(async (serverInterface) => {
97
+ if (serverInterface.fileChange) {
98
+ await serverInterface.fileChange(filePath, event);
99
+ }
100
+ });
122
101
  }
123
- });
124
102
  }
125
- }
126
-
127
- async cleanup() {
128
- if (this.started) {
129
- await this.iterateDevServers(async serverInterface => {
130
- if (serverInterface.cleanup) {
131
- await serverInterface.cleanup();
103
+ async cleanup() {
104
+ if (this.started) {
105
+ await this.iterateDevServers(async (serverInterface) => {
106
+ if (serverInterface.cleanup) {
107
+ await serverInterface.cleanup();
108
+ }
109
+ });
110
+ const hasActiveServers = await portManagerHasActiveServers();
111
+ if (!hasActiveServers) {
112
+ await stopPortManagerServer();
113
+ }
132
114
  }
133
- });
134
-
135
- const hasActiveServers = await portManagerHasActiveServers();
136
-
137
- if (!hasActiveServers) {
138
- await stopPortManagerServer();
139
- }
140
115
  }
141
- }
142
116
  }
143
-
144
117
  module.exports = new DevServerManager();
@@ -0,0 +1,41 @@
1
+ export = LocalDevManager;
2
+ declare class LocalDevManager {
3
+ constructor(options: any);
4
+ targetAccountId: any;
5
+ targetProjectAccountId: any;
6
+ projectConfig: any;
7
+ projectDir: any;
8
+ projectId: any;
9
+ debug: any;
10
+ deployedBuild: any;
11
+ isGithubLinked: any;
12
+ watcher: chokidar.FSWatcher | null;
13
+ uploadWarnings: {};
14
+ runnableComponents: any;
15
+ activeApp: any;
16
+ activePublicAppData: any;
17
+ env: any;
18
+ publicAppActiveInstalls: number | null;
19
+ projectSourceDir: string;
20
+ setActiveApp(appUid: any): Promise<void>;
21
+ setActivePublicAppData(): Promise<void>;
22
+ checkActivePublicAppInstalls(): Promise<void>;
23
+ start(): Promise<void>;
24
+ stop(showProgress?: boolean): Promise<void>;
25
+ getActiveAppInstallationData(): Promise<import("@hubspot/local-dev-lib/types/Apps").PublicAppInstallationData>;
26
+ checkPublicAppInstallation(): Promise<void>;
27
+ updateKeypressListeners(): void;
28
+ getUploadCommand(): string;
29
+ logUploadWarning(reason: any): void;
30
+ mostRecentUploadWarning: any;
31
+ monitorConsoleOutput(): void;
32
+ compareLocalProjectToDeployed(): void;
33
+ startWatching(): void;
34
+ stopWatching(): Promise<void>;
35
+ handleWatchEvent(filePath: any, event: any, configPaths: any): void;
36
+ devServerSetup(): Promise<boolean>;
37
+ devServerStart(): Promise<void>;
38
+ devServerFileChange(filePath: any, event: any): void;
39
+ devServerCleanup(): Promise<boolean>;
40
+ }
41
+ import chokidar = require("chokidar");