@hubspot/cli 7.7.19-experimental.3 → 7.7.20-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 (296) hide show
  1. package/api/__tests__/migrate.test.d.ts +1 -0
  2. package/api/__tests__/migrate.test.js +183 -0
  3. package/commands/__tests__/account.test.d.ts +1 -0
  4. package/commands/__tests__/account.test.js +74 -0
  5. package/commands/__tests__/auth.test.d.ts +1 -0
  6. package/commands/__tests__/auth.test.js +43 -0
  7. package/commands/__tests__/cms.test.d.ts +1 -0
  8. package/commands/__tests__/cms.test.js +49 -0
  9. package/commands/__tests__/config.test.d.ts +1 -0
  10. package/commands/__tests__/config.test.js +49 -0
  11. package/commands/__tests__/create.test.d.ts +1 -0
  12. package/commands/__tests__/create.test.js +38 -0
  13. package/commands/__tests__/customObject.test.d.ts +1 -0
  14. package/commands/__tests__/customObject.test.js +54 -0
  15. package/commands/__tests__/doctor.test.d.ts +1 -0
  16. package/commands/__tests__/doctor.test.js +139 -0
  17. package/commands/__tests__/feedback.test.d.ts +1 -0
  18. package/commands/__tests__/feedback.test.js +62 -0
  19. package/commands/__tests__/fetch.test.d.ts +1 -0
  20. package/commands/__tests__/fetch.test.js +56 -0
  21. package/commands/__tests__/filemanager.test.d.ts +1 -0
  22. package/commands/__tests__/filemanager.test.js +50 -0
  23. package/commands/__tests__/function.test.d.ts +1 -0
  24. package/commands/__tests__/function.test.js +51 -0
  25. package/commands/__tests__/getStarted.test.d.ts +1 -0
  26. package/commands/__tests__/getStarted.test.js +170 -0
  27. package/commands/__tests__/hubdb.test.d.ts +1 -0
  28. package/commands/__tests__/hubdb.test.js +55 -0
  29. package/commands/__tests__/init.test.d.ts +1 -0
  30. package/commands/__tests__/init.test.js +47 -0
  31. package/commands/__tests__/lint.test.d.ts +1 -0
  32. package/commands/__tests__/lint.test.js +38 -0
  33. package/commands/__tests__/list.test.d.ts +1 -0
  34. package/commands/__tests__/list.test.js +47 -0
  35. package/commands/__tests__/logs.test.d.ts +1 -0
  36. package/commands/__tests__/logs.test.js +70 -0
  37. package/commands/__tests__/mcp.test.d.ts +1 -0
  38. package/commands/__tests__/mcp.test.js +51 -0
  39. package/commands/__tests__/mv.test.d.ts +1 -0
  40. package/commands/__tests__/mv.test.js +84 -0
  41. package/commands/__tests__/open.test.d.ts +1 -0
  42. package/commands/__tests__/open.test.js +96 -0
  43. package/commands/__tests__/project.test.d.ts +1 -0
  44. package/commands/__tests__/project.test.js +100 -0
  45. package/commands/__tests__/remove.test.d.ts +1 -0
  46. package/commands/__tests__/remove.test.js +77 -0
  47. package/commands/__tests__/sandbox.test.d.ts +1 -0
  48. package/commands/__tests__/sandbox.test.js +49 -0
  49. package/commands/__tests__/secret.test.d.ts +1 -0
  50. package/commands/__tests__/secret.test.js +54 -0
  51. package/commands/__tests__/testAccount.test.d.ts +1 -0
  52. package/commands/__tests__/testAccount.test.js +60 -0
  53. package/commands/__tests__/theme.test.d.ts +1 -0
  54. package/commands/__tests__/theme.test.js +52 -0
  55. package/commands/account/__tests__/auth.test.d.ts +1 -0
  56. package/commands/account/__tests__/auth.test.js +31 -0
  57. package/commands/account/__tests__/clean.test.d.ts +1 -0
  58. package/commands/account/__tests__/clean.test.js +33 -0
  59. package/commands/account/__tests__/createOverride.test.d.ts +1 -0
  60. package/commands/account/__tests__/createOverride.test.js +37 -0
  61. package/commands/account/__tests__/info.test.d.ts +1 -0
  62. package/commands/account/__tests__/info.test.js +33 -0
  63. package/commands/account/__tests__/list.test.d.ts +1 -0
  64. package/commands/account/__tests__/list.test.js +33 -0
  65. package/commands/account/__tests__/remove.test.d.ts +1 -0
  66. package/commands/account/__tests__/remove.test.js +41 -0
  67. package/commands/account/__tests__/removeOverride.d.ts +1 -0
  68. package/commands/account/__tests__/removeOverride.js +30 -0
  69. package/commands/account/__tests__/rename.test.d.ts +1 -0
  70. package/commands/account/__tests__/rename.test.js +47 -0
  71. package/commands/account/__tests__/use.test.d.ts +1 -0
  72. package/commands/account/__tests__/use.test.js +37 -0
  73. package/commands/app/__tests__/migrate.test.d.ts +1 -0
  74. package/commands/app/__tests__/migrate.test.js +129 -0
  75. package/commands/app/secret/__tests__/add.test.d.ts +1 -0
  76. package/commands/app/secret/__tests__/add.test.js +33 -0
  77. package/commands/app/secret/__tests__/delete.test.d.ts +1 -0
  78. package/commands/app/secret/__tests__/delete.test.js +33 -0
  79. package/commands/app/secret/__tests__/list.test.d.ts +1 -0
  80. package/commands/app/secret/__tests__/list.test.js +30 -0
  81. package/commands/app/secret/__tests__/update.test.d.ts +1 -0
  82. package/commands/app/secret/__tests__/update.test.js +33 -0
  83. package/commands/app.js +1 -6
  84. package/commands/customObject/__tests__/create.test.d.ts +1 -0
  85. package/commands/customObject/__tests__/create.test.js +45 -0
  86. package/commands/customObject/__tests__/schema.test.d.ts +1 -0
  87. package/commands/customObject/__tests__/schema.test.js +58 -0
  88. package/commands/customObject/schema/__tests__/create.test.d.ts +1 -0
  89. package/commands/customObject/schema/__tests__/create.test.js +33 -0
  90. package/commands/customObject/schema/__tests__/delete.test.d.ts +1 -0
  91. package/commands/customObject/schema/__tests__/delete.test.js +47 -0
  92. package/commands/customObject/schema/__tests__/fetch-all.test.d.ts +1 -0
  93. package/commands/customObject/schema/__tests__/fetch-all.test.js +46 -0
  94. package/commands/customObject/schema/__tests__/fetch.test.d.ts +1 -0
  95. package/commands/customObject/schema/__tests__/fetch.test.js +50 -0
  96. package/commands/customObject/schema/__tests__/list.test.d.ts +1 -0
  97. package/commands/customObject/schema/__tests__/list.test.js +34 -0
  98. package/commands/customObject/schema/__tests__/update.test.d.ts +1 -0
  99. package/commands/customObject/schema/__tests__/update.test.js +45 -0
  100. package/commands/fetch.js +0 -1
  101. package/commands/filemanager/__tests__/fetch.test.d.ts +1 -0
  102. package/commands/filemanager/__tests__/fetch.test.js +37 -0
  103. package/commands/filemanager/__tests__/upload.test.d.ts +1 -0
  104. package/commands/filemanager/__tests__/upload.test.js +35 -0
  105. package/commands/hubdb/__tests__/clear.test.d.ts +1 -0
  106. package/commands/hubdb/__tests__/clear.test.js +33 -0
  107. package/commands/hubdb/__tests__/create.test.d.ts +1 -0
  108. package/commands/hubdb/__tests__/create.test.js +33 -0
  109. package/commands/hubdb/__tests__/delete.test.d.ts +1 -0
  110. package/commands/hubdb/__tests__/delete.test.js +33 -0
  111. package/commands/hubdb/__tests__/fetch.test.d.ts +1 -0
  112. package/commands/hubdb/__tests__/fetch.test.js +33 -0
  113. package/commands/hubdb/__tests__/list.test.d.ts +1 -0
  114. package/commands/hubdb/__tests__/list.test.js +101 -0
  115. package/commands/logs.js +0 -1
  116. package/commands/mcp/__tests__/setup.test.d.ts +1 -0
  117. package/commands/mcp/__tests__/setup.test.js +31 -0
  118. package/commands/mcp/__tests__/start.test.d.ts +1 -0
  119. package/commands/mcp/__tests__/start.test.js +32 -0
  120. package/commands/project/__tests__/add.test.d.ts +1 -0
  121. package/commands/project/__tests__/add.test.js +48 -0
  122. package/commands/project/__tests__/create.test.d.ts +1 -0
  123. package/commands/project/__tests__/create.test.js +45 -0
  124. package/commands/project/__tests__/deploy.test.d.ts +1 -0
  125. package/commands/project/__tests__/deploy.test.js +344 -0
  126. package/commands/project/__tests__/devUnifiedFlow.test.d.ts +1 -0
  127. package/commands/project/__tests__/devUnifiedFlow.test.js +419 -0
  128. package/commands/project/__tests__/download.test.d.ts +1 -0
  129. package/commands/project/__tests__/download.test.js +44 -0
  130. package/commands/project/__tests__/fixtures/exampleProject.json +33 -0
  131. package/commands/project/__tests__/installDeps.test.d.ts +1 -0
  132. package/commands/project/__tests__/installDeps.test.js +180 -0
  133. package/commands/project/__tests__/listBuilds.test.d.ts +1 -0
  134. package/commands/project/__tests__/listBuilds.test.js +43 -0
  135. package/commands/project/__tests__/logs.test.d.ts +1 -0
  136. package/commands/project/__tests__/logs.test.js +246 -0
  137. package/commands/project/__tests__/migrate.test.d.ts +1 -0
  138. package/commands/project/__tests__/migrate.test.js +116 -0
  139. package/commands/project/__tests__/migrateApp.test.d.ts +1 -0
  140. package/commands/project/__tests__/migrateApp.test.js +87 -0
  141. package/commands/project/__tests__/open.test.d.ts +1 -0
  142. package/commands/project/__tests__/open.test.js +44 -0
  143. package/commands/project/__tests__/profile.test.d.ts +1 -0
  144. package/commands/project/__tests__/profile.test.js +47 -0
  145. package/commands/project/__tests__/upload.test.d.ts +1 -0
  146. package/commands/project/__tests__/upload.test.js +48 -0
  147. package/commands/project/__tests__/watch.test.d.ts +1 -0
  148. package/commands/project/__tests__/watch.test.js +40 -0
  149. package/commands/project/dev/unifiedFlow.js +1 -1
  150. package/commands/sandbox/__tests__/create.test.d.ts +1 -0
  151. package/commands/sandbox/__tests__/create.test.js +36 -0
  152. package/commands/sandbox/__tests__/delete.test.d.ts +1 -0
  153. package/commands/sandbox/__tests__/delete.test.js +36 -0
  154. package/commands/secret/__tests__/addSecret.test.d.ts +1 -0
  155. package/commands/secret/__tests__/addSecret.test.js +34 -0
  156. package/commands/secret/__tests__/deleteSecret.test.d.ts +1 -0
  157. package/commands/secret/__tests__/deleteSecret.test.js +46 -0
  158. package/commands/secret/__tests__/listSecret.test.d.ts +1 -0
  159. package/commands/secret/__tests__/listSecret.test.js +34 -0
  160. package/commands/secret/__tests__/updateSecret.test.d.ts +1 -0
  161. package/commands/secret/__tests__/updateSecret.test.js +34 -0
  162. package/commands/testAccount/__tests__/create.test.d.ts +1 -0
  163. package/commands/testAccount/__tests__/create.test.js +38 -0
  164. package/commands/testAccount/__tests__/createConfig.test.d.ts +1 -0
  165. package/commands/testAccount/__tests__/createConfig.test.js +40 -0
  166. package/commands/testAccount/__tests__/delete.test.d.ts +1 -0
  167. package/commands/testAccount/__tests__/delete.test.js +36 -0
  168. package/commands/testAccount/create.js +24 -14
  169. package/commands/theme/__tests__/generate-selectors.test.d.ts +1 -0
  170. package/commands/theme/__tests__/generate-selectors.test.js +33 -0
  171. package/commands/theme/__tests__/marketplace-validate.test.d.ts +1 -0
  172. package/commands/theme/__tests__/marketplace-validate.test.js +41 -0
  173. package/commands/theme/__tests__/preview.test.d.ts +1 -0
  174. package/commands/theme/__tests__/preview.test.js +65 -0
  175. package/lang/en.d.ts +6 -65
  176. package/lang/en.js +6 -65
  177. package/lib/__tests__/accountTypes.test.d.ts +1 -0
  178. package/lib/__tests__/accountTypes.test.js +100 -0
  179. package/lib/__tests__/buildAccount.test.d.ts +1 -0
  180. package/lib/__tests__/buildAccount.test.js +231 -0
  181. package/lib/__tests__/commonOpts.test.d.ts +1 -0
  182. package/lib/__tests__/commonOpts.test.js +87 -0
  183. package/lib/__tests__/dependencyManagement.test.d.ts +1 -0
  184. package/lib/__tests__/dependencyManagement.test.js +180 -0
  185. package/lib/__tests__/developerTestAccounts.test.d.ts +1 -0
  186. package/lib/__tests__/developerTestAccounts.test.js +180 -0
  187. package/lib/__tests__/hasFeature.test.d.ts +1 -0
  188. package/lib/__tests__/hasFeature.test.js +37 -0
  189. package/lib/__tests__/npm.test.d.ts +1 -0
  190. package/lib/__tests__/npm.test.js +62 -0
  191. package/lib/__tests__/oauth.test.d.ts +1 -0
  192. package/lib/__tests__/oauth.test.js +113 -0
  193. package/lib/__tests__/parsing.test.d.ts +1 -0
  194. package/lib/__tests__/parsing.test.js +36 -0
  195. package/lib/__tests__/polling.test.d.ts +1 -0
  196. package/lib/__tests__/polling.test.js +78 -0
  197. package/lib/__tests__/process.test.d.ts +1 -0
  198. package/lib/__tests__/process.test.js +90 -0
  199. package/lib/__tests__/projectProfiles.test.d.ts +1 -0
  200. package/lib/__tests__/projectProfiles.test.js +134 -0
  201. package/lib/__tests__/sandboxSync.test.d.ts +1 -0
  202. package/lib/__tests__/sandboxSync.test.js +131 -0
  203. package/lib/__tests__/sandboxes.test.d.ts +1 -0
  204. package/lib/__tests__/sandboxes.test.js +148 -0
  205. package/lib/__tests__/serverlessLogs.test.d.ts +1 -0
  206. package/lib/__tests__/serverlessLogs.test.js +154 -0
  207. package/lib/__tests__/usageTracking.test.d.ts +1 -0
  208. package/lib/__tests__/usageTracking.test.js +171 -0
  209. package/lib/__tests__/validation.test.d.ts +1 -0
  210. package/lib/__tests__/validation.test.js +145 -0
  211. package/lib/__tests__/yargsUtils.test.d.ts +1 -0
  212. package/lib/__tests__/yargsUtils.test.js +74 -0
  213. package/lib/app/__tests__/migrate.test.d.ts +1 -0
  214. package/lib/app/__tests__/migrate.test.js +495 -0
  215. package/lib/app/__tests__/migrate_legacy.test.d.ts +1 -0
  216. package/lib/app/__tests__/migrate_legacy.test.js +136 -0
  217. package/lib/buildAccount.d.ts +1 -7
  218. package/lib/buildAccount.js +4 -54
  219. package/lib/doctor/Diagnosis.js +11 -11
  220. package/lib/doctor/Doctor.js +42 -42
  221. package/lib/doctor/__tests__/Diagnosis.test.d.ts +1 -0
  222. package/lib/doctor/__tests__/Diagnosis.test.js +87 -0
  223. package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.d.ts +1 -0
  224. package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +172 -0
  225. package/lib/doctor/__tests__/Doctor.test.d.ts +1 -0
  226. package/lib/doctor/__tests__/Doctor.test.js +398 -0
  227. package/lib/mcp/setup.js +18 -2
  228. package/lib/middleware/__test__/configMiddleware.test.js +12 -12
  229. package/lib/middleware/__test__/gitMiddleware.test.js +4 -4
  230. package/lib/middleware/__test__/notificationsMiddleware.test.js +2 -2
  231. package/lib/middleware/__test__/requestMiddleware.test.js +2 -2
  232. package/lib/middleware/__test__/yargsChecksMiddleware.test.js +7 -7
  233. package/lib/middleware/notificationsMiddleware.js +16 -13
  234. package/lib/projects/__tests__/AppDevModeInterface.test.d.ts +1 -0
  235. package/lib/projects/__tests__/AppDevModeInterface.test.js +517 -0
  236. package/lib/projects/__tests__/LocalDevProcess.test.d.ts +1 -0
  237. package/lib/projects/__tests__/LocalDevProcess.test.js +314 -0
  238. package/lib/projects/__tests__/LocalDevWebsocketServer.test.d.ts +1 -0
  239. package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +175 -0
  240. package/lib/projects/__tests__/ProjectLogsManager.test.d.ts +1 -0
  241. package/lib/projects/__tests__/ProjectLogsManager.test.js +191 -0
  242. package/lib/projects/__tests__/buildAndDeploy.test.d.ts +1 -0
  243. package/lib/projects/__tests__/buildAndDeploy.test.js +25 -0
  244. package/lib/projects/__tests__/components.test.d.ts +1 -0
  245. package/lib/projects/__tests__/components.test.js +186 -0
  246. package/lib/projects/__tests__/projects.test.d.ts +1 -0
  247. package/lib/projects/__tests__/projects.test.js +89 -0
  248. package/lib/projects/__tests__/structure.test.d.ts +1 -0
  249. package/lib/projects/__tests__/structure.test.js +249 -0
  250. package/lib/projects/add/__tests__/legacyAddComponent.test.d.ts +1 -0
  251. package/lib/projects/add/__tests__/legacyAddComponent.test.js +206 -0
  252. package/lib/projects/add/__tests__/v3AddComponent.test.d.ts +1 -0
  253. package/lib/projects/add/__tests__/v3AddComponent.test.js +190 -0
  254. package/lib/projects/create/__tests__/legacy.test.d.ts +1 -0
  255. package/lib/projects/create/__tests__/legacy.test.js +126 -0
  256. package/lib/projects/create/__tests__/v3.test.d.ts +1 -0
  257. package/lib/projects/create/__tests__/v3.test.js +80 -0
  258. package/lib/projects/localDev/DevServerManager.js +0 -1
  259. package/lib/projects/localDev/helpers.d.ts +1 -1
  260. package/lib/projects/localDev/helpers.js +2 -2
  261. package/lib/projects/structure.d.ts +2 -2
  262. package/lib/projects/upload.d.ts +1 -2
  263. package/lib/projects/upload.js +0 -1
  264. package/lib/prompts/__tests__/downloadProjectPrompt.test.d.ts +1 -0
  265. package/lib/prompts/__tests__/downloadProjectPrompt.test.js +30 -0
  266. package/lib/prompts/__tests__/projectsLogsPrompt.test.d.ts +1 -0
  267. package/lib/prompts/__tests__/projectsLogsPrompt.test.js +42 -0
  268. package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +10 -9
  269. package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +43 -81
  270. package/lib/schema.js +5 -1
  271. package/lib/ui/SpinniesManager.js +0 -1
  272. package/lib/ui/supportHyperlinks.js +2 -2
  273. package/lib/ui/supportsColor.js +2 -2
  274. package/lib/utils/hasFlag.d.ts +1 -0
  275. package/lib/utils/hasFlag.js +15 -0
  276. package/lib/yargsUtils.d.ts +2 -1
  277. package/lib/yargsUtils.js +3 -13
  278. package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.d.ts +1 -0
  279. package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.js +152 -0
  280. package/mcp-server/tools/project/__tests__/CreateProjectTool.test.d.ts +1 -0
  281. package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +129 -0
  282. package/mcp-server/tools/project/__tests__/DeployProject.test.d.ts +1 -0
  283. package/mcp-server/tools/project/__tests__/DeployProject.test.js +120 -0
  284. package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.d.ts +1 -0
  285. package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +127 -0
  286. package/mcp-server/tools/project/__tests__/UploadProjectTools.test.d.ts +1 -0
  287. package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +108 -0
  288. package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.d.ts +1 -0
  289. package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +111 -0
  290. package/mcp-server/utils/__tests__/command.test.d.ts +1 -0
  291. package/mcp-server/utils/__tests__/command.test.js +47 -0
  292. package/mcp-server/utils/__tests__/project.test.d.ts +1 -0
  293. package/mcp-server/utils/__tests__/project.test.js +81 -0
  294. package/package.json +8 -8
  295. package/commands/app/install.d.ts +0 -8
  296. package/commands/app/install.js +0 -127
@@ -0,0 +1,231 @@
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
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
37
+ const config_1 = require("@hubspot/local-dev-lib/config");
38
+ const developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTestAccounts");
39
+ const sandboxHubs_1 = require("@hubspot/local-dev-lib/api/sandboxHubs");
40
+ const config_2 = require("@hubspot/local-dev-lib/constants/config");
41
+ const personalAccessKeyPrompt_1 = require("../prompts/personalAccessKeyPrompt");
42
+ const accountNamePrompt_1 = require("../prompts/accountNamePrompt");
43
+ const buildAccount = __importStar(require("../buildAccount"));
44
+ vi.mock('@hubspot/local-dev-lib/personalAccessKey');
45
+ vi.mock('@hubspot/local-dev-lib/config');
46
+ vi.mock('@hubspot/local-dev-lib/api/developerTestAccounts');
47
+ vi.mock('@hubspot/local-dev-lib/api/sandboxHubs');
48
+ vi.mock('@hubspot/local-dev-lib/logger');
49
+ vi.mock('../prompts/personalAccessKeyPrompt');
50
+ vi.mock('../prompts/accountNamePrompt');
51
+ vi.mock('../ui/SpinniesManager', () => ({
52
+ default: {
53
+ init: vi.fn(),
54
+ add: vi.fn(),
55
+ succeed: vi.fn(),
56
+ fail: vi.fn(),
57
+ },
58
+ }));
59
+ const mockedPersonalAccessKeyPrompt = personalAccessKeyPrompt_1.personalAccessKeyPrompt;
60
+ const mockedGetAccessToken = personalAccessKey_1.getAccessToken;
61
+ const mockedUpdateConfigWithAccessToken = personalAccessKey_1.updateConfigWithAccessToken;
62
+ const mockedAccountNameExistsInConfig = config_1.accountNameExistsInConfig;
63
+ const mockedUpdateAccountConfig = config_1.updateAccountConfig;
64
+ const mockedWriteConfig = config_1.writeConfig;
65
+ const mockedCliAccountNamePrompt = accountNamePrompt_1.cliAccountNamePrompt;
66
+ const mockedGetAccountId = config_1.getAccountId;
67
+ const mockedCreateDeveloperTestAccount = developerTestAccounts_1.createDeveloperTestAccount;
68
+ const mockedCreateSandbox = sandboxHubs_1.createSandbox;
69
+ describe('lib/buildAccount', () => {
70
+ describe('saveAccountToConfig()', () => {
71
+ const mockAccountConfig = {
72
+ name: 'Test Account',
73
+ accountId: 123456,
74
+ accountType: config_2.HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER,
75
+ env: 'prod',
76
+ };
77
+ const accessToken = {
78
+ portalId: 123456,
79
+ accessToken: 'test-token',
80
+ expiresAt: '2025-01-01',
81
+ scopeGroups: ['test-scope'],
82
+ enabledFeatures: { 'test-feature': 1 },
83
+ encodedOAuthRefreshToken: 'test-refresh-token',
84
+ hubName: 'test-hub',
85
+ accountType: config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD,
86
+ };
87
+ beforeEach(() => {
88
+ mockedPersonalAccessKeyPrompt.mockResolvedValue({
89
+ personalAccessKey: 'test-key',
90
+ env: 'prod',
91
+ });
92
+ mockedGetAccessToken.mockResolvedValue(accessToken);
93
+ mockedUpdateConfigWithAccessToken.mockResolvedValue(mockAccountConfig);
94
+ mockedAccountNameExistsInConfig.mockResolvedValue(false);
95
+ mockedUpdateAccountConfig.mockReturnValue(undefined);
96
+ mockedWriteConfig.mockReturnValue(undefined);
97
+ });
98
+ afterEach(() => {
99
+ vi.clearAllMocks();
100
+ });
101
+ it('should save account with provided personal access key', async () => {
102
+ const result = await buildAccount.saveAccountToConfig(mockAccountConfig.accountId, mockAccountConfig.name, mockAccountConfig.env, 'test-key');
103
+ expect(mockedPersonalAccessKeyPrompt).not.toHaveBeenCalled();
104
+ expect(mockedUpdateConfigWithAccessToken).toHaveBeenCalledWith(accessToken, 'test-key', mockAccountConfig.env);
105
+ expect(mockedUpdateAccountConfig).toHaveBeenCalledWith(expect.objectContaining(mockAccountConfig));
106
+ expect(mockedWriteConfig).toHaveBeenCalled();
107
+ expect(result).toBe(mockAccountConfig.name);
108
+ });
109
+ it('should prompt for personal access key if not provided', async () => {
110
+ const result = await buildAccount.saveAccountToConfig(mockAccountConfig.accountId, mockAccountConfig.name, mockAccountConfig.env);
111
+ expect(mockedPersonalAccessKeyPrompt).toHaveBeenCalledWith({
112
+ env: mockAccountConfig.env,
113
+ account: mockAccountConfig.accountId,
114
+ });
115
+ expect(mockedUpdateConfigWithAccessToken).toHaveBeenCalledWith(accessToken, 'test-key', mockAccountConfig.env);
116
+ expect(mockedUpdateAccountConfig).toHaveBeenCalledWith(expect.objectContaining(mockAccountConfig));
117
+ expect(mockedWriteConfig).toHaveBeenCalled();
118
+ expect(result).toBe(mockAccountConfig.name);
119
+ });
120
+ it('should handle duplicate account names', async () => {
121
+ const mockAccountConfigWithNoName = {
122
+ ...mockAccountConfig,
123
+ name: undefined,
124
+ };
125
+ mockedUpdateConfigWithAccessToken.mockResolvedValue(mockAccountConfigWithNoName);
126
+ mockedAccountNameExistsInConfig.mockResolvedValue(true);
127
+ mockedCliAccountNamePrompt.mockResolvedValue({
128
+ name: 'test-account-with-new-name',
129
+ });
130
+ const result = await buildAccount.saveAccountToConfig(mockAccountConfig.accountId, mockAccountConfig.name, mockAccountConfig.env, 'test-key');
131
+ expect(mockedCliAccountNamePrompt).toHaveBeenCalled();
132
+ expect(result).toBe('test-account-with-new-name');
133
+ });
134
+ });
135
+ describe('buildDeveloperTestAccount()', () => {
136
+ const mockParentAccountConfig = {
137
+ name: 'Developer Test Account',
138
+ accountId: 123456,
139
+ accountType: config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
140
+ env: 'prod',
141
+ };
142
+ const mockDeveloperTestAccount = {
143
+ testPortalId: 56789,
144
+ parentPortalId: 123456,
145
+ accountName: 'Developer Test Account',
146
+ createdAt: '2025-01-01',
147
+ updatedAt: '2025-01-01',
148
+ status: 'active',
149
+ id: 56789,
150
+ };
151
+ beforeEach(() => {
152
+ vi.spyOn(buildAccount, 'saveAccountToConfig').mockResolvedValue(mockParentAccountConfig.name);
153
+ mockedGetAccountId.mockReturnValue(mockParentAccountConfig.accountId);
154
+ mockedCreateDeveloperTestAccount.mockResolvedValue({
155
+ data: mockDeveloperTestAccount,
156
+ });
157
+ });
158
+ afterEach(() => {
159
+ vi.clearAllMocks();
160
+ });
161
+ it('should create a developer test account successfully', async () => {
162
+ const result = await buildAccount.buildDeveloperTestAccount(mockDeveloperTestAccount.accountName, mockParentAccountConfig, mockParentAccountConfig.env, 10);
163
+ expect(result).toEqual(mockDeveloperTestAccount.id);
164
+ });
165
+ it('should throw error if account ID is not found', async () => {
166
+ mockedGetAccountId.mockReturnValue(null);
167
+ await expect(buildAccount.buildDeveloperTestAccount(mockDeveloperTestAccount.accountName, mockParentAccountConfig, mockParentAccountConfig.env, 10)).rejects.toThrow();
168
+ });
169
+ it('should handle API errors when creating developer test account', async () => {
170
+ mockedCreateDeveloperTestAccount.mockRejectedValue(new Error('test-error'));
171
+ await expect(buildAccount.buildDeveloperTestAccount(mockDeveloperTestAccount.accountName, mockParentAccountConfig, mockParentAccountConfig.env, 10)).rejects.toThrow();
172
+ });
173
+ });
174
+ describe('buildSandbox()', () => {
175
+ const mockParentAccountConfig = {
176
+ name: 'Developer Test Account',
177
+ accountId: 123456,
178
+ accountType: config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
179
+ env: 'prod',
180
+ };
181
+ const mockSandbox = {
182
+ sandboxHubId: 56789,
183
+ parentHubId: 123456,
184
+ createdAt: '2025-01-01',
185
+ type: 'sandbox',
186
+ archived: false,
187
+ name: 'Test Sandbox',
188
+ domain: 'test-sandbox.hubspot.com',
189
+ createdByUser: {
190
+ id: 123456,
191
+ email: 'test@test.com',
192
+ firstName: 'Test',
193
+ lastName: 'User',
194
+ },
195
+ };
196
+ beforeEach(() => {
197
+ vi.spyOn(buildAccount, 'saveAccountToConfig').mockResolvedValue(mockParentAccountConfig.name);
198
+ mockedGetAccountId.mockReturnValue(mockParentAccountConfig.accountId);
199
+ mockedCreateSandbox.mockResolvedValue({
200
+ data: { sandbox: mockSandbox, personalAccessKey: 'test-key' },
201
+ });
202
+ });
203
+ afterEach(() => {
204
+ vi.clearAllMocks();
205
+ });
206
+ it('should create a standard sandbox successfully', async () => {
207
+ const result = await buildAccount.buildSandbox(mockSandbox.name, mockParentAccountConfig, config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX, mockParentAccountConfig.env, false);
208
+ expect(result).toEqual({
209
+ name: mockSandbox.name,
210
+ personalAccessKey: 'test-key',
211
+ sandbox: mockSandbox,
212
+ });
213
+ });
214
+ it('should create a development sandbox successfully', async () => {
215
+ const result = await buildAccount.buildSandbox(mockSandbox.name, mockParentAccountConfig, config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX, mockParentAccountConfig.env);
216
+ expect(result).toEqual({
217
+ name: mockSandbox.name,
218
+ personalAccessKey: 'test-key',
219
+ sandbox: mockSandbox,
220
+ });
221
+ });
222
+ it('should throw error if account ID is not found', async () => {
223
+ mockedGetAccountId.mockReturnValue(null);
224
+ await expect(buildAccount.buildSandbox(mockSandbox.name, mockParentAccountConfig, config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX, mockParentAccountConfig.env)).rejects.toThrow();
225
+ });
226
+ it('should handle API errors when creating sandbox', async () => {
227
+ mockedCreateSandbox.mockRejectedValue(new Error('test-error'));
228
+ await expect(buildAccount.buildSandbox(mockSandbox.name, mockParentAccountConfig, config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX, mockParentAccountConfig.env, false)).rejects.toThrow();
229
+ });
230
+ });
231
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const files_1 = require("@hubspot/local-dev-lib/constants/files");
4
+ const config_1 = require("@hubspot/local-dev-lib/config");
5
+ const commonOpts_1 = require("../commonOpts");
6
+ const mockedGetAccountConfig = config_1.getAccountConfig;
7
+ const mockedGetAndLoadConfigIfNeeded = config_1.getAndLoadConfigIfNeeded;
8
+ const mockedLoadConfigFromEnvironment = config_1.loadConfigFromEnvironment;
9
+ function buildArguments(args) {
10
+ return {
11
+ _: [],
12
+ $0: '',
13
+ ...args,
14
+ };
15
+ }
16
+ vi.mock('@hubspot/local-dev-lib/config');
17
+ vi.mock('@hubspot/local-dev-lib/logger');
18
+ describe('lib/commonOpts', () => {
19
+ describe('getCmsPublishMode()', () => {
20
+ const accounts = {
21
+ PROD: 123,
22
+ DEV: 456,
23
+ };
24
+ const devAccountConfig = {
25
+ accountId: accounts.DEV,
26
+ name: 'DEV',
27
+ defaultCmsPublishMode: files_1.CMS_PUBLISH_MODE.draft,
28
+ };
29
+ const prodAccountConfig = {
30
+ accountId: accounts.PROD,
31
+ name: 'PROD',
32
+ };
33
+ const config = {
34
+ defaultAccount: 'DEV',
35
+ accounts: [devAccountConfig, prodAccountConfig],
36
+ };
37
+ const configWithDefaultCmsPublishMode = {
38
+ ...config,
39
+ defaultCmsPublishMode: files_1.CMS_PUBLISH_MODE.draft,
40
+ };
41
+ afterEach(() => {
42
+ vi.resetAllMocks();
43
+ });
44
+ describe('cms publish mode option precedence', () => {
45
+ describe('1. --cmsPublishMode', () => {
46
+ it('should return the cms publish mode specified by the command option if present.', () => {
47
+ mockedGetAndLoadConfigIfNeeded.mockReturnValue(configWithDefaultCmsPublishMode);
48
+ mockedGetAccountConfig.mockReturnValue(devAccountConfig);
49
+ expect((0, commonOpts_1.getCmsPublishMode)(buildArguments({
50
+ cmsPublishMode: files_1.CMS_PUBLISH_MODE.draft,
51
+ }))).toBe(files_1.CMS_PUBLISH_MODE.draft);
52
+ expect((0, commonOpts_1.getCmsPublishMode)(buildArguments({
53
+ cmsPublishMode: files_1.CMS_PUBLISH_MODE.publish,
54
+ }))).toBe(files_1.CMS_PUBLISH_MODE.publish);
55
+ });
56
+ });
57
+ describe('2. hubspot.config.yml -> config.accounts[x].defaultCmsPublishMode', () => {
58
+ it('should return the defaultCmsPublishMode specified by the account specific config if present.', () => {
59
+ mockedGetAndLoadConfigIfNeeded.mockReturnValue(configWithDefaultCmsPublishMode);
60
+ mockedGetAccountConfig.mockReturnValue(devAccountConfig);
61
+ mockedLoadConfigFromEnvironment.mockReturnValue(undefined);
62
+ expect((0, commonOpts_1.getCmsPublishMode)(buildArguments({
63
+ account: accounts.DEV,
64
+ }))).toBe(files_1.CMS_PUBLISH_MODE.draft);
65
+ });
66
+ });
67
+ describe('3. hubspot.config.yml -> config.defaultCmsPublishMode', () => {
68
+ it('should return the defaultCmsPublishMode specified by the config if present.', () => {
69
+ mockedGetAndLoadConfigIfNeeded.mockReturnValue(configWithDefaultCmsPublishMode);
70
+ mockedGetAccountConfig.mockReturnValue(prodAccountConfig);
71
+ mockedLoadConfigFromEnvironment.mockReturnValue(undefined);
72
+ expect((0, commonOpts_1.getCmsPublishMode)(buildArguments({
73
+ account: accounts.PROD,
74
+ }))).toBe(files_1.CMS_PUBLISH_MODE.draft);
75
+ });
76
+ });
77
+ describe('4. DEFAULT_CMS_PUBLISH_MODE', () => {
78
+ it('should return the defaultCmsPubishMode specified by the config if present.', () => {
79
+ mockedLoadConfigFromEnvironment.mockReturnValue(undefined);
80
+ expect((0, commonOpts_1.getCmsPublishMode)(buildArguments({
81
+ account: 'xxxxx',
82
+ }))).toBe(files_1.DEFAULT_CMS_PUBLISH_MODE);
83
+ });
84
+ });
85
+ });
86
+ });
87
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const util_1 = __importDefault(require("util"));
7
+ const dependencyManagement_1 = require("../dependencyManagement");
8
+ const fs_1 = require("@hubspot/local-dev-lib/fs");
9
+ const path_1 = __importDefault(require("path"));
10
+ const config_1 = require("../projects/config");
11
+ const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
12
+ const fs_2 = __importDefault(require("fs"));
13
+ vi.mock('../projects/config');
14
+ vi.mock('@hubspot/local-dev-lib/logger');
15
+ vi.mock('@hubspot/local-dev-lib/fs');
16
+ vi.mock('fs');
17
+ vi.mock('../ui/SpinniesManager', () => ({
18
+ default: {
19
+ init: vi.fn(),
20
+ add: vi.fn(),
21
+ succeed: vi.fn(),
22
+ fail: vi.fn(),
23
+ },
24
+ }));
25
+ const mockedFs = vi.mocked(fs_2.default);
26
+ describe('lib/dependencyManagement', () => {
27
+ let execMock;
28
+ const projectDir = path_1.default.join('path', 'to', 'project');
29
+ const srcDir = 'src';
30
+ const appDir = path_1.default.join(projectDir, srcDir, 'app');
31
+ const appFunctionsDir = path_1.default.join(appDir, 'app.functions');
32
+ const extensionsDir = path_1.default.join(appDir, 'exensions');
33
+ const projectName = 'super cool test project';
34
+ const installLocations = [appFunctionsDir, extensionsDir];
35
+ function mockedPromisify(execMock) {
36
+ return vi
37
+ .fn()
38
+ .mockReturnValue(execMock);
39
+ }
40
+ const mockedWalk = fs_1.walk;
41
+ const mockedGetProjectConfig = config_1.getProjectConfig;
42
+ beforeEach(() => {
43
+ execMock = vi.fn();
44
+ util_1.default.promisify = mockedPromisify(execMock);
45
+ mockedGetProjectConfig.mockResolvedValue({
46
+ projectDir,
47
+ projectConfig: {
48
+ srcDir,
49
+ name: projectName,
50
+ },
51
+ });
52
+ mockedFs.existsSync.mockReturnValue(true); // Default to true, override in specific tests
53
+ vi.clearAllMocks();
54
+ });
55
+ describe('installPackages()', () => {
56
+ it('should setup a loading spinner', async () => {
57
+ const packages = ['package1', 'package2'];
58
+ await (0, dependencyManagement_1.installPackages)({ packages, installLocations });
59
+ expect(SpinniesManager_1.default.init).toHaveBeenCalledTimes(installLocations.length);
60
+ expect(SpinniesManager_1.default.add).toHaveBeenCalledTimes(installLocations.length);
61
+ expect(SpinniesManager_1.default.succeed).toHaveBeenCalledTimes(installLocations.length);
62
+ });
63
+ it('should install the provided packages in all the provided install locations', async () => {
64
+ const packages = ['package1', 'package2'];
65
+ await (0, dependencyManagement_1.installPackages)({ packages, installLocations });
66
+ expect(execMock).toHaveBeenCalledTimes(installLocations.length);
67
+ expect(SpinniesManager_1.default.add).toHaveBeenCalledTimes(installLocations.length);
68
+ expect(SpinniesManager_1.default.succeed).toHaveBeenCalledTimes(installLocations.length);
69
+ for (const location of installLocations) {
70
+ expect(execMock).toHaveBeenCalledWith(`npm install package1 package2`, {
71
+ cwd: location,
72
+ });
73
+ expect(SpinniesManager_1.default.add).toHaveBeenCalledWith(`installingDependencies-${location}`, {
74
+ text: `Installing [package1, package2] in ${location}`,
75
+ });
76
+ expect(SpinniesManager_1.default.succeed).toHaveBeenCalledWith(`installingDependencies-${location}`, {
77
+ text: `Installed dependencies in ${location}`,
78
+ });
79
+ }
80
+ });
81
+ it('should use the provided install locations', async () => {
82
+ await (0, dependencyManagement_1.installPackages)({ installLocations });
83
+ expect(execMock).toHaveBeenCalledTimes(installLocations.length);
84
+ expect(execMock).toHaveBeenCalledWith(`npm install `, {
85
+ cwd: appFunctionsDir,
86
+ });
87
+ expect(execMock).toHaveBeenCalledWith(`npm install `, {
88
+ cwd: extensionsDir,
89
+ });
90
+ });
91
+ it('should locate the projects package.json files when install locations is not provided', async () => {
92
+ const installLocations = [
93
+ path_1.default.join(appFunctionsDir, 'package.json'),
94
+ path_1.default.join(extensionsDir, 'package.json'),
95
+ ];
96
+ mockedWalk.mockResolvedValue(installLocations);
97
+ mockedGetProjectConfig.mockResolvedValue({
98
+ projectDir,
99
+ projectConfig: {
100
+ srcDir,
101
+ },
102
+ });
103
+ await (0, dependencyManagement_1.installPackages)({});
104
+ // It's called once per each install location, plus once to check if npm installed
105
+ expect(execMock).toHaveBeenCalledTimes(installLocations.length + 1);
106
+ expect(execMock).toHaveBeenCalledWith(`npm install `, {
107
+ cwd: appFunctionsDir,
108
+ });
109
+ expect(execMock).toHaveBeenCalledWith(`npm install `, {
110
+ cwd: extensionsDir,
111
+ });
112
+ });
113
+ it('should throw an error when installing the dependencies fails', async () => {
114
+ execMock = vi.fn().mockImplementation(command => {
115
+ if (command === 'npm --version') {
116
+ return;
117
+ }
118
+ throw new Error('OH NO');
119
+ });
120
+ util_1.default.promisify = mockedPromisify(execMock);
121
+ // Mock walk to return the directory paths instead of package.json paths
122
+ mockedWalk.mockResolvedValue([appFunctionsDir, extensionsDir]);
123
+ mockedFs.existsSync.mockImplementation(filePath => {
124
+ const pathStr = filePath.toString();
125
+ if (pathStr === projectDir ||
126
+ pathStr === path_1.default.join(projectDir, srcDir)) {
127
+ return true;
128
+ }
129
+ return false;
130
+ });
131
+ await expect(() => (0, dependencyManagement_1.installPackages)({ installLocations: [appFunctionsDir, extensionsDir] })).rejects.toThrowError(`Installing dependencies for ${appFunctionsDir} failed`);
132
+ expect(SpinniesManager_1.default.fail).toHaveBeenCalledTimes(installLocations.length);
133
+ expect(SpinniesManager_1.default.fail).toHaveBeenCalledWith(`installingDependencies-${appFunctionsDir}`, {
134
+ text: `Installing dependencies for ${appFunctionsDir} failed`,
135
+ });
136
+ expect(SpinniesManager_1.default.fail).toHaveBeenCalledWith(`installingDependencies-${extensionsDir}`, {
137
+ text: `Installing dependencies for ${extensionsDir} failed`,
138
+ });
139
+ });
140
+ });
141
+ describe('getProjectPackageJsonFiles()', () => {
142
+ it('should throw an error when ran outside the boundary of a project', async () => {
143
+ mockedGetProjectConfig.mockResolvedValue({});
144
+ await expect(() => (0, dependencyManagement_1.getProjectPackageJsonLocations)()).rejects.toThrowError('No project detected. Run this command from a project directory.');
145
+ });
146
+ it('should throw an error if npm is not globally installed', async () => {
147
+ execMock = vi.fn().mockImplementation(() => {
148
+ throw new Error('OH NO');
149
+ });
150
+ util_1.default.promisify = mockedPromisify(execMock);
151
+ await expect(() => (0, dependencyManagement_1.getProjectPackageJsonLocations)()).rejects.toThrowError(/This command depends on npm, install/);
152
+ });
153
+ it('should throw an error if the project directory does not exist', async () => {
154
+ mockedFs.existsSync.mockReturnValueOnce(false);
155
+ await expect(() => (0, dependencyManagement_1.getProjectPackageJsonLocations)()).rejects.toThrowError(new RegExp(`No dependencies to install. The project ${projectName} folder might be missing component or subcomponent files.`));
156
+ });
157
+ it('should ignore package.json files in certain directories', async () => {
158
+ const nodeModulesDir = path_1.default.join(appDir, 'node_modules');
159
+ const viteDir = path_1.default.join(appDir, '.vite');
160
+ const installLocations = [
161
+ path_1.default.join(appFunctionsDir, 'package.json'),
162
+ path_1.default.join(extensionsDir, 'package.json'),
163
+ path_1.default.join(viteDir, 'package.json'),
164
+ path_1.default.join(nodeModulesDir, 'package.json'),
165
+ ];
166
+ mockedWalk.mockResolvedValue(installLocations);
167
+ mockedFs.existsSync.mockImplementation(filePath => {
168
+ // Return true for project directory and src directory
169
+ const pathStr = filePath.toString();
170
+ if (pathStr === projectDir ||
171
+ pathStr === path_1.default.join(projectDir, srcDir)) {
172
+ return true;
173
+ }
174
+ return false;
175
+ });
176
+ const actual = await (0, dependencyManagement_1.getProjectPackageJsonLocations)();
177
+ expect(actual).toEqual([appFunctionsDir, extensionsDir]);
178
+ });
179
+ });
180
+ });
@@ -0,0 +1 @@
1
+ export {};