@hubspot/cli 7.8.12-experimental.0 → 7.9.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +31 -25
- package/commands/__tests__/auth.test.js +5 -0
- package/commands/__tests__/cms.test.js +44 -1
- package/commands/__tests__/customObject.test.js +22 -1
- package/commands/__tests__/doctor.test.js +16 -16
- package/commands/__tests__/project.test.js +2 -0
- package/commands/account/auth.js +1 -0
- package/commands/account/clean.js +18 -27
- package/commands/account/createOverride.js +13 -31
- package/commands/account/info.js +20 -31
- package/commands/account/list.js +16 -22
- package/commands/account/remove.js +12 -20
- package/commands/account/removeOverride.js +11 -21
- package/commands/account/rename.js +6 -9
- package/commands/account/use.js +12 -26
- package/commands/account.js +2 -2
- package/commands/app/__tests__/migrate.test.js +5 -5
- package/commands/app/migrate.js +13 -18
- package/commands/app.js +1 -6
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +17 -7
- package/commands/{__tests__/remove.test.js → cms/__tests__/delete.test.js} +8 -8
- package/commands/{__tests__ → cms/__tests__}/fetch.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/function.test.js +7 -3
- package/commands/{__tests__ → cms/__tests__}/lint.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/list.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/mv.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/theme.test.js +9 -2
- package/commands/cms/app/create.d.ts +9 -0
- package/commands/cms/app/create.js +82 -0
- package/commands/cms/app.d.ts +3 -0
- package/commands/cms/app.js +17 -0
- package/commands/cms/convertFields.js +7 -9
- package/commands/cms/delete.d.ts +6 -0
- package/commands/cms/delete.js +43 -0
- package/commands/cms/fetch.d.ts +12 -0
- package/commands/cms/fetch.js +79 -0
- package/commands/{__tests__ → cms/function/__tests__}/logs.test.js +4 -5
- package/commands/cms/function/create.d.ts +12 -0
- package/commands/cms/function/create.js +84 -0
- package/commands/cms/function/deploy.d.ts +6 -0
- package/commands/cms/function/deploy.js +89 -0
- package/commands/cms/function/list.d.ts +6 -0
- package/commands/cms/function/list.js +60 -0
- package/commands/cms/function/logs.d.ts +10 -0
- package/commands/cms/function/logs.js +135 -0
- package/commands/cms/function/server.d.ts +10 -0
- package/commands/cms/function/server.js +69 -0
- package/commands/cms/function.d.ts +3 -0
- package/commands/cms/function.js +27 -0
- package/commands/cms/getReactModule.js +9 -14
- package/commands/cms/lighthouseScore.js +33 -36
- package/commands/cms/lint.d.ts +6 -0
- package/commands/cms/lint.js +83 -0
- package/commands/cms/list.d.ts +6 -0
- package/commands/cms/list.js +96 -0
- package/commands/cms/module/create.d.ts +11 -0
- package/commands/cms/module/create.js +84 -0
- package/commands/cms/module/marketplace-validate.d.ts +6 -0
- package/commands/cms/module/marketplace-validate.js +45 -0
- package/commands/cms/module.d.ts +3 -0
- package/commands/cms/module.js +17 -0
- package/commands/cms/mv.d.ts +7 -0
- package/commands/cms/mv.js +60 -0
- package/commands/cms/template/create.d.ts +9 -0
- package/commands/cms/template/create.js +72 -0
- package/commands/cms/template.d.ts +3 -0
- package/commands/cms/template.js +17 -0
- package/commands/{theme → cms/theme}/__tests__/marketplace-validate.test.js +2 -2
- package/commands/{theme → cms/theme}/__tests__/preview.test.js +2 -2
- package/commands/cms/theme/create.d.ts +6 -0
- package/commands/cms/theme/create.js +58 -0
- package/commands/cms/theme/generate-selectors.d.ts +6 -0
- package/commands/cms/theme/generate-selectors.js +171 -0
- package/commands/cms/theme/marketplace-validate.d.ts +6 -0
- package/commands/cms/theme/marketplace-validate.js +46 -0
- package/commands/cms/theme/preview.d.ts +12 -0
- package/commands/cms/theme/preview.js +224 -0
- package/commands/cms/theme.d.ts +3 -0
- package/commands/cms/theme.js +25 -0
- package/commands/cms/upload.d.ts +12 -0
- package/commands/cms/upload.js +212 -0
- package/commands/cms/watch.d.ts +14 -0
- package/commands/cms/watch.js +138 -0
- package/commands/cms/webpack/create.d.ts +6 -0
- package/commands/cms/webpack/create.js +58 -0
- package/commands/cms/webpack.d.ts +3 -0
- package/commands/cms/webpack.js +17 -0
- package/commands/cms.js +28 -2
- package/commands/completion.js +3 -3
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +64 -36
- package/commands/config.js +2 -2
- package/commands/create.js +6 -4
- package/commands/customObject/{schema/__tests__/create.test.js → __tests__/createSchema.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/delete.test.js → __tests__/deleteSchema.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/fetch-all.test.js → __tests__/fetch-all-schemas.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/fetch.test.js → __tests__/fetchSchema.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/list.test.js → __tests__/listSchemas.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/update.test.js → __tests__/updateSchema.test.js} +5 -5
- package/commands/customObject/create.js +10 -12
- package/commands/customObject/createSchema.d.ts +6 -0
- package/commands/customObject/createSchema.js +56 -0
- package/commands/customObject/deleteSchema.d.ts +7 -0
- package/commands/customObject/deleteSchema.js +69 -0
- package/commands/customObject/fetchAllSchemas.d.ts +6 -0
- package/commands/customObject/fetchAllSchemas.js +57 -0
- package/commands/customObject/fetchSchema.d.ts +7 -0
- package/commands/customObject/fetchSchema.js +67 -0
- package/commands/customObject/listSchemas.d.ts +4 -0
- package/commands/customObject/listSchemas.js +35 -0
- package/commands/customObject/schema/create.d.ts +4 -6
- package/commands/customObject/schema/create.js +13 -38
- package/commands/customObject/schema/delete.d.ts +4 -7
- package/commands/customObject/schema/delete.js +15 -50
- package/commands/customObject/schema/fetch-all.d.ts +4 -6
- package/commands/customObject/schema/fetch-all.js +14 -40
- package/commands/customObject/schema/fetch.d.ts +4 -7
- package/commands/customObject/schema/fetch.js +14 -49
- package/commands/customObject/schema/list.d.ts +4 -4
- package/commands/customObject/schema/list.js +10 -19
- package/commands/customObject/schema/update.d.ts +4 -7
- package/commands/customObject/schema/update.js +15 -50
- package/commands/customObject/schema.js +5 -3
- package/commands/customObject/updateSchema.d.ts +7 -0
- package/commands/customObject/updateSchema.js +71 -0
- package/commands/customObject.js +22 -8
- package/commands/doctor.js +8 -11
- package/commands/feedback.js +7 -12
- package/commands/fetch.d.ts +4 -12
- package/commands/fetch.js +20 -47
- package/commands/filemanager/fetch.js +7 -7
- package/commands/filemanager/upload.js +15 -34
- package/commands/filemanager.js +2 -2
- package/commands/function/deploy.d.ts +4 -6
- package/commands/function/deploy.js +14 -89
- package/commands/function/list.d.ts +4 -6
- package/commands/function/list.js +14 -40
- package/commands/function/server.d.ts +4 -10
- package/commands/function/server.js +22 -31
- package/commands/function.d.ts +2 -4
- package/commands/function.js +25 -14
- package/commands/getStarted.js +2 -2
- package/commands/hubdb/clear.js +7 -15
- package/commands/hubdb/create.js +9 -15
- package/commands/hubdb/delete.js +8 -15
- package/commands/hubdb/fetch.js +6 -9
- package/commands/hubdb.d.ts +1 -1
- package/commands/hubdb.js +2 -2
- package/commands/init.js +2 -3
- package/commands/lint.d.ts +4 -6
- package/commands/lint.js +13 -65
- package/commands/list.d.ts +4 -6
- package/commands/list.js +14 -81
- package/commands/logs.d.ts +4 -10
- package/commands/logs.js +25 -94
- package/commands/module/marketplace-validate.d.ts +4 -6
- package/commands/module/marketplace-validate.js +15 -27
- package/commands/module.d.ts +2 -2
- package/commands/module.js +17 -15
- package/commands/mv.d.ts +4 -7
- package/commands/mv.js +14 -51
- package/commands/open.js +5 -5
- package/commands/project/__tests__/add.test.js +15 -13
- package/commands/project/__tests__/deploy.test.js +3 -4
- package/commands/project/__tests__/devUnifiedFlow.test.js +32 -0
- package/commands/project/__tests__/installDeps.test.js +8 -8
- package/commands/project/__tests__/list.test.js +31 -0
- package/commands/project/__tests__/logs.test.js +1 -1
- package/commands/project/__tests__/migrate.test.js +6 -5
- package/commands/project/__tests__/migrateApp.test.js +2 -5
- package/commands/project/__tests__/validate.test.js +98 -0
- package/commands/project/add.d.ts +2 -2
- package/commands/project/add.js +6 -5
- package/commands/project/cloneApp.js +14 -19
- package/commands/project/create.js +1 -2
- package/commands/project/deploy.js +3 -3
- package/commands/project/dev/deprecatedFlow.js +9 -18
- package/commands/project/dev/index.js +19 -17
- package/commands/project/dev/unifiedFlow.js +11 -4
- package/commands/project/download.js +15 -15
- package/commands/project/installDeps.d.ts +2 -2
- package/commands/project/installDeps.js +9 -8
- package/commands/project/list.d.ts +4 -0
- package/commands/project/list.js +62 -0
- package/commands/project/listBuilds.js +11 -20
- package/commands/project/logs.js +21 -24
- package/commands/project/migrate.js +5 -2
- package/commands/project/migrateApp.js +9 -15
- package/commands/project/open.js +6 -13
- package/commands/project/upload.d.ts +2 -2
- package/commands/project/upload.js +17 -26
- package/commands/project/validate.js +6 -6
- package/commands/project/watch.js +13 -22
- package/commands/project.js +4 -2
- package/commands/remove.d.ts +4 -6
- package/commands/remove.js +12 -24
- package/commands/sandbox/__tests__/create.test.js +5 -5
- package/commands/sandbox/create.js +22 -32
- package/commands/sandbox/delete.js +38 -63
- package/commands/sandbox.js +2 -2
- package/commands/secret/addSecret.js +7 -17
- package/commands/secret/deleteSecret.js +10 -20
- package/commands/secret/listSecret.js +8 -10
- package/commands/secret/updateSecret.js +9 -17
- package/commands/secret.js +2 -2
- package/commands/testAccount/__tests__/delete.test.js +2 -4
- package/commands/testAccount/create.js +2 -5
- package/commands/testAccount/delete.d.ts +4 -3
- package/commands/testAccount/delete.js +155 -14
- package/commands/theme/generate-selectors.d.ts +4 -6
- package/commands/theme/generate-selectors.js +14 -152
- package/commands/theme/marketplace-validate.d.ts +4 -6
- package/commands/theme/marketplace-validate.js +14 -25
- package/commands/theme/preview.d.ts +4 -12
- package/commands/theme/preview.js +18 -183
- package/commands/theme.d.ts +2 -2
- package/commands/theme.js +19 -13
- package/commands/upload.d.ts +4 -12
- package/commands/upload.js +19 -169
- package/commands/watch.d.ts +4 -14
- package/commands/watch.js +23 -88
- package/lang/en.d.ts +863 -542
- package/lang/en.js +912 -595
- package/lang/en.lyaml +4 -4
- package/lib/__tests__/buildAccount.test.js +4 -3
- package/lib/__tests__/commonOpts.test.js +1 -1
- package/lib/__tests__/dependencyManagement.test.js +1 -1
- package/lib/__tests__/developerTestAccounts.test.js +3 -3
- package/lib/__tests__/npm.test.js +1 -1
- package/lib/__tests__/oauth.test.js +4 -4
- package/lib/__tests__/process.test.js +10 -5
- package/lib/__tests__/sandboxSync.test.js +8 -8
- package/lib/__tests__/sandboxes.test.js +8 -8
- package/lib/__tests__/serverlessLogs.test.js +1 -1
- package/lib/__tests__/usageTracking.test.js +5 -5
- package/lib/__tests__/validation.test.js +2 -1
- package/lib/__tests__/yargsUtils.test.js +83 -9
- package/lib/app/__tests__/migrate.test.js +5 -5
- package/lib/app/__tests__/migrate_legacy.test.js +1 -1
- package/lib/app/migrate.js +1 -1
- package/lib/app/migrate_legacy.js +20 -24
- package/lib/buildAccount.d.ts +2 -2
- package/lib/buildAccount.js +32 -64
- package/lib/commonOpts.d.ts +1 -1
- package/lib/commonOpts.js +25 -22
- package/lib/configMigrate.js +88 -9
- package/lib/configOptions.js +7 -0
- package/lib/constants.d.ts +15 -1
- package/lib/constants.js +19 -1
- package/lib/dependencyManagement.js +9 -27
- package/lib/developerTestAccounts.js +9 -23
- package/lib/doctor/Diagnosis.js +11 -23
- package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
- package/lib/doctor/Doctor.js +42 -90
- package/lib/doctor/__tests__/Doctor.test.js +4 -4
- package/lib/errorHandlers/index.js +12 -20
- package/lib/errorHandlers/suppressError.js +11 -18
- package/lib/generateSelectors.js +1 -1
- package/lib/lang.js +6 -5
- package/lib/links.js +4 -4
- package/lib/middleware/__test__/commandTargetingUtils.test.js +99 -0
- package/lib/middleware/__test__/configMiddleware.test.js +11 -11
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +6 -8
- package/lib/middleware/autoUpdateMiddleware.d.ts +2 -1
- package/lib/middleware/autoUpdateMiddleware.js +12 -2
- package/lib/middleware/commandTargetingUtils.d.ts +8 -0
- package/lib/middleware/commandTargetingUtils.js +74 -0
- package/lib/middleware/configMiddleware.d.ts +1 -1
- package/lib/middleware/configMiddleware.js +21 -81
- package/lib/middleware/gitMiddleware.js +5 -1
- package/lib/middleware/notificationsMiddleware.js +5 -11
- package/lib/middleware/yargsChecksMiddleware.js +6 -9
- package/lib/npm.js +2 -2
- package/lib/oauth.js +5 -5
- package/lib/process.js +5 -4
- package/lib/projectProfiles.d.ts +1 -1
- package/lib/projectProfiles.js +2 -10
- package/lib/projects/__tests__/AppDevModeInterface.test.js +101 -135
- package/lib/projects/__tests__/DevServerManager.test.js +183 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +6 -5
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +76 -45
- package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.d.ts +1 -0
- package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.js +161 -0
- package/lib/projects/__tests__/deploy.test.js +9 -9
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +2 -0
- package/lib/projects/__tests__/platformVersion.test.js +8 -8
- package/lib/projects/__tests__/projects.test.js +12 -12
- package/lib/projects/__tests__/structure.test.js +3 -3
- package/lib/projects/__tests__/upload.test.d.ts +1 -0
- package/lib/projects/__tests__/upload.test.js +82 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +6 -6
- package/lib/projects/add/__tests__/v2AddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/{v3AddComponent.test.js → v2AddComponent.test.js} +39 -39
- package/lib/projects/add/{v3AddComponent.d.ts → v2AddComponent.d.ts} +1 -1
- package/lib/projects/add/{v3AddComponent.js → v2AddComponent.js} +5 -5
- package/lib/projects/create/__tests__/legacy.test.js +5 -5
- package/lib/projects/create/__tests__/v2.test.d.ts +1 -0
- package/lib/projects/create/__tests__/{v3.test.js → v2.test.js} +3 -3
- package/lib/projects/create/index.js +4 -4
- package/lib/projects/create/legacy.js +2 -2
- package/lib/projects/create/{v3.d.ts → v2.d.ts} +3 -3
- package/lib/projects/create/{v3.js → v2.js} +5 -5
- package/lib/projects/deploy.d.ts +1 -1
- package/lib/projects/deploy.js +2 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +11 -3
- package/lib/projects/localDev/AppDevModeInterface.js +128 -115
- package/lib/projects/localDev/DevServerManager.d.ts +10 -29
- package/lib/projects/localDev/DevServerManager.js +20 -76
- package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +40 -0
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +120 -0
- package/lib/projects/localDev/LocalDevLogger.js +10 -11
- package/lib/projects/localDev/{LocalDevManager.js → LocalDevManager_DEPRECATED.js} +10 -11
- package/lib/projects/localDev/LocalDevProcess.js +3 -2
- package/lib/projects/localDev/LocalDevState.d.ts +3 -0
- package/lib/projects/localDev/LocalDevState.js +9 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +4 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +46 -16
- package/lib/projects/localDev/UIExtensionsDevModeInterface.d.ts +13 -0
- package/lib/projects/localDev/UIExtensionsDevModeInterface.js +37 -0
- package/lib/projects/localDev/helpers/account.d.ts +1 -1
- package/lib/projects/localDev/helpers/account.js +2 -2
- package/lib/projects/localDev/helpers/process.d.ts +1 -0
- package/lib/projects/localDev/helpers/process.js +15 -0
- package/lib/projects/localDev/helpers/project.d.ts +1 -0
- package/lib/projects/localDev/helpers/project.js +39 -3
- package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +3 -0
- package/lib/projects/localDev/localDevWebsocketServerUtils.js +9 -0
- package/lib/projects/platformVersion.d.ts +1 -1
- package/lib/projects/platformVersion.js +1 -1
- package/lib/projects/structure.d.ts +2 -2
- package/lib/projects/structure.js +6 -6
- package/lib/projects/upload.d.ts +2 -3
- package/lib/projects/upload.js +17 -9
- package/lib/projects/urls.d.ts +0 -1
- package/lib/projects/urls.js +0 -3
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +1 -0
- package/lib/prompts/__tests__/projectAddPrompt.test.js +10 -10
- package/lib/prompts/accountNamePrompt.js +14 -19
- package/lib/prompts/accountsPrompt.js +2 -2
- package/lib/prompts/cmsFieldPrompt.js +2 -2
- package/lib/prompts/createApiSamplePrompt.js +5 -5
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
- package/lib/prompts/createFunctionPrompt.js +14 -14
- package/lib/prompts/createModulePrompt.js +9 -9
- package/lib/prompts/createTemplatePrompt.js +2 -2
- package/lib/prompts/downloadProjectPrompt.js +5 -8
- package/lib/prompts/installAppPrompt.d.ts +1 -6
- package/lib/prompts/installAppPrompt.js +1 -6
- package/lib/prompts/personalAccessKeyPrompt.js +3 -3
- package/lib/prompts/previewPrompt.js +6 -6
- package/lib/prompts/projectAddPrompt.d.ts +2 -2
- package/lib/prompts/projectAddPrompt.js +7 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +20 -32
- package/lib/prompts/projectNamePrompt.js +4 -8
- package/lib/prompts/projectsLogsPrompt.js +2 -4
- package/lib/prompts/promptUtils.js +27 -9
- package/lib/prompts/sandboxesPrompt.js +7 -7
- package/lib/prompts/secretPrompt.js +3 -3
- package/lib/prompts/selectAppPrompt.js +3 -3
- package/lib/prompts/selectHubDBTablePrompt.js +9 -13
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +15 -19
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -8
- package/lib/prompts/uploadPrompt.js +5 -5
- package/lib/sandboxSync.js +24 -41
- package/lib/sandboxes.js +19 -47
- package/lib/schema.js +3 -3
- package/lib/serverlessLogs.js +11 -13
- package/lib/theme/__tests__/migrate.test.js +6 -6
- package/lib/theme/migrate.js +2 -2
- package/lib/ui/SpinniesManager.d.ts +2 -0
- package/lib/ui/SpinniesManager.js +7 -0
- package/lib/ui/boxen.js +1 -2
- package/lib/ui/git.js +13 -10
- package/lib/ui/index.d.ts +6 -0
- package/lib/ui/index.js +55 -38
- package/lib/ui/serverlessFunctionLogs.js +9 -7
- package/lib/ui/uiMessages.d.ts +73 -0
- package/lib/ui/uiMessages.js +76 -0
- package/lib/usageTracking.js +7 -7
- package/lib/validation.js +20 -23
- package/lib/yargsUtils.d.ts +1 -1
- package/lib/yargsUtils.js +12 -5
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +4 -4
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +23 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +68 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +11 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.js +49 -0
- package/mcp-server/tools/project/GetConfigValuesTool.js +2 -2
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +169 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +115 -0
- package/mcp-server/utils/toolUsageTracking.js +2 -2
- package/package.json +8 -7
- package/types/Cms.d.ts +6 -6
- package/types/Yargs.d.ts +1 -1
- package/commands/app/__tests__/install.test.js +0 -47
- package/commands/app/install.d.ts +0 -8
- package/commands/app/install.js +0 -122
- package/lib/middleware/__test__/utils.test.js +0 -51
- package/lib/middleware/utils.d.ts +0 -8
- package/lib/middleware/utils.js +0 -14
- package/lib/projects/localDev/DevServerManagerV2.d.ts +0 -22
- package/lib/projects/localDev/DevServerManagerV2.js +0 -81
- /package/commands/{customObject/schema → cms}/__tests__/delete.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/fetch.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/function.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/lint.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/list.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/mv.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/theme.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/function/__tests__}/logs.test.d.ts +0 -0
- /package/commands/{theme → cms/theme}/__tests__/generate-selectors.test.d.ts +0 -0
- /package/commands/{theme → cms/theme}/__tests__/generate-selectors.test.js +0 -0
- /package/commands/{theme → cms/theme}/__tests__/marketplace-validate.test.d.ts +0 -0
- /package/commands/{theme → cms/theme}/__tests__/preview.test.d.ts +0 -0
- /package/commands/{__tests__/remove.test.d.ts → customObject/__tests__/createSchema.test.d.ts} +0 -0
- /package/commands/{app/__tests__/install.test.d.ts → customObject/__tests__/deleteSchema.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/create.test.d.ts → __tests__/fetch-all-schemas.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/fetch-all.test.d.ts → __tests__/fetchSchema.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/fetch.test.d.ts → __tests__/listSchemas.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/list.test.d.ts → __tests__/updateSchema.test.d.ts} +0 -0
- /package/commands/{customObject/schema/__tests__/update.test.d.ts → project/__tests__/list.test.d.ts} +0 -0
- /package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
- /package/{commands/create → lib/cmsAssets}/api-sample.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/api-sample.js +0 -0
- /package/{commands/create → lib/cmsAssets}/app.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/app.js +0 -0
- /package/{commands/create → lib/cmsAssets}/function.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/function.js +0 -0
- /package/{commands/create → lib/cmsAssets}/index.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/index.js +0 -0
- /package/{commands/create → lib/cmsAssets}/module.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/module.js +0 -0
- /package/{commands/create → lib/cmsAssets}/react-app.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/react-app.js +0 -0
- /package/{commands/create → lib/cmsAssets}/template.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/template.js +0 -0
- /package/{commands/create → lib/cmsAssets}/vue-app.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/vue-app.js +0 -0
- /package/{commands/create → lib/cmsAssets}/webpack-serverless.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/webpack-serverless.js +0 -0
- /package/{commands/create → lib/cmsAssets}/website-theme.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/website-theme.js +0 -0
- /package/lib/{projects/add/__tests__/v3AddComponent.test.d.ts → middleware/__test__/commandTargetingUtils.test.d.ts} +0 -0
- /package/lib/projects/{create/__tests__/v3.test.d.ts → __tests__/DevServerManager.test.d.ts} +0 -0
- /package/lib/projects/localDev/{LocalDevManager.d.ts → LocalDevManager_DEPRECATED.d.ts} +0 -0
|
@@ -11,9 +11,7 @@ vi.mock('@hubspot/ui-extensions-dev-server', () => {
|
|
|
11
11
|
};
|
|
12
12
|
});
|
|
13
13
|
import { fetchAppInstallationData } from '@hubspot/local-dev-lib/api/localDevAuth';
|
|
14
|
-
import {
|
|
15
|
-
import { DevModeUnifiedInterface as UIEDevModeInterface } from '@hubspot/ui-extensions-dev-server';
|
|
16
|
-
import { requestPorts } from '@hubspot/local-dev-lib/portManager';
|
|
14
|
+
import { fetchAppMetadataByUid, fetchPublicAppProductionInstallCounts, installStaticAuthAppOnTestAccount, } from '@hubspot/local-dev-lib/api/appsDev';
|
|
17
15
|
import { getAccountConfig } from '@hubspot/local-dev-lib/config';
|
|
18
16
|
import AppDevModeInterface from '../localDev/AppDevModeInterface.js';
|
|
19
17
|
import LocalDevState from '../localDev/LocalDevState.js';
|
|
@@ -67,6 +65,8 @@ describe('AppDevModeInterface', () => {
|
|
|
67
65
|
componentRoot: '/test/path',
|
|
68
66
|
componentConfigPath: '/test/path/config.json',
|
|
69
67
|
configUpdatedSinceLastUpload: false,
|
|
68
|
+
removed: false,
|
|
69
|
+
parsingErrors: [],
|
|
70
70
|
},
|
|
71
71
|
componentDeps: {},
|
|
72
72
|
metaFilePath: '/test/path',
|
|
@@ -107,8 +107,8 @@ describe('AppDevModeInterface', () => {
|
|
|
107
107
|
LocalDevState.mockImplementation(() => mockLocalDevState);
|
|
108
108
|
LocalDevLogger.mockImplementation(() => mockLocalDevLogger);
|
|
109
109
|
// Mock external dependencies
|
|
110
|
-
|
|
111
|
-
data:
|
|
110
|
+
fetchAppMetadataByUid.mockResolvedValue({
|
|
111
|
+
data: mockPublicApp,
|
|
112
112
|
});
|
|
113
113
|
fetchPublicAppProductionInstallCounts.mockResolvedValue({
|
|
114
114
|
data: { uniquePortalInstallCount: 5 },
|
|
@@ -127,7 +127,16 @@ describe('AppDevModeInterface', () => {
|
|
|
127
127
|
getOauthAppInstallUrl.mockReturnValue('http://oauth-install-url');
|
|
128
128
|
getStaticAuthAppInstallUrl.mockReturnValue('http://static-install-url');
|
|
129
129
|
installAppAutoPrompt.mockResolvedValue(true);
|
|
130
|
-
installAppBrowserPrompt.
|
|
130
|
+
installAppBrowserPrompt.mockImplementation(async () => {
|
|
131
|
+
setTimeout(() => {
|
|
132
|
+
const addListenerCall = mockLocalDevState.addListener.mock.calls.find(call => call[0] === 'devServerMessage');
|
|
133
|
+
if (addListenerCall) {
|
|
134
|
+
const callback = addListenerCall[1];
|
|
135
|
+
callback(LOCAL_DEV_SERVER_MESSAGE_TYPES.STATIC_AUTH_APP_INSTALL_SUCCESS);
|
|
136
|
+
}
|
|
137
|
+
}, 0);
|
|
138
|
+
return undefined;
|
|
139
|
+
});
|
|
131
140
|
confirmPrompt.mockResolvedValue(true);
|
|
132
141
|
installStaticAuthAppOnTestAccount.mockResolvedValue(undefined);
|
|
133
142
|
// Mock process.exit
|
|
@@ -188,16 +197,14 @@ describe('AppDevModeInterface', () => {
|
|
|
188
197
|
});
|
|
189
198
|
it('should return early if no app node exists', async () => {
|
|
190
199
|
mockLocalDevState.projectNodes = {};
|
|
191
|
-
await appDevModeInterface.setup(
|
|
192
|
-
expect(
|
|
193
|
-
expect(UIEDevModeInterface.setup).not.toHaveBeenCalled();
|
|
200
|
+
await appDevModeInterface.setup();
|
|
201
|
+
expect(fetchAppMetadataByUid).not.toHaveBeenCalled();
|
|
194
202
|
});
|
|
195
203
|
it('should setup successfully with private app', async () => {
|
|
196
|
-
await appDevModeInterface.setup(
|
|
197
|
-
expect(
|
|
204
|
+
await appDevModeInterface.setup();
|
|
205
|
+
expect(fetchAppMetadataByUid).toHaveBeenCalledWith('test-app-uid', 12345);
|
|
198
206
|
expect(fetchPublicAppProductionInstallCounts).toHaveBeenCalledWith(123, 12345);
|
|
199
207
|
expect(fetchAppInstallationData).toHaveBeenCalledWith(67890, 999, 'test-app-uid', ['test-scope'], []);
|
|
200
|
-
expect(UIEDevModeInterface.setup).toHaveBeenCalled();
|
|
201
208
|
});
|
|
202
209
|
it('should show marketplace warning for marketplace apps', async () => {
|
|
203
210
|
const marketplaceAppNode = {
|
|
@@ -210,7 +217,7 @@ describe('AppDevModeInterface', () => {
|
|
|
210
217
|
mockLocalDevState.projectNodes = {
|
|
211
218
|
[marketplaceAppNode.uid]: marketplaceAppNode,
|
|
212
219
|
};
|
|
213
|
-
await appDevModeInterface.setup(
|
|
220
|
+
await appDevModeInterface.setup();
|
|
214
221
|
expect(confirmPrompt).toHaveBeenCalled();
|
|
215
222
|
expect(mockLocalDevState.addUploadWarning).toHaveBeenCalled();
|
|
216
223
|
});
|
|
@@ -237,24 +244,19 @@ describe('AppDevModeInterface', () => {
|
|
|
237
244
|
localDevLogger: mockLocalDevLogger,
|
|
238
245
|
});
|
|
239
246
|
// The setup method catches the error, so we check that process.exit was called
|
|
240
|
-
await newAppDevModeInterface.setup(
|
|
247
|
+
await newAppDevModeInterface.setup();
|
|
241
248
|
expect(process.exit).toHaveBeenCalledWith(0);
|
|
242
249
|
});
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
// 123,
|
|
254
|
-
// 67890,
|
|
255
|
-
// [1, 2, 3]
|
|
256
|
-
// );
|
|
257
|
-
// });
|
|
250
|
+
it('should auto-install static auth app on test account', async () => {
|
|
251
|
+
fetchAppInstallationData.mockResolvedValue({
|
|
252
|
+
data: {
|
|
253
|
+
isInstalledWithScopeGroups: false,
|
|
254
|
+
previouslyAuthorizedScopeGroups: [],
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
await appDevModeInterface.setup();
|
|
258
|
+
expect(installStaticAuthAppOnTestAccount).toHaveBeenCalledWith(123, 67890, [1, 2, 3]);
|
|
259
|
+
});
|
|
258
260
|
it('should open browser for OAuth app installation', async () => {
|
|
259
261
|
const oauthAppNode = {
|
|
260
262
|
...mockAppNode,
|
|
@@ -273,7 +275,7 @@ describe('AppDevModeInterface', () => {
|
|
|
273
275
|
previouslyAuthorizedScopeGroups: [],
|
|
274
276
|
},
|
|
275
277
|
});
|
|
276
|
-
await appDevModeInterface.setup(
|
|
278
|
+
await appDevModeInterface.setup();
|
|
277
279
|
expect(getOauthAppInstallUrl).toHaveBeenCalledWith({
|
|
278
280
|
targetAccountId: 67890,
|
|
279
281
|
env: ENVIRONMENTS.PROD,
|
|
@@ -292,119 +294,58 @@ describe('AppDevModeInterface', () => {
|
|
|
292
294
|
previouslyAuthorizedScopeGroups: ['old-scope'],
|
|
293
295
|
},
|
|
294
296
|
});
|
|
295
|
-
await appDevModeInterface.setup(
|
|
296
|
-
expect(installAppBrowserPrompt).toHaveBeenCalledWith('http://static-install-url', true
|
|
297
|
-
appUid: 'test-app-uid',
|
|
298
|
-
projectAccountId: 12345,
|
|
299
|
-
projectName: 'test-project',
|
|
300
|
-
testingAccountId: 67890,
|
|
301
|
-
});
|
|
297
|
+
await appDevModeInterface.setup();
|
|
298
|
+
expect(installAppBrowserPrompt).toHaveBeenCalledWith('http://static-install-url', true);
|
|
302
299
|
});
|
|
303
300
|
it('should handle errors during setup', async () => {
|
|
304
301
|
const error = new Error('Setup failed');
|
|
305
|
-
|
|
306
|
-
await appDevModeInterface.setup(
|
|
302
|
+
fetchAppMetadataByUid.mockRejectedValue(error);
|
|
303
|
+
await appDevModeInterface.setup();
|
|
307
304
|
expect(logError).toHaveBeenCalledWith(error);
|
|
308
305
|
});
|
|
309
|
-
it('should exit if
|
|
310
|
-
// Set up conditions for
|
|
311
|
-
getAccountConfig.mockReturnValue(
|
|
312
|
-
|
|
313
|
-
fetchPublicAppsForPortal
|
|
314
|
-
.mockResolvedValueOnce({
|
|
315
|
-
data: { results: [mockPublicApp] },
|
|
316
|
-
})
|
|
317
|
-
// Second call for getAppInstallUrl fails (app not found)
|
|
318
|
-
.mockResolvedValueOnce({
|
|
319
|
-
data: { results: [] },
|
|
306
|
+
it('should exit if user declines auto-install', async () => {
|
|
307
|
+
// Set up conditions for automatic installation
|
|
308
|
+
getAccountConfig.mockReturnValue({
|
|
309
|
+
parentAccountId: 12345, // matches targetProjectAccountId
|
|
320
310
|
});
|
|
311
|
+
isDeveloperTestAccount.mockReturnValue(true);
|
|
321
312
|
fetchAppInstallationData.mockResolvedValue({
|
|
322
313
|
data: {
|
|
323
314
|
isInstalledWithScopeGroups: false,
|
|
324
315
|
previouslyAuthorizedScopeGroups: [],
|
|
325
316
|
},
|
|
326
317
|
});
|
|
318
|
+
installAppAutoPrompt.mockResolvedValue(false);
|
|
319
|
+
// Create a new instance to trigger the exit during setup
|
|
320
|
+
const newAppDevModeInterface = new AppDevModeInterface({
|
|
321
|
+
localDevState: mockLocalDevState,
|
|
322
|
+
localDevLogger: mockLocalDevLogger,
|
|
323
|
+
});
|
|
327
324
|
// The setup method catches the error, so we check that process.exit was called
|
|
328
|
-
await
|
|
329
|
-
expect(process.exit).toHaveBeenCalledWith(
|
|
330
|
-
});
|
|
331
|
-
// @TODO: Restore test account auto install functionality
|
|
332
|
-
// it('should exit if user declines auto-install', async () => {
|
|
333
|
-
// // Set up conditions for automatic installation
|
|
334
|
-
// (getAccountConfig as Mock).mockReturnValue({
|
|
335
|
-
// parentAccountId: 12345, // matches targetProjectAccountId
|
|
336
|
-
// });
|
|
337
|
-
// (isDeveloperTestAccount as Mock).mockReturnValue(true);
|
|
338
|
-
// (fetchAppInstallationData as Mock).mockResolvedValue({
|
|
339
|
-
// data: {
|
|
340
|
-
// isInstalledWithScopeGroups: false,
|
|
341
|
-
// previouslyAuthorizedScopeGroups: [],
|
|
342
|
-
// },
|
|
343
|
-
// });
|
|
344
|
-
// (installAppAutoPrompt as Mock).mockResolvedValue(false);
|
|
345
|
-
// // Create a new instance to trigger the exit during setup
|
|
346
|
-
// const newAppDevModeInterface = new AppDevModeInterface({
|
|
347
|
-
// localDevState: mockLocalDevState,
|
|
348
|
-
// localDevLogger: mockLocalDevLogger,
|
|
349
|
-
// });
|
|
350
|
-
// // The setup method catches the error, so we check that process.exit was called
|
|
351
|
-
// await newAppDevModeInterface.setup({});
|
|
352
|
-
// expect(process.exit).toHaveBeenCalledWith(0);
|
|
353
|
-
// });
|
|
354
|
-
// @TODO: Restore test account auto install functionality
|
|
355
|
-
// it('should fallback to browser install if auto-install fails', async () => {
|
|
356
|
-
// (fetchAppInstallationData as Mock).mockResolvedValue({
|
|
357
|
-
// data: {
|
|
358
|
-
// isInstalledWithScopeGroups: false,
|
|
359
|
-
// previouslyAuthorizedScopeGroups: [],
|
|
360
|
-
// },
|
|
361
|
-
// });
|
|
362
|
-
// (installStaticAuthAppOnTestAccount as Mock).mockRejectedValue(
|
|
363
|
-
// new Error('Install failed')
|
|
364
|
-
// );
|
|
365
|
-
// await appDevModeInterface.setup({});
|
|
366
|
-
// expect(installAppBrowserPrompt).toHaveBeenCalledWith(
|
|
367
|
-
// 'http://static-install-url',
|
|
368
|
-
// false
|
|
369
|
-
// );
|
|
370
|
-
// });
|
|
371
|
-
});
|
|
372
|
-
describe('start()', () => {
|
|
373
|
-
it('should return early if no app node exists', async () => {
|
|
374
|
-
mockLocalDevState.projectNodes = {};
|
|
375
|
-
await appDevModeInterface.start();
|
|
376
|
-
expect(UIEDevModeInterface.start).not.toHaveBeenCalled();
|
|
325
|
+
await newAppDevModeInterface.setup();
|
|
326
|
+
expect(process.exit).toHaveBeenCalledWith(0);
|
|
377
327
|
});
|
|
378
|
-
it('should
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
328
|
+
it('should fallback to browser install if auto-install fails', async () => {
|
|
329
|
+
fetchAppInstallationData.mockResolvedValue({
|
|
330
|
+
data: {
|
|
331
|
+
isInstalledWithScopeGroups: false,
|
|
332
|
+
previouslyAuthorizedScopeGroups: [],
|
|
333
|
+
},
|
|
384
334
|
});
|
|
335
|
+
installStaticAuthAppOnTestAccount.mockRejectedValue(new Error('Install failed'));
|
|
336
|
+
await appDevModeInterface.setup();
|
|
337
|
+
expect(installAppBrowserPrompt).toHaveBeenCalledWith('http://static-install-url', false);
|
|
385
338
|
});
|
|
386
339
|
});
|
|
387
|
-
describe('
|
|
388
|
-
it('should
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
expect
|
|
392
|
-
|
|
393
|
-
it('should forward file change to UIE dev mode interface', async () => {
|
|
394
|
-
await appDevModeInterface.fileChange('test.js', 'change');
|
|
395
|
-
expect(UIEDevModeInterface.fileChange).toHaveBeenCalledWith('test.js', 'change');
|
|
340
|
+
describe('start()', () => {
|
|
341
|
+
it('should add state listeners', async () => {
|
|
342
|
+
await appDevModeInterface.start();
|
|
343
|
+
expect(mockLocalDevState.addListener).toHaveBeenCalledWith('projectNodes',
|
|
344
|
+
// @ts-expect-error access private method for testing
|
|
345
|
+
appDevModeInterface.onChangeProjectNodes);
|
|
396
346
|
});
|
|
397
347
|
});
|
|
398
348
|
describe('cleanup()', () => {
|
|
399
|
-
it('should return early if no app node exists', async () => {
|
|
400
|
-
mockLocalDevState.projectNodes = {};
|
|
401
|
-
await appDevModeInterface.cleanup();
|
|
402
|
-
expect(UIEDevModeInterface.cleanup).not.toHaveBeenCalled();
|
|
403
|
-
});
|
|
404
|
-
it('should cleanup UIE dev mode interface', async () => {
|
|
405
|
-
await appDevModeInterface.cleanup();
|
|
406
|
-
expect(UIEDevModeInterface.cleanup).toHaveBeenCalled();
|
|
407
|
-
});
|
|
408
349
|
it('should remove state listeners', async () => {
|
|
409
350
|
await appDevModeInterface.cleanup();
|
|
410
351
|
expect(mockLocalDevState.removeListener).toHaveBeenCalledWith('devServerMessage',
|
|
@@ -424,14 +365,21 @@ describe('AppDevModeInterface', () => {
|
|
|
424
365
|
// Reset mocks to ensure clean state
|
|
425
366
|
vi.clearAllMocks();
|
|
426
367
|
// Set up basic mocks
|
|
427
|
-
|
|
428
|
-
data:
|
|
368
|
+
fetchAppMetadataByUid.mockResolvedValue({
|
|
369
|
+
data: mockPublicApp,
|
|
429
370
|
});
|
|
430
371
|
fetchPublicAppProductionInstallCounts.mockResolvedValue({
|
|
431
372
|
data: { uniquePortalInstallCount: 5 },
|
|
432
373
|
});
|
|
433
374
|
getStaticAuthAppInstallUrl.mockReturnValue('http://static-install-url');
|
|
434
|
-
installAppBrowserPrompt.
|
|
375
|
+
installAppBrowserPrompt.mockImplementation(async () => {
|
|
376
|
+
const addListenerCall = mockLocalDevState.addListener.mock.calls.find(call => call[0] === 'devServerMessage');
|
|
377
|
+
if (addListenerCall) {
|
|
378
|
+
const callback = addListenerCall[1];
|
|
379
|
+
callback(LOCAL_DEV_SERVER_MESSAGE_TYPES.STATIC_AUTH_APP_INSTALL_SUCCESS);
|
|
380
|
+
}
|
|
381
|
+
return undefined;
|
|
382
|
+
});
|
|
435
383
|
// Reset the mock LocalDevState
|
|
436
384
|
mockLocalDevState.getAppDataByUid = vi.fn().mockReturnValue(mockAppData);
|
|
437
385
|
mockLocalDevState.setAppDataForUid = vi.fn();
|
|
@@ -450,21 +398,30 @@ describe('AppDevModeInterface', () => {
|
|
|
450
398
|
localDevState: mockLocalDevState,
|
|
451
399
|
localDevLogger: mockLocalDevLogger,
|
|
452
400
|
});
|
|
453
|
-
await newAppDevModeInterface.setup(
|
|
401
|
+
await newAppDevModeInterface.setup();
|
|
454
402
|
expect(installAppBrowserPrompt).toHaveBeenCalled();
|
|
455
403
|
});
|
|
456
404
|
it('should return false for OAuth app', async () => {
|
|
457
405
|
// Reset mocks to ensure clean state
|
|
458
406
|
vi.clearAllMocks();
|
|
459
407
|
// Set up basic mocks
|
|
460
|
-
|
|
461
|
-
data:
|
|
408
|
+
fetchAppMetadataByUid.mockResolvedValue({
|
|
409
|
+
data: mockPublicApp,
|
|
462
410
|
});
|
|
463
411
|
fetchPublicAppProductionInstallCounts.mockResolvedValue({
|
|
464
412
|
data: { uniquePortalInstallCount: 5 },
|
|
465
413
|
});
|
|
466
414
|
getOauthAppInstallUrl.mockReturnValue('http://oauth-install-url');
|
|
467
|
-
installAppBrowserPrompt.
|
|
415
|
+
installAppBrowserPrompt.mockImplementation(async () => {
|
|
416
|
+
setTimeout(() => {
|
|
417
|
+
const addListenerCall = mockLocalDevState.addListener.mock.calls.find(call => call[0] === 'devServerMessage');
|
|
418
|
+
if (addListenerCall) {
|
|
419
|
+
const callback = addListenerCall[1];
|
|
420
|
+
callback(LOCAL_DEV_SERVER_MESSAGE_TYPES.STATIC_AUTH_APP_INSTALL_SUCCESS);
|
|
421
|
+
}
|
|
422
|
+
}, 0);
|
|
423
|
+
return undefined;
|
|
424
|
+
});
|
|
468
425
|
// Reset the mock LocalDevState
|
|
469
426
|
mockLocalDevState.getAppDataByUid = vi.fn().mockReturnValue(mockAppData);
|
|
470
427
|
mockLocalDevState.setAppDataForUid = vi.fn();
|
|
@@ -492,7 +449,7 @@ describe('AppDevModeInterface', () => {
|
|
|
492
449
|
localDevState: mockLocalDevState,
|
|
493
450
|
localDevLogger: mockLocalDevLogger,
|
|
494
451
|
});
|
|
495
|
-
await newAppDevModeInterface.setup(
|
|
452
|
+
await newAppDevModeInterface.setup();
|
|
496
453
|
expect(installAppBrowserPrompt).toHaveBeenCalled();
|
|
497
454
|
});
|
|
498
455
|
});
|
|
@@ -501,14 +458,23 @@ describe('AppDevModeInterface', () => {
|
|
|
501
458
|
// Reset mocks to ensure clean state
|
|
502
459
|
vi.clearAllMocks();
|
|
503
460
|
// Set up basic mocks
|
|
504
|
-
|
|
505
|
-
data:
|
|
461
|
+
fetchAppMetadataByUid.mockResolvedValue({
|
|
462
|
+
data: mockPublicApp,
|
|
506
463
|
});
|
|
507
464
|
fetchPublicAppProductionInstallCounts.mockResolvedValue({
|
|
508
465
|
data: { uniquePortalInstallCount: 5 },
|
|
509
466
|
});
|
|
510
467
|
getStaticAuthAppInstallUrl.mockReturnValue('http://static-install-url');
|
|
511
|
-
installAppBrowserPrompt.
|
|
468
|
+
installAppBrowserPrompt.mockImplementation(async () => {
|
|
469
|
+
setTimeout(() => {
|
|
470
|
+
const addListenerCall = mockLocalDevState.addListener.mock.calls.find(call => call[0] === 'devServerMessage');
|
|
471
|
+
if (addListenerCall) {
|
|
472
|
+
const callback = addListenerCall[1];
|
|
473
|
+
callback(LOCAL_DEV_SERVER_MESSAGE_TYPES.STATIC_AUTH_APP_INSTALL_SUCCESS);
|
|
474
|
+
}
|
|
475
|
+
}, 0);
|
|
476
|
+
return undefined;
|
|
477
|
+
});
|
|
512
478
|
// Reset the mock LocalDevState
|
|
513
479
|
mockLocalDevState.getAppDataByUid = vi.fn().mockReturnValue(mockAppData);
|
|
514
480
|
mockLocalDevState.setAppDataForUid = vi.fn();
|
|
@@ -525,7 +491,7 @@ describe('AppDevModeInterface', () => {
|
|
|
525
491
|
localDevState: mockLocalDevState,
|
|
526
492
|
localDevLogger: mockLocalDevLogger,
|
|
527
493
|
});
|
|
528
|
-
await newAppDevModeInterface.setup(
|
|
494
|
+
await newAppDevModeInterface.setup();
|
|
529
495
|
// Simulate websocket server connection
|
|
530
496
|
const addListenerCall = mockLocalDevState.addListener.mock
|
|
531
497
|
.calls[0];
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
+
import DevServerManager from '../localDev/DevServerManager.js';
|
|
3
|
+
import LocalDevState from '../localDev/LocalDevState.js';
|
|
4
|
+
import LocalDevLogger from '../localDev/LocalDevLogger.js';
|
|
5
|
+
import { ENVIRONMENTS } from '@hubspot/local-dev-lib/constants/environments';
|
|
6
|
+
vi.mock('@hubspot/ui-extensions-dev-server', () => ({
|
|
7
|
+
DevModeUnifiedInterface: {
|
|
8
|
+
setup: vi.fn().mockResolvedValue(undefined),
|
|
9
|
+
start: vi.fn().mockResolvedValue(undefined),
|
|
10
|
+
fileChange: vi.fn().mockResolvedValue(undefined),
|
|
11
|
+
cleanup: vi.fn().mockResolvedValue(undefined),
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
14
|
+
vi.mock('@hubspot/local-dev-lib/portManager', () => ({
|
|
15
|
+
requestPorts: vi.fn().mockResolvedValue({ 'test-port': 8080 }),
|
|
16
|
+
}));
|
|
17
|
+
vi.mock('@hubspot/local-dev-lib/api/localDevAuth', () => ({
|
|
18
|
+
fetchAppInstallationData: vi.fn().mockResolvedValue({}),
|
|
19
|
+
}));
|
|
20
|
+
vi.mock('@hubspot/local-dev-lib/api/appsDev', () => ({
|
|
21
|
+
fetchAppMetadataByUid: vi.fn().mockResolvedValue({}),
|
|
22
|
+
fetchPublicAppProductionInstallCounts: vi.fn().mockResolvedValue({}),
|
|
23
|
+
installStaticAuthAppOnTestAccount: vi.fn().mockResolvedValue({}),
|
|
24
|
+
}));
|
|
25
|
+
vi.mock('@hubspot/local-dev-lib/config', () => ({
|
|
26
|
+
getAccountConfig: vi.fn().mockReturnValue({ accountId: 123 }),
|
|
27
|
+
configFileExists: vi.fn().mockReturnValue(true),
|
|
28
|
+
getAccountId: vi.fn().mockReturnValue(123),
|
|
29
|
+
hasLocalStateFlag: vi.fn().mockReturnValue(false),
|
|
30
|
+
getConfigDefaultAccount: vi.fn().mockReturnValue({ accountId: 123 }),
|
|
31
|
+
}));
|
|
32
|
+
vi.mock('@hubspot/local-dev-lib/urls', () => ({
|
|
33
|
+
getHubSpotApiOrigin: vi.fn().mockReturnValue('https://api.hubspot.com'),
|
|
34
|
+
getHubSpotWebsiteOrigin: vi.fn().mockReturnValue('https://app.hubspot.com'),
|
|
35
|
+
}));
|
|
36
|
+
vi.mock('../../ui/SpinniesManager', () => ({
|
|
37
|
+
default: {
|
|
38
|
+
add: vi.fn(),
|
|
39
|
+
succeed: vi.fn(),
|
|
40
|
+
fail: vi.fn(),
|
|
41
|
+
init: vi.fn(),
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
describe('DevServerManager', () => {
|
|
45
|
+
let devServerManager;
|
|
46
|
+
let localDevState;
|
|
47
|
+
let logger;
|
|
48
|
+
beforeEach(() => {
|
|
49
|
+
localDevState = new LocalDevState({
|
|
50
|
+
targetProjectAccountId: 123,
|
|
51
|
+
targetTestingAccountId: 456,
|
|
52
|
+
projectConfig: {
|
|
53
|
+
name: 'test-project',
|
|
54
|
+
srcDir: 'src',
|
|
55
|
+
platformVersion: '1.0.0',
|
|
56
|
+
},
|
|
57
|
+
projectDir: '/test/project',
|
|
58
|
+
projectData: {
|
|
59
|
+
name: 'test-project',
|
|
60
|
+
id: 123,
|
|
61
|
+
createdAt: Date.now(),
|
|
62
|
+
deletedAt: 0,
|
|
63
|
+
isLocked: false,
|
|
64
|
+
portalId: 123,
|
|
65
|
+
updatedAt: Date.now(),
|
|
66
|
+
},
|
|
67
|
+
debug: false,
|
|
68
|
+
initialProjectNodes: {},
|
|
69
|
+
initialProjectProfileData: {},
|
|
70
|
+
profile: 'test',
|
|
71
|
+
env: ENVIRONMENTS.QA,
|
|
72
|
+
});
|
|
73
|
+
logger = new LocalDevLogger(localDevState);
|
|
74
|
+
devServerManager = new DevServerManager({
|
|
75
|
+
localDevState,
|
|
76
|
+
logger,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
describe('constructor', () => {
|
|
80
|
+
it('should initialize with correct state', async () => {
|
|
81
|
+
await expect(async () => {
|
|
82
|
+
await devServerManager.start();
|
|
83
|
+
}).rejects.toThrow('The Dev Server Manager must be initialized before it is started.');
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
describe('setup', () => {
|
|
87
|
+
it('should complete setup without errors', async () => {
|
|
88
|
+
await expect(devServerManager.setup()).resolves.not.toThrow();
|
|
89
|
+
});
|
|
90
|
+
it('should allow start after successful setup', async () => {
|
|
91
|
+
await devServerManager.setup();
|
|
92
|
+
await expect(devServerManager.start()).resolves.not.toThrow();
|
|
93
|
+
});
|
|
94
|
+
it('should call setup on dev servers sequentially', async () => {
|
|
95
|
+
const executionOrder = [];
|
|
96
|
+
const { DevModeUnifiedInterface } = await import('@hubspot/ui-extensions-dev-server');
|
|
97
|
+
const originalSetup = DevModeUnifiedInterface.setup;
|
|
98
|
+
DevModeUnifiedInterface.setup = vi.fn().mockImplementation(async () => {
|
|
99
|
+
executionOrder.push('UIExtensions-start');
|
|
100
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
101
|
+
executionOrder.push('UIExtensions-end');
|
|
102
|
+
});
|
|
103
|
+
const AppDevModeInterface = (await import('../localDev/AppDevModeInterface.js')).default;
|
|
104
|
+
const originalAppSetup = AppDevModeInterface.prototype.setup;
|
|
105
|
+
AppDevModeInterface.prototype.setup = vi
|
|
106
|
+
.fn()
|
|
107
|
+
.mockImplementation(async function () {
|
|
108
|
+
executionOrder.push('App-start');
|
|
109
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
110
|
+
executionOrder.push('App-end');
|
|
111
|
+
});
|
|
112
|
+
const testManager = new DevServerManager({
|
|
113
|
+
localDevState,
|
|
114
|
+
logger,
|
|
115
|
+
});
|
|
116
|
+
await testManager.setup();
|
|
117
|
+
expect(executionOrder).toEqual([
|
|
118
|
+
'App-start',
|
|
119
|
+
'App-end',
|
|
120
|
+
'UIExtensions-start',
|
|
121
|
+
'UIExtensions-end',
|
|
122
|
+
]);
|
|
123
|
+
expect(AppDevModeInterface.prototype.setup).toHaveBeenCalledTimes(1);
|
|
124
|
+
expect(DevModeUnifiedInterface.setup).toHaveBeenCalledTimes(1);
|
|
125
|
+
// Restore original methods
|
|
126
|
+
DevModeUnifiedInterface.setup = originalSetup;
|
|
127
|
+
AppDevModeInterface.prototype.setup = originalAppSetup;
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
describe('start', () => {
|
|
131
|
+
it('should throw error when not initialized', async () => {
|
|
132
|
+
await expect(devServerManager.start()).rejects.toThrow();
|
|
133
|
+
});
|
|
134
|
+
it('should start successfully after setup', async () => {
|
|
135
|
+
await devServerManager.setup();
|
|
136
|
+
await expect(devServerManager.start()).resolves.not.toThrow();
|
|
137
|
+
});
|
|
138
|
+
it('should set started state correctly', async () => {
|
|
139
|
+
await devServerManager.setup();
|
|
140
|
+
await devServerManager.start();
|
|
141
|
+
await expect(devServerManager.fileChange({ filePath: 'test.js', event: 'change' })).resolves.not.toThrow();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
describe('fileChange', () => {
|
|
145
|
+
it('should handle fileChange', async () => {
|
|
146
|
+
await devServerManager.setup();
|
|
147
|
+
await devServerManager.start();
|
|
148
|
+
await expect(devServerManager.fileChange({
|
|
149
|
+
filePath: 'src/test.js',
|
|
150
|
+
event: 'change',
|
|
151
|
+
})).resolves.not.toThrow();
|
|
152
|
+
});
|
|
153
|
+
it('should handle different file events', async () => {
|
|
154
|
+
await devServerManager.setup();
|
|
155
|
+
await devServerManager.start();
|
|
156
|
+
const testCases = [
|
|
157
|
+
{ filePath: 'src/component.js', event: 'add' },
|
|
158
|
+
{ filePath: 'src/style.css', event: 'change' },
|
|
159
|
+
{ filePath: 'src/config.json', event: 'unlink' },
|
|
160
|
+
];
|
|
161
|
+
for (const testCase of testCases) {
|
|
162
|
+
await expect(devServerManager.fileChange(testCase)).resolves.not.toThrow();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
it('should handle concurrent fileChange calls', async () => {
|
|
166
|
+
await devServerManager.setup();
|
|
167
|
+
await devServerManager.start();
|
|
168
|
+
const fileChanges = [
|
|
169
|
+
devServerManager.fileChange({ filePath: 'file1.js', event: 'change' }),
|
|
170
|
+
devServerManager.fileChange({ filePath: 'file2.js', event: 'add' }),
|
|
171
|
+
devServerManager.fileChange({ filePath: 'file3.js', event: 'unlink' }),
|
|
172
|
+
];
|
|
173
|
+
await expect(Promise.all(fileChanges)).resolves.not.toThrow();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
describe('cleanup', () => {
|
|
177
|
+
it('should handle cleanup', async () => {
|
|
178
|
+
await devServerManager.setup();
|
|
179
|
+
await devServerManager.start();
|
|
180
|
+
await expect(devServerManager.cleanup()).resolves.not.toThrow();
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -7,7 +7,7 @@ import { fetchProject } from '@hubspot/local-dev-lib/api/projects';
|
|
|
7
7
|
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
8
8
|
import LocalDevProcess from '../localDev/LocalDevProcess.js';
|
|
9
9
|
import LocalDevLogger from '../localDev/LocalDevLogger.js';
|
|
10
|
-
import
|
|
10
|
+
import DevServerManager from '../localDev/DevServerManager.js';
|
|
11
11
|
import { ENVIRONMENTS } from '@hubspot/local-dev-lib/constants/environments';
|
|
12
12
|
import { vi } from 'vitest';
|
|
13
13
|
// Mock @hubspot/ui-extensions-dev-server
|
|
@@ -27,7 +27,7 @@ vi.mock('../config');
|
|
|
27
27
|
vi.mock('@hubspot/local-dev-lib/api/projects');
|
|
28
28
|
vi.mock('@hubspot/local-dev-lib/errors/index');
|
|
29
29
|
vi.mock('../localDev/LocalDevLogger');
|
|
30
|
-
vi.mock('../localDev/
|
|
30
|
+
vi.mock('../localDev/DevServerManager');
|
|
31
31
|
// Tests for LocalDevProcess and LocalDevState
|
|
32
32
|
describe('LocalDevProcess', () => {
|
|
33
33
|
let mockLocalDevLogger;
|
|
@@ -67,6 +67,7 @@ describe('LocalDevProcess', () => {
|
|
|
67
67
|
subbuildStatuses: [],
|
|
68
68
|
uploadMessage: 'Build completed',
|
|
69
69
|
autoDeployId: 0,
|
|
70
|
+
platformVersion: '2025.2',
|
|
70
71
|
},
|
|
71
72
|
},
|
|
72
73
|
initialProjectNodes: {},
|
|
@@ -104,7 +105,7 @@ describe('LocalDevProcess', () => {
|
|
|
104
105
|
};
|
|
105
106
|
// Mock constructors
|
|
106
107
|
LocalDevLogger.mockImplementation(() => mockLocalDevLogger);
|
|
107
|
-
|
|
108
|
+
DevServerManager.mockImplementation(() => mockDevServerManager);
|
|
108
109
|
// Mock external functions
|
|
109
110
|
isHubSpotHttpError.mockReturnValue(false);
|
|
110
111
|
// Create process instance
|
|
@@ -398,7 +399,7 @@ describe('LocalDevProcess', () => {
|
|
|
398
399
|
expect(handleProjectDeploy).toHaveBeenCalledWith(123, // targetProjectAccountId
|
|
399
400
|
'test-project', // projectName
|
|
400
401
|
123, // buildId
|
|
401
|
-
true, //
|
|
402
|
+
true, // useV2Api
|
|
402
403
|
false // force
|
|
403
404
|
);
|
|
404
405
|
expect(mockLocalDevLogger.deploySuccess).toHaveBeenCalled();
|
|
@@ -426,7 +427,7 @@ describe('LocalDevProcess', () => {
|
|
|
426
427
|
expect(handleProjectDeploy).toHaveBeenCalledWith(123, // targetProjectAccountId
|
|
427
428
|
'test-project', // projectName
|
|
428
429
|
123, // buildId
|
|
429
|
-
true, //
|
|
430
|
+
true, // useV2Api
|
|
430
431
|
true // force
|
|
431
432
|
);
|
|
432
433
|
expect(result).toEqual({
|