@hubspot/cli 7.8.0-experimental.0 → 7.8.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 -27
- package/commands/__tests__/auth.test.js +5 -0
- package/commands/__tests__/doctor.test.js +16 -16
- package/commands/__tests__/getStarted.test.js +2 -2
- package/commands/__tests__/mcp.test.js +1 -1
- package/commands/__tests__/project.test.js +2 -3
- 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 -6
- package/commands/app/migrate.js +13 -19
- package/commands/app/secret/add.js +2 -1
- package/commands/app/secret/delete.js +2 -1
- package/commands/app/secret/list.js +2 -1
- package/commands/app/secret/update.js +2 -1
- package/commands/app/secret.js +2 -1
- package/commands/app.js +2 -2
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +17 -7
- package/commands/cms/convertFields.js +7 -9
- package/commands/cms/getReactModule.js +9 -14
- package/commands/cms/lighthouseScore.js +33 -36
- package/commands/cms.js +2 -2
- package/commands/completion.js +3 -3
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +64 -37
- package/commands/config.js +2 -2
- package/commands/create.js +2 -2
- package/commands/customObject/create.js +10 -12
- package/commands/customObject/schema/create.js +9 -11
- package/commands/customObject/schema/delete.js +16 -16
- package/commands/customObject/schema/fetch-all.js +12 -11
- package/commands/customObject/schema/fetch.js +15 -15
- package/commands/customObject/schema/list.js +4 -4
- package/commands/customObject/schema/update.js +13 -13
- package/commands/customObject/schema.js +2 -2
- package/commands/customObject.js +6 -7
- package/commands/doctor.js +8 -11
- package/commands/feedback.js +8 -13
- package/commands/fetch.js +8 -8
- package/commands/filemanager/fetch.js +7 -7
- package/commands/filemanager/upload.js +15 -34
- package/commands/filemanager.js +2 -2
- package/commands/function/deploy.js +11 -29
- package/commands/function/list.js +8 -8
- package/commands/function/server.js +9 -11
- package/commands/function.d.ts +1 -1
- package/commands/function.js +2 -2
- package/commands/getStarted.d.ts +1 -3
- package/commands/getStarted.js +68 -20
- 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.js +16 -16
- package/commands/list.js +8 -14
- package/commands/logs.js +14 -20
- package/commands/mcp/__tests__/setup.test.js +2 -2
- package/commands/mcp/setup.js +11 -2
- package/commands/mcp.js +3 -3
- package/commands/mv.js +6 -17
- package/commands/open.js +5 -5
- package/commands/project/__tests__/add.test.js +15 -13
- package/commands/project/__tests__/create.test.js +6 -6
- package/commands/project/__tests__/deploy.test.js +3 -7
- package/commands/project/__tests__/devUnifiedFlow.test.js +2 -4
- 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 -4
- package/commands/project/__tests__/migrate.test.js +7 -7
- package/commands/project/__tests__/migrateApp.test.js +3 -7
- package/commands/project/__tests__/profile.test.js +1 -1
- package/commands/project/__tests__/validate.test.js +98 -0
- package/commands/project/add.d.ts +2 -2
- package/commands/project/add.js +7 -10
- package/commands/project/cloneApp.js +14 -19
- package/commands/project/create.js +4 -11
- package/commands/project/deploy.js +5 -5
- package/commands/project/dev/deprecatedFlow.js +9 -18
- package/commands/project/dev/index.js +21 -18
- package/commands/project/dev/unifiedFlow.js +15 -8
- package/commands/project/download.js +15 -16
- package/commands/project/installDeps.d.ts +2 -2
- package/commands/project/installDeps.js +9 -9
- package/commands/project/list.d.ts +4 -0
- package/commands/project/list.js +62 -0
- package/commands/project/listBuilds.js +12 -21
- package/commands/project/logs.js +21 -24
- package/commands/project/migrate.js +33 -12
- package/commands/project/migrateApp.js +10 -17
- package/commands/project/open.js +6 -14
- package/commands/project/profile/add.js +3 -3
- package/commands/project/profile/delete.js +1 -2
- package/commands/project/profile.js +2 -3
- package/commands/project/upload.js +16 -25
- package/commands/project/validate.js +7 -7
- package/commands/project/watch.js +13 -22
- package/commands/project.js +4 -3
- package/commands/sandbox/__tests__/create.test.js +5 -5
- package/commands/sandbox/create.js +22 -32
- package/commands/sandbox/delete.js +39 -64
- 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 -2
- package/commands/testAccount/delete.d.ts +4 -3
- package/commands/testAccount/delete.js +155 -14
- package/commands/testAccount/importData.d.ts +1 -1
- package/commands/testAccount/importData.js +1 -1
- package/commands/testAccount.js +1 -1
- package/commands/theme/preview.js +1 -4
- package/lang/en.d.ts +365 -111
- package/lang/en.js +409 -158
- 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__/hasFeature.test.js +145 -7
- 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 +19 -56
- package/lib/app/__tests__/migrate_legacy.test.js +1 -1
- package/lib/app/migrate.d.ts +2 -8
- package/lib/app/migrate.js +6 -81
- 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 +22 -1
- package/lib/constants.js +26 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +9 -36
- 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/hasFeature.js +6 -0
- package/lib/lang.js +6 -5
- package/lib/links.d.ts +1 -0
- package/lib/links.js +14 -7
- package/lib/mcp/setup.js +1 -1
- 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/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/fireAlarmMiddleware.js +15 -5
- 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/projects/__tests__/AppDevModeInterface.test.js +87 -90
- package/lib/projects/__tests__/LocalDevProcess.test.js +231 -19
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +89 -63
- package/lib/projects/__tests__/deploy.test.js +73 -8
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +6 -2
- 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} +82 -7
- 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} +16 -13
- package/lib/projects/deploy.d.ts +1 -1
- package/lib/projects/deploy.js +2 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +10 -1
- package/lib/projects/localDev/AppDevModeInterface.js +118 -89
- package/lib/projects/localDev/DevServerManager.d.ts +11 -29
- package/lib/projects/localDev/DevServerManager.js +19 -61
- package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +40 -0
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +120 -0
- package/lib/projects/localDev/LocalDevLogger.d.ts +4 -0
- package/lib/projects/localDev/LocalDevLogger.js +27 -6
- package/lib/projects/localDev/{LocalDevManager.js → LocalDevManager_DEPRECATED.js} +10 -11
- package/lib/projects/localDev/LocalDevProcess.d.ts +7 -5
- package/lib/projects/localDev/LocalDevProcess.js +93 -21
- package/lib/projects/localDev/LocalDevState.d.ts +12 -8
- package/lib/projects/localDev/LocalDevState.js +27 -17
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +6 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +94 -33
- package/lib/projects/localDev/helpers/account.d.ts +1 -1
- package/lib/projects/localDev/helpers/account.js +2 -2
- package/lib/projects/localDev/helpers/project.d.ts +3 -2
- package/lib/projects/localDev/helpers/project.js +49 -10
- package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +7 -0
- package/lib/projects/localDev/localDevWebsocketServerUtils.js +19 -0
- package/lib/projects/platformVersion.d.ts +1 -1
- package/lib/projects/platformVersion.js +1 -1
- package/lib/projects/pollProjectBuildAndDeploy.js +4 -4
- package/lib/projects/structure.js +6 -6
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +17 -8
- 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 +9 -2
- 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 +30 -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/selectProjectTemplatePrompt.js +2 -0
- 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.d.ts +1 -0
- package/lib/theme/__tests__/migrate.test.js +233 -0
- package/lib/theme/migrate.d.ts +13 -0
- package/lib/theme/migrate.js +90 -0
- package/lib/ui/SpinniesManager.d.ts +2 -0
- package/lib/ui/SpinniesManager.js +112 -8
- package/lib/ui/boxen.js +1 -2
- package/lib/ui/git.js +13 -10
- package/lib/ui/index.d.ts +4 -0
- package/lib/ui/index.js +47 -38
- package/lib/ui/serverlessFunctionLogs.js +9 -7
- package/lib/ui/uiMessages.d.ts +72 -0
- package/lib/ui/uiMessages.js +75 -0
- package/lib/usageTracking.js +8 -8
- package/lib/validation.js +20 -23
- package/lib/yargsUtils.d.ts +1 -1
- package/lib/yargsUtils.js +12 -5
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +1 -1
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/cms/HsCreateModuleTool.js +1 -1
- package/mcp-server/tools/cms/HsCreateTemplateTool.js +1 -1
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +2 -2
- package/mcp-server/tools/cms/HsListFunctionsTool.js +1 -1
- package/mcp-server/tools/cms/HsListTool.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.js +2 -2
- package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsListTool.test.js +1 -1
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +3 -3
- package/mcp-server/tools/project/AddFeatureToProjectTool.js +3 -3
- package/mcp-server/tools/project/CreateProjectTool.d.ts +3 -3
- package/mcp-server/tools/project/CreateProjectTool.js +5 -5
- package/mcp-server/tools/project/DeployProjectTool.js +1 -1
- package/mcp-server/tools/project/DocFetchTool.js +2 -2
- package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
- package/mcp-server/tools/project/DocsSearchTool.js +7 -7
- 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.d.ts +4 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +13 -7
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +1 -1
- package/mcp-server/tools/project/UploadProjectTools.js +2 -2
- package/mcp-server/tools/project/ValidateProjectTool.js +1 -1
- package/mcp-server/tools/project/__tests__/AddFeatureToProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +2 -2
- package/mcp-server/tools/project/__tests__/DeployProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +2 -2
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +14 -12
- 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/tools/project/__tests__/GetConfigValuesTool.test.js +9 -8
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +1 -1
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +1 -1
- package/mcp-server/tools/project/constants.d.ts +1 -1
- package/mcp-server/tools/project/constants.js +9 -3
- package/mcp-server/utils/__tests__/cliConfig.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/cliConfig.test.js +110 -0
- package/mcp-server/utils/cliConfig.d.ts +1 -0
- package/mcp-server/utils/cliConfig.js +12 -0
- package/mcp-server/utils/toolUsageTracking.js +2 -2
- package/package.json +8 -12
- package/types/LocalDev.d.ts +19 -3
- package/ui/components/HorizontalSelectPrompt.js +1 -1
- package/ui/index.js +1 -1
- package/commands/getStartedV2.d.ts +0 -9
- package/commands/getStartedV2.js +0 -39
- 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/ui/components/Ascii.d.ts +0 -10
- package/ui/components/Ascii.js +0 -11
- package/ui/views/GetStarted.d.ts +0 -7
- package/ui/views/GetStarted.js +0 -157
- /package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/list.test.d.ts} +0 -0
- /package/{lib/projects/add/__tests__/v3AddComponent.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
- /package/lib/{projects/create/__tests__/v3.test.d.ts → middleware/__test__/commandTargetingUtils.test.d.ts} +0 -0
- /package/lib/projects/localDev/{LocalDevManager.d.ts → LocalDevManager_DEPRECATED.d.ts} +0 -0
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { fetchAppInstallationData } from '@hubspot/local-dev-lib/api/localDevAuth';
|
|
2
|
-
import {
|
|
3
|
-
// installStaticAuthAppOnTestAccount,
|
|
4
|
-
} from '@hubspot/local-dev-lib/api/appsDev';
|
|
2
|
+
import { fetchAppMetadataByUid, fetchPublicAppProductionInstallCounts, installStaticAuthAppOnTestAccount, } from '@hubspot/local-dev-lib/api/appsDev';
|
|
5
3
|
import { DevModeUnifiedInterface as UIEDevModeInterface } from '@hubspot/ui-extensions-dev-server';
|
|
6
4
|
import { requestPorts } from '@hubspot/local-dev-lib/portManager';
|
|
5
|
+
import { getAccountConfig } from '@hubspot/local-dev-lib/config';
|
|
7
6
|
import { APP_AUTH_TYPES, APP_DISTRIBUTION_TYPES, APP_INSTALLATION_STATES, LOCAL_DEV_SERVER_MESSAGE_TYPES, } from '../../constants.js';
|
|
8
7
|
import { EXIT_CODES } from '../../enums/exitCodes.js';
|
|
9
8
|
import { isAppIRNode } from '../../projects/structure.js';
|
|
10
9
|
import { uiLine } from '../../ui/index.js';
|
|
11
10
|
import { logError } from '../../errorHandlers/index.js';
|
|
12
|
-
import {
|
|
13
|
-
// installAppAutoPrompt,
|
|
14
|
-
installAppBrowserPrompt, } from '../../prompts/installAppPrompt.js';
|
|
11
|
+
import { installAppAutoPrompt, installAppBrowserPrompt, } from '../../prompts/installAppPrompt.js';
|
|
15
12
|
import { confirmPrompt } from '../../prompts/promptUtils.js';
|
|
16
13
|
import { lib } from '../../../lang/en.js';
|
|
17
14
|
import { uiLogger } from '../../ui/logger.js';
|
|
18
15
|
import { getOauthAppInstallUrl, getStaticAuthAppInstallUrl, } from '../../app/urls.js';
|
|
16
|
+
import { isDeveloperTestAccount, isSandbox } from '../../accountTypes.js';
|
|
19
17
|
import SpinniesManager from '../../ui/SpinniesManager.js';
|
|
20
18
|
class AppDevModeInterface {
|
|
21
19
|
localDevState;
|
|
22
20
|
localDevLogger;
|
|
23
21
|
_appNode;
|
|
24
22
|
marketplaceAppInstalls;
|
|
23
|
+
appInstallResolve;
|
|
25
24
|
constructor(options) {
|
|
26
25
|
this.localDevState = options.localDevState;
|
|
27
26
|
this.localDevLogger = options.localDevLogger;
|
|
@@ -54,28 +53,25 @@ class AppDevModeInterface {
|
|
|
54
53
|
}
|
|
55
54
|
this.localDevState.setAppDataForUid(this.appNode.uid, appData);
|
|
56
55
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// this.appNode?.config.auth.type === APP_AUTH_TYPES.STATIC
|
|
75
|
-
// );
|
|
76
|
-
// }
|
|
56
|
+
isStaticAuthApp() {
|
|
57
|
+
return (this.appNode?.config.auth.type.toLowerCase() === APP_AUTH_TYPES.STATIC);
|
|
58
|
+
}
|
|
59
|
+
isOAuthApp() {
|
|
60
|
+
return (this.appNode?.config.auth.type.toLowerCase() === APP_AUTH_TYPES.OAUTH);
|
|
61
|
+
}
|
|
62
|
+
isAutomaticallyInstallable() {
|
|
63
|
+
const targetTestingAccount = getAccountConfig(this.localDevState.targetTestingAccountId);
|
|
64
|
+
if (!targetTestingAccount) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const isTestAccount = isDeveloperTestAccount(targetTestingAccount) ||
|
|
68
|
+
isSandbox(targetTestingAccount);
|
|
69
|
+
const hasCorrectParent = targetTestingAccount.parentAccountId ===
|
|
70
|
+
this.localDevState.targetProjectAccountId;
|
|
71
|
+
return isTestAccount && hasCorrectParent && this.isStaticAuthApp();
|
|
72
|
+
}
|
|
77
73
|
async getAppInstallUrl() {
|
|
78
|
-
if (this.appNode
|
|
74
|
+
if (this.appNode && this.isOAuthApp()) {
|
|
79
75
|
return getOauthAppInstallUrl({
|
|
80
76
|
targetAccountId: this.localDevState.targetTestingAccountId,
|
|
81
77
|
env: this.localDevState.env,
|
|
@@ -84,26 +80,20 @@ class AppDevModeInterface {
|
|
|
84
80
|
redirectUrls: this.appNode.config.auth.redirectUrls,
|
|
85
81
|
});
|
|
86
82
|
}
|
|
87
|
-
const { data: { results }, } = await fetchPublicAppsForPortal(this.localDevState.targetProjectAccountId);
|
|
88
|
-
const app = results.find(app => app.sourceId === this.appNode?.uid);
|
|
89
|
-
if (!app) {
|
|
90
|
-
uiLogger.error(lib.LocalDevManager.appNotFound(this.localDevState.targetProjectAccountId, this.appNode?.uid));
|
|
91
|
-
process.exit(EXIT_CODES.ERROR);
|
|
92
|
-
}
|
|
93
83
|
return getStaticAuthAppInstallUrl({
|
|
94
84
|
targetAccountId: this.localDevState.targetTestingAccountId,
|
|
95
85
|
env: this.localDevState.env,
|
|
96
|
-
appId:
|
|
86
|
+
appId: this.appData.id,
|
|
97
87
|
});
|
|
98
88
|
}
|
|
99
89
|
async fetchAppData() {
|
|
100
90
|
SpinniesManager.add('fetchAppData', {
|
|
101
91
|
text: lib.AppDevModeInterface.fetchAppData.checking(this.appNode?.config.name || ''),
|
|
102
92
|
});
|
|
103
|
-
let
|
|
93
|
+
let appData;
|
|
104
94
|
try {
|
|
105
|
-
const { data
|
|
106
|
-
|
|
95
|
+
const { data } = await fetchAppMetadataByUid(this.appNode.uid, this.localDevState.targetProjectAccountId);
|
|
96
|
+
appData = data;
|
|
107
97
|
}
|
|
108
98
|
catch (e) {
|
|
109
99
|
SpinniesManager.fail('fetchAppData', {
|
|
@@ -112,7 +102,6 @@ class AppDevModeInterface {
|
|
|
112
102
|
logError(e);
|
|
113
103
|
process.exit(EXIT_CODES.ERROR);
|
|
114
104
|
}
|
|
115
|
-
const appData = portalApps.find(({ sourceId }) => sourceId === this.appNode?.uid);
|
|
116
105
|
if (!appData) {
|
|
117
106
|
return;
|
|
118
107
|
}
|
|
@@ -121,7 +110,7 @@ class AppDevModeInterface {
|
|
|
121
110
|
id: appData.id,
|
|
122
111
|
clientId: appData.clientId,
|
|
123
112
|
name: appData.name,
|
|
124
|
-
installationState: APP_INSTALLATION_STATES.
|
|
113
|
+
installationState: APP_INSTALLATION_STATES.UNKNOWN,
|
|
125
114
|
scopeGroupIds: appData.scopeGroupIds,
|
|
126
115
|
};
|
|
127
116
|
this.marketplaceAppInstalls = uniquePortalInstallCount;
|
|
@@ -143,47 +132,55 @@ class AppDevModeInterface {
|
|
|
143
132
|
}
|
|
144
133
|
this.localDevState.addUploadWarning(lib.AppDevModeInterface.defaultMarketplaceAppWarning(this.marketplaceAppInstalls));
|
|
145
134
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
135
|
+
async waitUntilAppIsInstalled(installUrl) {
|
|
136
|
+
uiLogger.log(lib.AppDevModeInterface.waitUntilAppIsInstalled.link(installUrl));
|
|
137
|
+
SpinniesManager.add('waitUntilAppIsInstalled', {
|
|
138
|
+
text: lib.AppDevModeInterface.waitUntilAppIsInstalled.waiting,
|
|
139
|
+
});
|
|
140
|
+
await new Promise(resolve => {
|
|
141
|
+
this.appInstallResolve = resolve;
|
|
142
|
+
});
|
|
143
|
+
SpinniesManager.succeed('waitUntilAppIsInstalled', {
|
|
144
|
+
text: lib.AppDevModeInterface.waitUntilAppIsInstalled.success(this.appNode?.config.name || '', this.localDevState.targetTestingAccountId),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
async autoInstallStaticAuthApp() {
|
|
148
|
+
const shouldInstall = await installAppAutoPrompt();
|
|
149
|
+
if (!shouldInstall) {
|
|
150
|
+
uiLogger.log(lib.AppDevModeInterface.autoInstallDeclined);
|
|
151
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
152
|
+
}
|
|
153
|
+
uiLogger.log('');
|
|
154
|
+
SpinniesManager.add('autoInstallStaticAuthApp', {
|
|
155
|
+
text: lib.AppDevModeInterface.autoInstallStaticAuthApp.installing(this.appData.name, this.localDevState.targetTestingAccountId),
|
|
156
|
+
});
|
|
157
|
+
try {
|
|
158
|
+
await installStaticAuthAppOnTestAccount(this.appData.id, this.localDevState.targetTestingAccountId, this.appData.scopeGroupIds);
|
|
159
|
+
SpinniesManager.succeed('autoInstallStaticAuthApp', {
|
|
160
|
+
text: lib.AppDevModeInterface.autoInstallStaticAuthApp.success(this.appData.name, this.localDevState.targetTestingAccountId),
|
|
161
|
+
});
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
SpinniesManager.fail('autoInstallStaticAuthApp', {
|
|
166
|
+
text: lib.AppDevModeInterface.autoInstallStaticAuthApp.error(this.appData.name, this.localDevState.targetTestingAccountId),
|
|
167
|
+
failColor: 'white',
|
|
168
|
+
});
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
159
172
|
async installAppOrOpenInstallUrl(isReinstall) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// this.appData!.name,
|
|
167
|
-
// this.localDevState.targetTestingAccountId
|
|
168
|
-
// )
|
|
169
|
-
// );
|
|
170
|
-
// return;
|
|
171
|
-
// } catch (e) {
|
|
172
|
-
// uiLogger.error(
|
|
173
|
-
// lib.AppDevModeInterface.autoInstallError(
|
|
174
|
-
// this.appData!.name,
|
|
175
|
-
// this.localDevState.targetTestingAccountId
|
|
176
|
-
// )
|
|
177
|
-
// );
|
|
178
|
-
// }
|
|
179
|
-
// }
|
|
173
|
+
if (this.isAutomaticallyInstallable()) {
|
|
174
|
+
const installSuccess = await this.autoInstallStaticAuthApp();
|
|
175
|
+
if (installSuccess) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
180
179
|
const installUrl = await this.getAppInstallUrl();
|
|
181
|
-
await installAppBrowserPrompt(installUrl, isReinstall
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
appUid: this.appNode.uid,
|
|
186
|
-
});
|
|
180
|
+
await installAppBrowserPrompt(installUrl, isReinstall);
|
|
181
|
+
if (!isReinstall) {
|
|
182
|
+
await this.waitUntilAppIsInstalled(installUrl);
|
|
183
|
+
}
|
|
187
184
|
}
|
|
188
185
|
async checkTestAccountAppInstallation() {
|
|
189
186
|
if (!this.appNode || !this.appData) {
|
|
@@ -203,11 +200,46 @@ class AppDevModeInterface {
|
|
|
203
200
|
installationState: APP_INSTALLATION_STATES.INSTALLED_WITH_OUTDATED_SCOPES,
|
|
204
201
|
};
|
|
205
202
|
}
|
|
203
|
+
else {
|
|
204
|
+
this.appData = {
|
|
205
|
+
...this.appData,
|
|
206
|
+
installationState: APP_INSTALLATION_STATES.NOT_INSTALLED,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
206
209
|
return { needsInstall: !isInstalledWithScopeGroups, isReinstall };
|
|
207
210
|
}
|
|
208
|
-
|
|
211
|
+
resolveAppInstallPromise() {
|
|
212
|
+
if (this.appInstallResolve) {
|
|
213
|
+
this.appInstallResolve();
|
|
214
|
+
this.appInstallResolve = undefined;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
handleAppInstallSuccessDevServerMessage() {
|
|
218
|
+
this.resolveAppInstallPromise();
|
|
219
|
+
this.appData = {
|
|
220
|
+
...this.appData,
|
|
221
|
+
installationState: APP_INSTALLATION_STATES.INSTALLED,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
handleAppInstallInitiatedDevServerMessage() {
|
|
225
|
+
this.resolveAppInstallPromise();
|
|
226
|
+
}
|
|
227
|
+
handleAppInstallFailureDevServerMessage() {
|
|
228
|
+
uiLogger.error(lib.AppDevModeInterface.installationFailed);
|
|
229
|
+
process.exit(EXIT_CODES.ERROR);
|
|
230
|
+
}
|
|
231
|
+
onDevServerMessage = async (message) => {
|
|
209
232
|
if (message === LOCAL_DEV_SERVER_MESSAGE_TYPES.WEBSOCKET_SERVER_CONNECTED) {
|
|
210
|
-
this.checkTestAccountAppInstallation();
|
|
233
|
+
await this.checkTestAccountAppInstallation();
|
|
234
|
+
}
|
|
235
|
+
else if (message === LOCAL_DEV_SERVER_MESSAGE_TYPES.STATIC_AUTH_APP_INSTALL_SUCCESS) {
|
|
236
|
+
this.handleAppInstallSuccessDevServerMessage();
|
|
237
|
+
}
|
|
238
|
+
else if (message === LOCAL_DEV_SERVER_MESSAGE_TYPES.STATIC_AUTH_APP_INSTALL_FAILURE) {
|
|
239
|
+
this.handleAppInstallFailureDevServerMessage();
|
|
240
|
+
}
|
|
241
|
+
else if (message === LOCAL_DEV_SERVER_MESSAGE_TYPES.OAUTH_APP_INSTALL_INITIATED) {
|
|
242
|
+
this.handleAppInstallInitiatedDevServerMessage();
|
|
211
243
|
}
|
|
212
244
|
};
|
|
213
245
|
onChangeProjectNodes = (nodes) => {
|
|
@@ -216,19 +248,15 @@ class AppDevModeInterface {
|
|
|
216
248
|
const newDistribution = newAppNode?.config.distribution;
|
|
217
249
|
const oldAuthType = this.appNode?.config.auth.type;
|
|
218
250
|
const newAuthType = newAppNode?.config.auth.type;
|
|
219
|
-
if (newDistribution === APP_DISTRIBUTION_TYPES.MARKETPLACE &&
|
|
220
|
-
oldDistribution !== APP_DISTRIBUTION_TYPES.MARKETPLACE) {
|
|
251
|
+
if (newDistribution?.toLowerCase() === APP_DISTRIBUTION_TYPES.MARKETPLACE &&
|
|
252
|
+
oldDistribution?.toLowerCase() !== APP_DISTRIBUTION_TYPES.MARKETPLACE) {
|
|
221
253
|
this.localDevState.addUploadWarning(lib.AppDevModeInterface.distributionChanged);
|
|
222
254
|
}
|
|
223
|
-
else if (newAuthType === APP_AUTH_TYPES.OAUTH &&
|
|
224
|
-
oldAuthType !== APP_AUTH_TYPES.OAUTH) {
|
|
255
|
+
else if (newAuthType?.toLowerCase() === APP_AUTH_TYPES.OAUTH &&
|
|
256
|
+
oldAuthType?.toLowerCase() !== APP_AUTH_TYPES.OAUTH) {
|
|
225
257
|
this.localDevState.addUploadWarning(lib.AppDevModeInterface.authTypeChanged);
|
|
226
258
|
}
|
|
227
259
|
};
|
|
228
|
-
setUpStateListeners() {
|
|
229
|
-
this.localDevState.addListener('devServerMessage', this.onDevServerMessage);
|
|
230
|
-
this.localDevState.addListener('projectNodes', this.onChangeProjectNodes);
|
|
231
|
-
}
|
|
232
260
|
removeStateListeners() {
|
|
233
261
|
this.localDevState.removeListener('devServerMessage', this.onDevServerMessage);
|
|
234
262
|
this.localDevState.removeListener('projectNodes', this.onChangeProjectNodes);
|
|
@@ -252,6 +280,7 @@ class AppDevModeInterface {
|
|
|
252
280
|
failColor: 'white',
|
|
253
281
|
});
|
|
254
282
|
}
|
|
283
|
+
this.localDevState.addListener('devServerMessage', this.onDevServerMessage);
|
|
255
284
|
await this.installAppOrOpenInstallUrl(isReinstall || false);
|
|
256
285
|
}
|
|
257
286
|
else {
|
|
@@ -266,7 +295,7 @@ class AppDevModeInterface {
|
|
|
266
295
|
catch (e) {
|
|
267
296
|
logError(e);
|
|
268
297
|
}
|
|
269
|
-
this.
|
|
298
|
+
this.localDevState.addListener('projectNodes', this.onChangeProjectNodes);
|
|
270
299
|
return UIEDevModeInterface.setup(args);
|
|
271
300
|
}
|
|
272
301
|
async start() {
|
|
@@ -1,40 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
cleanup?: () => Promise<void>;
|
|
7
|
-
};
|
|
8
|
-
type ComponentsByType = {
|
|
9
|
-
[key in ComponentTypes]?: {
|
|
10
|
-
[key: string]: Component;
|
|
11
|
-
};
|
|
1
|
+
import LocalDevState from './LocalDevState.js';
|
|
2
|
+
import LocalDevLogger from './LocalDevLogger.js';
|
|
3
|
+
type DevServerManagerConstructorOptions = {
|
|
4
|
+
localDevState: LocalDevState;
|
|
5
|
+
logger: LocalDevLogger;
|
|
12
6
|
};
|
|
13
7
|
declare class DevServerManager {
|
|
14
8
|
private initialized;
|
|
15
9
|
private started;
|
|
16
|
-
private componentsByType;
|
|
17
10
|
private devServers;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
setup({ components, onUploadRequired, accountId, setActiveApp, }: {
|
|
24
|
-
components: Component[];
|
|
25
|
-
onUploadRequired: () => void;
|
|
26
|
-
accountId: number;
|
|
27
|
-
setActiveApp: (appUid: string | undefined) => Promise<void>;
|
|
28
|
-
}): Promise<void>;
|
|
29
|
-
start({ accountId, projectConfig, }: {
|
|
30
|
-
accountId: number;
|
|
31
|
-
projectConfig: ProjectConfig;
|
|
32
|
-
}): Promise<void>;
|
|
11
|
+
private localDevState;
|
|
12
|
+
constructor(options: DevServerManagerConstructorOptions);
|
|
13
|
+
private iterateDevServers;
|
|
14
|
+
setup(): Promise<void>;
|
|
15
|
+
start(): Promise<void>;
|
|
33
16
|
fileChange({ filePath, event, }: {
|
|
34
17
|
filePath: string;
|
|
35
18
|
event: string;
|
|
36
19
|
}): Promise<void>;
|
|
37
20
|
cleanup(): Promise<void>;
|
|
38
21
|
}
|
|
39
|
-
|
|
40
|
-
export default Manager;
|
|
22
|
+
export default DevServerManager;
|
|
@@ -1,93 +1,53 @@
|
|
|
1
1
|
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
2
|
-
import { DevModeInterface as UIEDevModeInterface } from '@hubspot/ui-extensions-dev-server';
|
|
3
|
-
import { startPortManagerServer, stopPortManagerServer, requestPorts, } from '@hubspot/local-dev-lib/portManager';
|
|
4
2
|
import { getHubSpotApiOrigin, getHubSpotWebsiteOrigin, } from '@hubspot/local-dev-lib/urls';
|
|
5
3
|
import { getAccountConfig } from '@hubspot/local-dev-lib/config';
|
|
6
|
-
import
|
|
4
|
+
import AppDevModeInterface from './AppDevModeInterface.js';
|
|
7
5
|
import { lib } from '../../../lang/en.js';
|
|
8
|
-
import { uiLogger } from '../../ui/logger.js';
|
|
9
|
-
const SERVER_KEYS = {
|
|
10
|
-
privateApp: 'privateApp',
|
|
11
|
-
publicApp: 'publicApp',
|
|
12
|
-
};
|
|
13
6
|
class DevServerManager {
|
|
14
7
|
initialized;
|
|
15
8
|
started;
|
|
16
|
-
componentsByType;
|
|
17
9
|
devServers;
|
|
18
|
-
|
|
10
|
+
localDevState;
|
|
11
|
+
constructor(options) {
|
|
19
12
|
this.initialized = false;
|
|
20
13
|
this.started = false;
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[SERVER_KEYS.publicApp]: {
|
|
28
|
-
componentType: ComponentTypes.PublicApp,
|
|
29
|
-
serverInterface: UIEDevModeInterface,
|
|
30
|
-
},
|
|
31
|
-
};
|
|
14
|
+
this.localDevState = options.localDevState;
|
|
15
|
+
const AppsDevServer = new AppDevModeInterface({
|
|
16
|
+
localDevState: options.localDevState,
|
|
17
|
+
localDevLogger: options.logger,
|
|
18
|
+
});
|
|
19
|
+
this.devServers = [AppsDevServer];
|
|
32
20
|
}
|
|
33
21
|
async iterateDevServers(callback) {
|
|
34
|
-
|
|
35
|
-
for (let i = 0; i < serverKeys.length; i++) {
|
|
36
|
-
const serverKey = serverKeys[i];
|
|
37
|
-
const devServer = this.devServers[serverKey];
|
|
38
|
-
const compatibleComponents = this.componentsByType[devServer.componentType] || {};
|
|
39
|
-
if (Object.keys(compatibleComponents).length) {
|
|
40
|
-
await callback(devServer.serverInterface, compatibleComponents);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
uiLogger.debug(lib.DevServerManager.noCompatibleComponents(serverKey));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
arrangeComponentsByType(components) {
|
|
48
|
-
return components.reduce((acc, component) => {
|
|
49
|
-
if (!acc[component.type]) {
|
|
50
|
-
acc[component.type] = {};
|
|
51
|
-
}
|
|
52
|
-
if ('name' in component.config && component.config.name) {
|
|
53
|
-
acc[component.type][component.config.name] = component;
|
|
54
|
-
}
|
|
55
|
-
return acc;
|
|
56
|
-
}, {});
|
|
22
|
+
await Promise.all(this.devServers.map(devServer => callback(devServer)));
|
|
57
23
|
}
|
|
58
|
-
async setup(
|
|
59
|
-
this.componentsByType = this.arrangeComponentsByType(components);
|
|
24
|
+
async setup() {
|
|
60
25
|
let env;
|
|
61
|
-
const accountConfig = getAccountConfig(
|
|
26
|
+
const accountConfig = getAccountConfig(this.localDevState.targetTestingAccountId);
|
|
62
27
|
if (accountConfig) {
|
|
63
28
|
env = accountConfig.env;
|
|
64
29
|
}
|
|
65
|
-
await
|
|
66
|
-
await this.iterateDevServers(async (serverInterface, compatibleComponents) => {
|
|
30
|
+
await this.iterateDevServers(async (serverInterface) => {
|
|
67
31
|
if (serverInterface.setup) {
|
|
32
|
+
// @TODO: In the future, update UIE Dev Server to use LocalDevState
|
|
68
33
|
await serverInterface.setup({
|
|
69
|
-
components:
|
|
70
|
-
|
|
34
|
+
components: this.localDevState.projectNodes,
|
|
35
|
+
profileData: this.localDevState.projectProfileData,
|
|
71
36
|
logger,
|
|
72
37
|
urls: {
|
|
73
38
|
api: getHubSpotApiOrigin(env),
|
|
74
39
|
web: getHubSpotWebsiteOrigin(env),
|
|
75
40
|
},
|
|
76
|
-
setActiveApp,
|
|
77
41
|
});
|
|
78
42
|
}
|
|
79
43
|
});
|
|
80
44
|
this.initialized = true;
|
|
81
45
|
}
|
|
82
|
-
async start(
|
|
46
|
+
async start() {
|
|
83
47
|
if (this.initialized) {
|
|
84
48
|
await this.iterateDevServers(async (serverInterface) => {
|
|
85
49
|
if (serverInterface.start) {
|
|
86
|
-
await serverInterface.start(
|
|
87
|
-
accountId,
|
|
88
|
-
projectConfig,
|
|
89
|
-
requestPorts,
|
|
90
|
-
});
|
|
50
|
+
await serverInterface.start();
|
|
91
51
|
}
|
|
92
52
|
});
|
|
93
53
|
}
|
|
@@ -112,9 +72,7 @@ class DevServerManager {
|
|
|
112
72
|
await serverInterface.cleanup();
|
|
113
73
|
}
|
|
114
74
|
});
|
|
115
|
-
await stopPortManagerServer();
|
|
116
75
|
}
|
|
117
76
|
}
|
|
118
77
|
}
|
|
119
|
-
|
|
120
|
-
export default Manager;
|
|
78
|
+
export default DevServerManager;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ProjectConfig, ComponentTypes, Component } from '../../../types/Projects.js';
|
|
2
|
+
type DevServerInterface = {
|
|
3
|
+
setup?: Function;
|
|
4
|
+
start?: (options: object) => Promise<void>;
|
|
5
|
+
fileChange?: (filePath: string, event: string) => Promise<void>;
|
|
6
|
+
cleanup?: () => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
type ComponentsByType = {
|
|
9
|
+
[key in ComponentTypes]?: {
|
|
10
|
+
[key: string]: Component;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare class DevServerManager_DEPRECATED {
|
|
14
|
+
private initialized;
|
|
15
|
+
private started;
|
|
16
|
+
private componentsByType;
|
|
17
|
+
private devServers;
|
|
18
|
+
constructor();
|
|
19
|
+
iterateDevServers(callback: (serverInterface: DevServerInterface, compatibleComponents: {
|
|
20
|
+
[key: string]: Component;
|
|
21
|
+
}) => Promise<void>): Promise<void>;
|
|
22
|
+
arrangeComponentsByType(components: Component[]): ComponentsByType;
|
|
23
|
+
setup({ components, onUploadRequired, accountId, setActiveApp, }: {
|
|
24
|
+
components: Component[];
|
|
25
|
+
onUploadRequired: () => void;
|
|
26
|
+
accountId: number;
|
|
27
|
+
setActiveApp: (appUid: string | undefined) => Promise<void>;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
start({ accountId, projectConfig, }: {
|
|
30
|
+
accountId: number;
|
|
31
|
+
projectConfig: ProjectConfig;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
fileChange({ filePath, event, }: {
|
|
34
|
+
filePath: string;
|
|
35
|
+
event: string;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
cleanup(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
declare const Manager: DevServerManager_DEPRECATED;
|
|
40
|
+
export default Manager;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
2
|
+
import { DevModeInterface as UIEDevModeInterface } from '@hubspot/ui-extensions-dev-server';
|
|
3
|
+
import { startPortManagerServer, stopPortManagerServer, requestPorts, } from '@hubspot/local-dev-lib/portManager';
|
|
4
|
+
import { getHubSpotApiOrigin, getHubSpotWebsiteOrigin, } from '@hubspot/local-dev-lib/urls';
|
|
5
|
+
import { getAccountConfig } from '@hubspot/local-dev-lib/config';
|
|
6
|
+
import { ComponentTypes, } from '../../../types/Projects.js';
|
|
7
|
+
import { lib } from '../../../lang/en.js';
|
|
8
|
+
import { uiLogger } from '../../ui/logger.js';
|
|
9
|
+
const SERVER_KEYS = {
|
|
10
|
+
privateApp: 'privateApp',
|
|
11
|
+
publicApp: 'publicApp',
|
|
12
|
+
};
|
|
13
|
+
class DevServerManager_DEPRECATED {
|
|
14
|
+
initialized;
|
|
15
|
+
started;
|
|
16
|
+
componentsByType;
|
|
17
|
+
devServers;
|
|
18
|
+
constructor() {
|
|
19
|
+
this.initialized = false;
|
|
20
|
+
this.started = false;
|
|
21
|
+
this.componentsByType = {};
|
|
22
|
+
this.devServers = {
|
|
23
|
+
[SERVER_KEYS.privateApp]: {
|
|
24
|
+
componentType: ComponentTypes.PrivateApp,
|
|
25
|
+
serverInterface: UIEDevModeInterface,
|
|
26
|
+
},
|
|
27
|
+
[SERVER_KEYS.publicApp]: {
|
|
28
|
+
componentType: ComponentTypes.PublicApp,
|
|
29
|
+
serverInterface: UIEDevModeInterface,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async iterateDevServers(callback) {
|
|
34
|
+
const serverKeys = Object.keys(this.devServers);
|
|
35
|
+
for (let i = 0; i < serverKeys.length; i++) {
|
|
36
|
+
const serverKey = serverKeys[i];
|
|
37
|
+
const devServer = this.devServers[serverKey];
|
|
38
|
+
const compatibleComponents = this.componentsByType[devServer.componentType] || {};
|
|
39
|
+
if (Object.keys(compatibleComponents).length) {
|
|
40
|
+
await callback(devServer.serverInterface, compatibleComponents);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
uiLogger.debug(lib.DevServerManager.noCompatibleComponents(serverKey));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
arrangeComponentsByType(components) {
|
|
48
|
+
return components.reduce((acc, component) => {
|
|
49
|
+
if (!acc[component.type]) {
|
|
50
|
+
acc[component.type] = {};
|
|
51
|
+
}
|
|
52
|
+
if ('name' in component.config && component.config.name) {
|
|
53
|
+
acc[component.type][component.config.name] = component;
|
|
54
|
+
}
|
|
55
|
+
return acc;
|
|
56
|
+
}, {});
|
|
57
|
+
}
|
|
58
|
+
async setup({ components, onUploadRequired, accountId, setActiveApp, }) {
|
|
59
|
+
this.componentsByType = this.arrangeComponentsByType(components);
|
|
60
|
+
let env;
|
|
61
|
+
const accountConfig = getAccountConfig(accountId);
|
|
62
|
+
if (accountConfig) {
|
|
63
|
+
env = accountConfig.env;
|
|
64
|
+
}
|
|
65
|
+
await startPortManagerServer();
|
|
66
|
+
await this.iterateDevServers(async (serverInterface, compatibleComponents) => {
|
|
67
|
+
if (serverInterface.setup) {
|
|
68
|
+
await serverInterface.setup({
|
|
69
|
+
components: compatibleComponents,
|
|
70
|
+
onUploadRequired,
|
|
71
|
+
logger,
|
|
72
|
+
urls: {
|
|
73
|
+
api: getHubSpotApiOrigin(env),
|
|
74
|
+
web: getHubSpotWebsiteOrigin(env),
|
|
75
|
+
},
|
|
76
|
+
setActiveApp,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
this.initialized = true;
|
|
81
|
+
}
|
|
82
|
+
async start({ accountId, projectConfig, }) {
|
|
83
|
+
if (this.initialized) {
|
|
84
|
+
await this.iterateDevServers(async (serverInterface) => {
|
|
85
|
+
if (serverInterface.start) {
|
|
86
|
+
await serverInterface.start({
|
|
87
|
+
accountId,
|
|
88
|
+
projectConfig,
|
|
89
|
+
requestPorts,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw new Error(lib.DevServerManager.notInitialized);
|
|
96
|
+
}
|
|
97
|
+
this.started = true;
|
|
98
|
+
}
|
|
99
|
+
async fileChange({ filePath, event, }) {
|
|
100
|
+
if (this.started) {
|
|
101
|
+
this.iterateDevServers(async (serverInterface) => {
|
|
102
|
+
if (serverInterface.fileChange) {
|
|
103
|
+
await serverInterface.fileChange(filePath, event);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async cleanup() {
|
|
109
|
+
if (this.started) {
|
|
110
|
+
await this.iterateDevServers(async (serverInterface) => {
|
|
111
|
+
if (serverInterface.cleanup) {
|
|
112
|
+
await serverInterface.cleanup();
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
await stopPortManagerServer();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const Manager = new DevServerManager_DEPRECATED();
|
|
120
|
+
export default Manager;
|
|
@@ -18,9 +18,13 @@ declare class LocalDevLogger {
|
|
|
18
18
|
cleanupError(): void;
|
|
19
19
|
cleanupSuccess(): void;
|
|
20
20
|
uploadInitiated(): void;
|
|
21
|
+
deployInitiated(): void;
|
|
21
22
|
projectConfigMismatch(): void;
|
|
22
23
|
uploadError(error: unknown): void;
|
|
23
24
|
uploadSuccess(): void;
|
|
25
|
+
uploadSuccessAutoDeployDisabled(): void;
|
|
26
|
+
deployError(error?: unknown): void;
|
|
27
|
+
deploySuccess(): void;
|
|
24
28
|
monitorConsoleOutput(): void;
|
|
25
29
|
}
|
|
26
30
|
export default LocalDevLogger;
|