@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
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const { notifyAboutUpdates } = require('../notificationsMiddleware');
3
+ const notificationsMiddleware_1 = require("../notificationsMiddleware");
4
4
  describe('lib/middleware/notificationsMiddleware', () => {
5
5
  describe('notifyAboutUpdates()', () => {
6
6
  it('should safely execute without throwing an error', () => {
7
- expect(() => notifyAboutUpdates()).not.toThrow();
7
+ expect(() => (0, notificationsMiddleware_1.notifyAboutUpdates)()).not.toThrow();
8
8
  });
9
9
  });
10
10
  });
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const http_1 = require("@hubspot/local-dev-lib/http");
7
7
  const requestMiddleware_1 = require("../requestMiddleware");
8
8
  const package_json_1 = __importDefault(require("../../../package.json"));
9
- jest.mock('@hubspot/local-dev-lib/http', () => ({
10
- addUserAgentHeader: jest.fn(),
9
+ vi.mock('@hubspot/local-dev-lib/http', () => ({
10
+ addUserAgentHeader: vi.fn(),
11
11
  }));
12
12
  describe('lib/middleware/requestMiddleware', () => {
13
13
  describe('setRequestHeaders()', () => {
@@ -37,17 +37,17 @@ const logger_1 = require("@hubspot/local-dev-lib/logger");
37
37
  const exitCodes_1 = require("../../enums/exitCodes");
38
38
  const projectsConfig = __importStar(require("../../projects/config"));
39
39
  const yargsChecksMiddleware_1 = require("../yargsChecksMiddleware");
40
- jest.mock('@hubspot/local-dev-lib/logger', () => ({
40
+ vi.mock('@hubspot/local-dev-lib/logger', () => ({
41
41
  logger: {
42
- error: jest.fn(),
42
+ error: vi.fn(),
43
43
  },
44
44
  }));
45
- jest.mock('../../projects/config');
46
- jest.mock('../../lang', () => ({
47
- i18n: jest.fn(key => key),
45
+ vi.mock('../../projects/config');
46
+ vi.mock('../../lang', () => ({
47
+ i18n: vi.fn(key => key),
48
48
  }));
49
- const getIsInProjectSpy = jest.spyOn(projectsConfig, 'getIsInProject');
50
- const processExitSpy = jest.spyOn(process, 'exit');
49
+ const getIsInProjectSpy = vi.spyOn(projectsConfig, 'getIsInProject');
50
+ const processExitSpy = vi.spyOn(process, 'exit');
51
51
  describe('lib/middleware/yargsChecksMiddleware', () => {
52
52
  beforeEach(() => {
53
53
  processExitSpy.mockImplementation(code => {
@@ -1,38 +1,41 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.notifyAboutUpdates = notifyAboutUpdates;
4
7
  // Update-notifier is CommonJS, so we need to use require
5
8
  const updateNotifier = require('update-notifier');
6
- const chalk = require('chalk');
7
- const pkg = require('../../package.json');
8
- const { UI_COLORS, uiCommandReference } = require('../ui');
9
- const { i18n } = require('../lang');
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const package_json_1 = __importDefault(require("../../package.json"));
11
+ const ui_1 = require("../ui");
12
+ const lang_1 = require("../lang");
10
13
  const notifier = updateNotifier({
11
- pkg: { ...pkg, name: '@hubspot/cli' },
14
+ pkg: { ...package_json_1.default, name: '@hubspot/cli' },
12
15
  distTag: 'latest',
13
16
  shouldNotifyInNpmScript: true,
14
17
  });
15
18
  const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
16
19
  function notifyAboutUpdates() {
17
20
  notifier.notify({
18
- message: pkg.name === CMS_CLI_PACKAGE_NAME
19
- ? i18n(`commands.generalErrors.updateNotify.cmsUpdateNotification`, {
21
+ message: package_json_1.default.name === CMS_CLI_PACKAGE_NAME
22
+ ? (0, lang_1.i18n)(`commands.generalErrors.updateNotify.cmsUpdateNotification`, {
20
23
  packageName: CMS_CLI_PACKAGE_NAME,
21
- updateCommand: uiCommandReference('{updateCommand}'),
24
+ updateCommand: (0, ui_1.uiCommandReference)('{updateCommand}'),
22
25
  })
23
- : i18n(`commands.generalErrors.updateNotify.cliUpdateNotification`, {
24
- updateCommand: uiCommandReference('{updateCommand}'),
26
+ : (0, lang_1.i18n)(`commands.generalErrors.updateNotify.cliUpdateNotification`, {
27
+ updateCommand: (0, ui_1.uiCommandReference)('{updateCommand}'),
25
28
  }),
26
29
  defer: false,
27
30
  boxenOptions: {
28
- borderColor: UI_COLORS.MARIGOLD_DARK,
31
+ borderColor: ui_1.UI_COLORS.MARIGOLD_DARK,
29
32
  margin: 1,
30
33
  padding: 1,
31
34
  textAlignment: 'center',
32
35
  borderStyle: 'round',
33
- title: pkg.name === CMS_CLI_PACKAGE_NAME
36
+ title: package_json_1.default.name === CMS_CLI_PACKAGE_NAME
34
37
  ? null
35
- : chalk.bold(i18n(`commands.generalErrors.updateNotify.notifyTitle`)),
38
+ : chalk_1.default.bold((0, lang_1.i18n)(`commands.generalErrors.updateNotify.notifyTitle`)),
36
39
  },
37
40
  });
38
41
  }
@@ -0,0 +1,517 @@
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 vitest_1 = require("vitest");
7
+ // Mock the ui-extensions-dev-server module
8
+ vitest_1.vi.mock('@hubspot/ui-extensions-dev-server', () => {
9
+ return {
10
+ DevModeUnifiedInterface: {
11
+ setup: vitest_1.vi.fn().mockResolvedValue(undefined),
12
+ start: vitest_1.vi.fn().mockResolvedValue(undefined),
13
+ fileChange: vitest_1.vi.fn().mockResolvedValue(undefined),
14
+ cleanup: vitest_1.vi.fn().mockResolvedValue(undefined),
15
+ },
16
+ };
17
+ });
18
+ const localDevAuth_1 = require("@hubspot/local-dev-lib/api/localDevAuth");
19
+ const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
20
+ const ui_extensions_dev_server_1 = require("@hubspot/ui-extensions-dev-server");
21
+ const portManager_1 = require("@hubspot/local-dev-lib/portManager");
22
+ const config_1 = require("@hubspot/local-dev-lib/config");
23
+ const AppDevModeInterface_1 = __importDefault(require("../localDev/AppDevModeInterface"));
24
+ const LocalDevState_1 = __importDefault(require("../localDev/LocalDevState"));
25
+ const LocalDevLogger_1 = __importDefault(require("../localDev/LocalDevLogger"));
26
+ const installAppPrompt_1 = require("../../prompts/installAppPrompt");
27
+ const promptUtils_1 = require("../../prompts/promptUtils");
28
+ const urls_1 = require("../../app/urls");
29
+ const accountTypes_1 = require("../../accountTypes");
30
+ const index_1 = require("../../errorHandlers/index");
31
+ const constants_1 = require("../../constants");
32
+ const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
33
+ vitest_1.vi.mock('@hubspot/local-dev-lib/api/localDevAuth');
34
+ vitest_1.vi.mock('@hubspot/local-dev-lib/api/appsDev');
35
+ vitest_1.vi.mock('@hubspot/local-dev-lib/portManager');
36
+ vitest_1.vi.mock('@hubspot/local-dev-lib/config');
37
+ vitest_1.vi.mock('../../prompts/installAppPrompt');
38
+ vitest_1.vi.mock('../../prompts/promptUtils');
39
+ vitest_1.vi.mock('../../app/urls');
40
+ vitest_1.vi.mock('../../accountTypes');
41
+ vitest_1.vi.mock('../../ui/logger');
42
+ vitest_1.vi.mock('../../errorHandlers/index');
43
+ vitest_1.vi.mock('../localDev/LocalDevState');
44
+ vitest_1.vi.mock('../localDev/LocalDevLogger');
45
+ describe('AppDevModeInterface', () => {
46
+ let appDevModeInterface;
47
+ let mockLocalDevState;
48
+ let mockLocalDevLogger;
49
+ const mockProjectConfig = {
50
+ name: 'test-project',
51
+ srcDir: 'src',
52
+ platformVersion: '1.0.0',
53
+ };
54
+ const mockAppNode = {
55
+ uid: 'test-app-uid',
56
+ componentType: 'APPLICATION',
57
+ config: {
58
+ name: 'Test App',
59
+ description: 'Test app description',
60
+ logo: 'logo.png',
61
+ auth: {
62
+ type: constants_1.APP_AUTH_TYPES.STATIC,
63
+ requiredScopes: ['test-scope'],
64
+ optionalScopes: [],
65
+ conditionallyRequiredScopes: [],
66
+ redirectUrls: ['http://localhost:3000'],
67
+ },
68
+ distribution: constants_1.APP_DISTRIBUTION_TYPES.PRIVATE,
69
+ },
70
+ localDev: {
71
+ componentRoot: '/test/path',
72
+ componentConfigPath: '/test/path/config.json',
73
+ configUpdatedSinceLastUpload: false,
74
+ },
75
+ componentDeps: {},
76
+ metaFilePath: '/test/path',
77
+ files: [],
78
+ };
79
+ const mockAppData = {
80
+ id: 123,
81
+ clientId: 'test-client-id',
82
+ name: 'Test App',
83
+ installationState: constants_1.APP_INSTALLATION_STATES.NOT_INSTALLED,
84
+ scopeGroupIds: [1, 2, 3],
85
+ };
86
+ const mockPublicApp = {
87
+ id: 123,
88
+ clientId: 'test-client-id',
89
+ name: 'Test App',
90
+ sourceId: 'test-app-uid',
91
+ scopeGroupIds: [1, 2, 3],
92
+ };
93
+ beforeEach(() => {
94
+ vitest_1.vi.clearAllMocks();
95
+ mockLocalDevState = {
96
+ targetProjectAccountId: 12345,
97
+ targetTestingAccountId: 67890,
98
+ projectConfig: mockProjectConfig,
99
+ projectDir: '/test/project',
100
+ projectId: 999,
101
+ env: environments_1.ENVIRONMENTS.PROD,
102
+ projectNodes: { [mockAppNode.uid]: mockAppNode },
103
+ getAppDataByUid: vitest_1.vi.fn(),
104
+ setAppDataForUid: vitest_1.vi.fn(),
105
+ addListener: vitest_1.vi.fn(),
106
+ };
107
+ mockLocalDevLogger = {
108
+ addUploadWarning: vitest_1.vi.fn(),
109
+ };
110
+ // Mock constructors
111
+ LocalDevState_1.default.mockImplementation(() => mockLocalDevState);
112
+ LocalDevLogger_1.default.mockImplementation(() => mockLocalDevLogger);
113
+ // Mock external dependencies
114
+ appsDev_1.fetchPublicAppsForPortal.mockResolvedValue({
115
+ data: { results: [mockPublicApp] },
116
+ });
117
+ appsDev_1.fetchPublicAppProductionInstallCounts.mockResolvedValue({
118
+ data: { uniquePortalInstallCount: 5 },
119
+ });
120
+ localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
121
+ data: {
122
+ isInstalledWithScopeGroups: true,
123
+ previouslyAuthorizedScopeGroups: [],
124
+ },
125
+ });
126
+ config_1.getAccountConfig.mockReturnValue({
127
+ parentAccountId: 12345,
128
+ });
129
+ accountTypes_1.isDeveloperTestAccount.mockReturnValue(true);
130
+ accountTypes_1.isSandbox.mockReturnValue(false);
131
+ urls_1.getOauthAppInstallUrl.mockReturnValue('http://oauth-install-url');
132
+ urls_1.getStaticAuthAppInstallUrl.mockReturnValue('http://static-install-url');
133
+ installAppPrompt_1.installAppAutoPrompt.mockResolvedValue(true);
134
+ installAppPrompt_1.installAppBrowserPrompt.mockResolvedValue(undefined);
135
+ promptUtils_1.confirmPrompt.mockResolvedValue(true);
136
+ appsDev_1.installStaticAuthAppOnTestAccount.mockResolvedValue(undefined);
137
+ // Mock process.exit
138
+ vitest_1.vi.spyOn(global.process, 'exit').mockImplementation((code) => {
139
+ throw new Error(`Process.exit called with code ${code}`);
140
+ });
141
+ appDevModeInterface = new AppDevModeInterface_1.default({
142
+ localDevState: mockLocalDevState,
143
+ localDevLogger: mockLocalDevLogger,
144
+ });
145
+ });
146
+ describe('constructor', () => {
147
+ it('should initialize with valid state', () => {
148
+ expect(appDevModeInterface).toBeInstanceOf(AppDevModeInterface_1.default);
149
+ expect(appDevModeInterface.localDevState).toBe(mockLocalDevState);
150
+ expect(appDevModeInterface.localDevLogger).toBe(mockLocalDevLogger);
151
+ });
152
+ it('should exit if targetProjectAccountId is missing', () => {
153
+ const mockLocalDevStateWithoutAccountId = {
154
+ ...mockLocalDevState,
155
+ targetProjectAccountId: null,
156
+ };
157
+ expect(() => {
158
+ new AppDevModeInterface_1.default({
159
+ localDevState: mockLocalDevStateWithoutAccountId,
160
+ localDevLogger: mockLocalDevLogger,
161
+ });
162
+ }).toThrow('Process.exit called with code 1');
163
+ });
164
+ it('should exit if projectConfig is missing', () => {
165
+ const mockLocalDevStateWithoutConfig = {
166
+ ...mockLocalDevState,
167
+ projectConfig: null,
168
+ };
169
+ expect(() => {
170
+ new AppDevModeInterface_1.default({
171
+ localDevState: mockLocalDevStateWithoutConfig,
172
+ localDevLogger: mockLocalDevLogger,
173
+ });
174
+ }).toThrow('Process.exit called with code 1');
175
+ });
176
+ it('should exit if projectDir is missing', () => {
177
+ const mockLocalDevStateWithoutDir = {
178
+ ...mockLocalDevState,
179
+ projectDir: null,
180
+ };
181
+ expect(() => {
182
+ new AppDevModeInterface_1.default({
183
+ localDevState: mockLocalDevStateWithoutDir,
184
+ localDevLogger: mockLocalDevLogger,
185
+ });
186
+ }).toThrow('Process.exit called with code 1');
187
+ });
188
+ });
189
+ describe('setup()', () => {
190
+ beforeEach(() => {
191
+ mockLocalDevState.getAppDataByUid.mockReturnValue(mockAppData);
192
+ });
193
+ it('should return early if no app node exists', async () => {
194
+ mockLocalDevState.projectNodes = {};
195
+ await appDevModeInterface.setup({});
196
+ expect(appsDev_1.fetchPublicAppsForPortal).not.toHaveBeenCalled();
197
+ expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.setup).not.toHaveBeenCalled();
198
+ });
199
+ it('should setup successfully with private app', async () => {
200
+ await appDevModeInterface.setup({});
201
+ expect(appsDev_1.fetchPublicAppsForPortal).toHaveBeenCalledWith(12345);
202
+ expect(appsDev_1.fetchPublicAppProductionInstallCounts).toHaveBeenCalledWith(123, 12345);
203
+ expect(localDevAuth_1.fetchAppInstallationData).toHaveBeenCalledWith(67890, 999, 'test-app-uid', ['test-scope'], []);
204
+ expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.setup).toHaveBeenCalled();
205
+ });
206
+ it('should show marketplace warning for marketplace apps', async () => {
207
+ const marketplaceAppNode = {
208
+ ...mockAppNode,
209
+ config: {
210
+ ...mockAppNode.config,
211
+ distribution: constants_1.APP_DISTRIBUTION_TYPES.MARKETPLACE,
212
+ },
213
+ };
214
+ mockLocalDevState.projectNodes = {
215
+ [marketplaceAppNode.uid]: marketplaceAppNode,
216
+ };
217
+ await appDevModeInterface.setup({});
218
+ expect(promptUtils_1.confirmPrompt).toHaveBeenCalled();
219
+ expect(mockLocalDevLogger.addUploadWarning).toHaveBeenCalled();
220
+ });
221
+ it('should exit if user declines marketplace warning', async () => {
222
+ const marketplaceAppNode = {
223
+ ...mockAppNode,
224
+ config: {
225
+ ...mockAppNode.config,
226
+ distribution: constants_1.APP_DISTRIBUTION_TYPES.MARKETPLACE,
227
+ },
228
+ };
229
+ mockLocalDevState.projectNodes = {
230
+ [marketplaceAppNode.uid]: marketplaceAppNode,
231
+ };
232
+ // Set up conditions to trigger marketplace warning
233
+ appsDev_1.fetchPublicAppProductionInstallCounts.mockResolvedValue({
234
+ data: { uniquePortalInstallCount: 5 },
235
+ });
236
+ mockLocalDevState.getAppDataByUid.mockReturnValue(mockAppData);
237
+ promptUtils_1.confirmPrompt.mockResolvedValue(false);
238
+ // Create a new instance to trigger the exit during setup
239
+ const newAppDevModeInterface = new AppDevModeInterface_1.default({
240
+ localDevState: mockLocalDevState,
241
+ localDevLogger: mockLocalDevLogger,
242
+ });
243
+ // The setup method catches the error, so we check that process.exit was called
244
+ await newAppDevModeInterface.setup({});
245
+ expect(process.exit).toHaveBeenCalledWith(0);
246
+ });
247
+ it('should auto-install static auth app on test account', async () => {
248
+ localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
249
+ data: {
250
+ isInstalledWithScopeGroups: false,
251
+ previouslyAuthorizedScopeGroups: [],
252
+ },
253
+ });
254
+ await appDevModeInterface.setup({});
255
+ expect(appsDev_1.installStaticAuthAppOnTestAccount).toHaveBeenCalledWith(123, 67890, [1, 2, 3]);
256
+ });
257
+ it('should open browser for OAuth app installation', async () => {
258
+ const oauthAppNode = {
259
+ ...mockAppNode,
260
+ config: {
261
+ ...mockAppNode.config,
262
+ auth: {
263
+ ...mockAppNode.config.auth,
264
+ type: constants_1.APP_AUTH_TYPES.OAUTH,
265
+ },
266
+ },
267
+ };
268
+ mockLocalDevState.projectNodes = { [oauthAppNode.uid]: oauthAppNode };
269
+ localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
270
+ data: {
271
+ isInstalledWithScopeGroups: false,
272
+ previouslyAuthorizedScopeGroups: [],
273
+ },
274
+ });
275
+ await appDevModeInterface.setup({});
276
+ expect(urls_1.getOauthAppInstallUrl).toHaveBeenCalledWith({
277
+ targetAccountId: 67890,
278
+ env: environments_1.ENVIRONMENTS.PROD,
279
+ clientId: 'test-client-id',
280
+ scopes: ['test-scope'],
281
+ redirectUrls: ['http://localhost:3000'],
282
+ });
283
+ expect(installAppPrompt_1.installAppBrowserPrompt).toHaveBeenCalled();
284
+ });
285
+ it('should handle app reinstallation', async () => {
286
+ // Set up conditions for non-automatic installation
287
+ config_1.getAccountConfig.mockReturnValue(null);
288
+ localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
289
+ data: {
290
+ isInstalledWithScopeGroups: false,
291
+ previouslyAuthorizedScopeGroups: ['old-scope'],
292
+ },
293
+ });
294
+ await appDevModeInterface.setup({});
295
+ expect(installAppPrompt_1.installAppBrowserPrompt).toHaveBeenCalledWith('http://static-install-url', true);
296
+ });
297
+ it('should handle errors during setup', async () => {
298
+ const error = new Error('Setup failed');
299
+ appsDev_1.fetchPublicAppsForPortal.mockRejectedValue(error);
300
+ await appDevModeInterface.setup({});
301
+ expect(index_1.logError).toHaveBeenCalledWith(error);
302
+ });
303
+ it('should exit if app not found in portal', async () => {
304
+ // Set up conditions for non-automatic installation to force getAppInstallUrl call
305
+ config_1.getAccountConfig.mockReturnValue(null);
306
+ // First call for fetchAppData succeeds
307
+ appsDev_1.fetchPublicAppsForPortal
308
+ .mockResolvedValueOnce({
309
+ data: { results: [mockPublicApp] },
310
+ })
311
+ // Second call for getAppInstallUrl fails (app not found)
312
+ .mockResolvedValueOnce({
313
+ data: { results: [] },
314
+ });
315
+ localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
316
+ data: {
317
+ isInstalledWithScopeGroups: false,
318
+ previouslyAuthorizedScopeGroups: [],
319
+ },
320
+ });
321
+ // The setup method catches the error, so we check that process.exit was called
322
+ await appDevModeInterface.setup({});
323
+ expect(process.exit).toHaveBeenCalledWith(1);
324
+ });
325
+ it('should exit if user declines auto-install', async () => {
326
+ // Set up conditions for automatic installation
327
+ config_1.getAccountConfig.mockReturnValue({
328
+ parentAccountId: 12345, // matches targetProjectAccountId
329
+ });
330
+ accountTypes_1.isDeveloperTestAccount.mockReturnValue(true);
331
+ localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
332
+ data: {
333
+ isInstalledWithScopeGroups: false,
334
+ previouslyAuthorizedScopeGroups: [],
335
+ },
336
+ });
337
+ installAppPrompt_1.installAppAutoPrompt.mockResolvedValue(false);
338
+ // Create a new instance to trigger the exit during setup
339
+ const newAppDevModeInterface = new AppDevModeInterface_1.default({
340
+ localDevState: mockLocalDevState,
341
+ localDevLogger: mockLocalDevLogger,
342
+ });
343
+ // The setup method catches the error, so we check that process.exit was called
344
+ await newAppDevModeInterface.setup({});
345
+ expect(process.exit).toHaveBeenCalledWith(0);
346
+ });
347
+ it('should fallback to browser install if auto-install fails', async () => {
348
+ localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
349
+ data: {
350
+ isInstalledWithScopeGroups: false,
351
+ previouslyAuthorizedScopeGroups: [],
352
+ },
353
+ });
354
+ appsDev_1.installStaticAuthAppOnTestAccount.mockRejectedValue(new Error('Install failed'));
355
+ await appDevModeInterface.setup({});
356
+ expect(installAppPrompt_1.installAppBrowserPrompt).toHaveBeenCalledWith('http://static-install-url', false);
357
+ });
358
+ });
359
+ describe('start()', () => {
360
+ it('should return early if no app node exists', async () => {
361
+ mockLocalDevState.projectNodes = {};
362
+ await appDevModeInterface.start();
363
+ expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.start).not.toHaveBeenCalled();
364
+ });
365
+ it('should start UIE dev mode interface', async () => {
366
+ await appDevModeInterface.start();
367
+ expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.start).toHaveBeenCalledWith({
368
+ accountId: 67890,
369
+ projectConfig: mockProjectConfig,
370
+ requestPorts: portManager_1.requestPorts,
371
+ });
372
+ });
373
+ });
374
+ describe('fileChange()', () => {
375
+ it('should return early if no app node exists', async () => {
376
+ mockLocalDevState.projectNodes = {};
377
+ await appDevModeInterface.fileChange('test.js', 'change');
378
+ expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.fileChange).not.toHaveBeenCalled();
379
+ });
380
+ it('should forward file change to UIE dev mode interface', async () => {
381
+ await appDevModeInterface.fileChange('test.js', 'change');
382
+ expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.fileChange).toHaveBeenCalledWith('test.js', 'change');
383
+ });
384
+ });
385
+ describe('cleanup()', () => {
386
+ it('should return early if no app node exists', async () => {
387
+ mockLocalDevState.projectNodes = {};
388
+ await appDevModeInterface.cleanup();
389
+ expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.cleanup).not.toHaveBeenCalled();
390
+ });
391
+ it('should cleanup UIE dev mode interface', async () => {
392
+ await appDevModeInterface.cleanup();
393
+ expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.cleanup).toHaveBeenCalled();
394
+ });
395
+ });
396
+ describe('isAutomaticallyInstallable()', () => {
397
+ it('should return true for static auth app on test account with correct parent', () => {
398
+ // This is testing private method behavior through setup()
399
+ expect(appDevModeInterface).toBeDefined();
400
+ });
401
+ it('should return false if target account config is missing', async () => {
402
+ // Reset mocks to ensure clean state
403
+ vitest_1.vi.clearAllMocks();
404
+ // Set up basic mocks
405
+ appsDev_1.fetchPublicAppsForPortal.mockResolvedValue({
406
+ data: { results: [mockPublicApp] },
407
+ });
408
+ appsDev_1.fetchPublicAppProductionInstallCounts.mockResolvedValue({
409
+ data: { uniquePortalInstallCount: 5 },
410
+ });
411
+ urls_1.getStaticAuthAppInstallUrl.mockReturnValue('http://static-install-url');
412
+ installAppPrompt_1.installAppBrowserPrompt.mockResolvedValue(undefined);
413
+ // Reset the mock LocalDevState
414
+ mockLocalDevState.getAppDataByUid = vitest_1.vi.fn().mockReturnValue(mockAppData);
415
+ mockLocalDevState.setAppDataForUid = vitest_1.vi.fn();
416
+ mockLocalDevState.addListener = vitest_1.vi.fn();
417
+ // Target account config is missing
418
+ config_1.getAccountConfig.mockReturnValue(null);
419
+ // App is not installed
420
+ localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
421
+ data: {
422
+ isInstalledWithScopeGroups: false,
423
+ previouslyAuthorizedScopeGroups: [],
424
+ },
425
+ });
426
+ // Create a new instance to avoid interference from previous test setup
427
+ const newAppDevModeInterface = new AppDevModeInterface_1.default({
428
+ localDevState: mockLocalDevState,
429
+ localDevLogger: mockLocalDevLogger,
430
+ });
431
+ await newAppDevModeInterface.setup({});
432
+ expect(installAppPrompt_1.installAppBrowserPrompt).toHaveBeenCalled();
433
+ });
434
+ it('should return false for OAuth app', async () => {
435
+ // Reset mocks to ensure clean state
436
+ vitest_1.vi.clearAllMocks();
437
+ // Set up basic mocks
438
+ appsDev_1.fetchPublicAppsForPortal.mockResolvedValue({
439
+ data: { results: [mockPublicApp] },
440
+ });
441
+ appsDev_1.fetchPublicAppProductionInstallCounts.mockResolvedValue({
442
+ data: { uniquePortalInstallCount: 5 },
443
+ });
444
+ urls_1.getOauthAppInstallUrl.mockReturnValue('http://oauth-install-url');
445
+ installAppPrompt_1.installAppBrowserPrompt.mockResolvedValue(undefined);
446
+ // Reset the mock LocalDevState
447
+ mockLocalDevState.getAppDataByUid = vitest_1.vi.fn().mockReturnValue(mockAppData);
448
+ mockLocalDevState.setAppDataForUid = vitest_1.vi.fn();
449
+ mockLocalDevState.addListener = vitest_1.vi.fn();
450
+ const oauthAppNode = {
451
+ ...mockAppNode,
452
+ config: {
453
+ ...mockAppNode.config,
454
+ auth: {
455
+ ...mockAppNode.config.auth,
456
+ type: constants_1.APP_AUTH_TYPES.OAUTH,
457
+ },
458
+ },
459
+ };
460
+ mockLocalDevState.projectNodes = { [oauthAppNode.uid]: oauthAppNode };
461
+ // App is not installed
462
+ localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
463
+ data: {
464
+ isInstalledWithScopeGroups: false,
465
+ previouslyAuthorizedScopeGroups: [],
466
+ },
467
+ });
468
+ // Create a new instance to avoid interference from previous test setup
469
+ const newAppDevModeInterface = new AppDevModeInterface_1.default({
470
+ localDevState: mockLocalDevState,
471
+ localDevLogger: mockLocalDevLogger,
472
+ });
473
+ await newAppDevModeInterface.setup({});
474
+ expect(installAppPrompt_1.installAppBrowserPrompt).toHaveBeenCalled();
475
+ });
476
+ });
477
+ describe('websocket server message handling', () => {
478
+ it('should check app installation when websocket server connects', async () => {
479
+ // Reset mocks to ensure clean state
480
+ vitest_1.vi.clearAllMocks();
481
+ // Set up basic mocks
482
+ appsDev_1.fetchPublicAppsForPortal.mockResolvedValue({
483
+ data: { results: [mockPublicApp] },
484
+ });
485
+ appsDev_1.fetchPublicAppProductionInstallCounts.mockResolvedValue({
486
+ data: { uniquePortalInstallCount: 5 },
487
+ });
488
+ urls_1.getStaticAuthAppInstallUrl.mockReturnValue('http://static-install-url');
489
+ installAppPrompt_1.installAppBrowserPrompt.mockResolvedValue(undefined);
490
+ // Reset the mock LocalDevState
491
+ mockLocalDevState.getAppDataByUid = vitest_1.vi.fn().mockReturnValue(mockAppData);
492
+ mockLocalDevState.setAppDataForUid = vitest_1.vi.fn();
493
+ mockLocalDevState.addListener = vitest_1.vi.fn();
494
+ // App is not installed so fetchAppInstallationData will be called
495
+ localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
496
+ data: {
497
+ isInstalledWithScopeGroups: false,
498
+ previouslyAuthorizedScopeGroups: [],
499
+ },
500
+ });
501
+ // Create a new instance to avoid interference from previous test setup
502
+ const newAppDevModeInterface = new AppDevModeInterface_1.default({
503
+ localDevState: mockLocalDevState,
504
+ localDevLogger: mockLocalDevLogger,
505
+ });
506
+ await newAppDevModeInterface.setup({});
507
+ // Simulate websocket server connection
508
+ const addListenerCall = mockLocalDevState.addListener.mock
509
+ .calls[0];
510
+ const [eventType, callback] = addListenerCall;
511
+ expect(eventType).toBe('devServerMessage');
512
+ // Call the callback with websocket connection message
513
+ await callback(constants_1.LOCAL_DEV_SERVER_MESSAGE_TYPES.WEBSOCKET_SERVER_CONNECTED);
514
+ expect(localDevAuth_1.fetchAppInstallationData).toHaveBeenCalledTimes(2); // Once in setup, once in listener
515
+ });
516
+ });
517
+ });
@@ -0,0 +1 @@
1
+ export {};