@hubspot/cli 7.8.12-experimental.1 → 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/commands/__tests__/cms.test.js +44 -1
- package/commands/__tests__/customObject.test.js +22 -1
- package/commands/__tests__/project.test.js +2 -0
- package/commands/account/auth.js +1 -0
- package/commands/auth.js +1 -0
- 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/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/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 +26 -0
- package/commands/create.js +4 -2
- 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/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 -36
- 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 -41
- 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 +4 -2
- package/commands/customObject/updateSchema.d.ts +7 -0
- package/commands/customObject/updateSchema.js +71 -0
- package/commands/customObject.js +16 -1
- package/commands/feedback.js +1 -1
- package/commands/fetch.d.ts +4 -12
- package/commands/fetch.js +19 -46
- package/commands/function/deploy.d.ts +4 -6
- package/commands/function/deploy.js +14 -71
- 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 -29
- package/commands/function.d.ts +2 -4
- package/commands/function.js +25 -14
- package/commands/lint.d.ts +4 -6
- package/commands/lint.js +13 -65
- package/commands/list.d.ts +4 -6
- package/commands/list.js +13 -74
- package/commands/logs.d.ts +4 -10
- package/commands/logs.js +24 -87
- 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 +13 -39
- package/commands/project/__tests__/add.test.js +12 -12
- package/commands/project/__tests__/devUnifiedFlow.test.js +32 -0
- package/commands/project/__tests__/list.test.js +31 -0
- package/commands/project/__tests__/migrate.test.js +1 -0
- package/commands/project/add.d.ts +2 -2
- package/commands/project/add.js +3 -2
- package/commands/project/create.js +1 -1
- package/commands/project/dev/deprecatedFlow.js +2 -2
- package/commands/project/dev/index.js +5 -5
- package/commands/project/dev/unifiedFlow.js +8 -3
- package/commands/project/download.js +5 -2
- package/commands/project/installDeps.d.ts +2 -2
- package/commands/project/installDeps.js +1 -0
- package/commands/project/list.d.ts +4 -0
- package/commands/project/list.js +62 -0
- package/commands/project/migrate.js +5 -2
- package/commands/project.js +2 -0
- package/commands/remove.d.ts +4 -6
- package/commands/remove.js +12 -24
- package/commands/testAccount/create.js +2 -2
- package/commands/testAccount/delete.js +1 -1
- 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 -180
- 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 +560 -425
- package/lang/en.js +562 -427
- package/lang/en.lyaml +2 -2
- package/lib/__tests__/buildAccount.test.js +2 -2
- package/lib/buildAccount.d.ts +2 -2
- package/lib/buildAccount.js +7 -7
- package/lib/configMigrate.js +88 -9
- package/lib/constants.d.ts +9 -0
- package/lib/constants.js +9 -0
- package/lib/generateSelectors.js +1 -1
- package/lib/middleware/autoUpdateMiddleware.d.ts +2 -1
- package/lib/middleware/autoUpdateMiddleware.js +12 -2
- package/lib/middleware/commandTargetingUtils.d.ts +1 -1
- package/lib/middleware/commandTargetingUtils.js +16 -20
- package/lib/projects/__tests__/AppDevModeInterface.test.js +95 -109
- 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 +6 -6
- 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__/upload.test.js +2 -2
- package/lib/projects/add/__tests__/v2AddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/{v3AddComponent.test.js → v2AddComponent.test.js} +35 -35
- 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__/v2.test.d.ts +1 -0
- package/lib/projects/create/__tests__/{v3.test.js → v2.test.js} +2 -2
- package/lib/projects/create/index.js +2 -2
- package/lib/projects/create/{v3.d.ts → v2.d.ts} +3 -3
- package/lib/projects/create/{v3.js → v2.js} +3 -3
- package/lib/projects/deploy.d.ts +1 -1
- package/lib/projects/deploy.js +2 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +9 -3
- package/lib/projects/localDev/AppDevModeInterface.js +116 -105
- 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/{LocalDevManager.js → LocalDevManager_DEPRECATED.js} +6 -6
- 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 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +39 -6
- 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.js +2 -3
- package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +3 -0
- package/lib/projects/localDev/localDevWebsocketServerUtils.js +9 -0
- package/lib/projects/urls.d.ts +0 -1
- package/lib/projects/urls.js +0 -3
- package/lib/prompts/__tests__/projectAddPrompt.test.js +10 -10
- package/lib/prompts/installAppPrompt.d.ts +1 -6
- package/lib/prompts/installAppPrompt.js +1 -6
- package/lib/prompts/projectAddPrompt.d.ts +2 -2
- package/lib/prompts/projectAddPrompt.js +1 -1
- package/lib/theme/__tests__/migrate.test.js +4 -4
- package/lib/ui/index.d.ts +2 -0
- package/lib/ui/index.js +8 -0
- package/lib/ui/uiMessages.d.ts +5 -0
- package/lib/ui/uiMessages.js +5 -0
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +1 -1
- package/package.json +6 -5
- package/types/Cms.d.ts +6 -6
- 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/customObject/{schema/__tests__/create.test.d.ts → __tests__/deleteSchema.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/fetch-all.test.d.ts → __tests__/fetch-all-schemas.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/fetch.test.d.ts → __tests__/fetchSchema.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/list.test.d.ts → __tests__/listSchemas.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/update.test.d.ts → __tests__/updateSchema.test.d.ts} +0 -0
- /package/{lib/projects/add/__tests__/v3AddComponent.test.d.ts → commands/project/__tests__/list.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/{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
|
@@ -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;
|
|
@@ -6,10 +6,10 @@ import { fetchPublicAppsForPortal, fetchPublicAppProductionInstallCounts, } from
|
|
|
6
6
|
import { getAccountId, getConfigDefaultAccount, } from '@hubspot/local-dev-lib/config';
|
|
7
7
|
import { PROJECT_CONFIG_FILE } from '../../constants.js';
|
|
8
8
|
import SpinniesManager from '../../ui/SpinniesManager.js';
|
|
9
|
-
import
|
|
9
|
+
import DevServerManager_DEPRECATED from './DevServerManager_DEPRECATED.js';
|
|
10
10
|
import { EXIT_CODES } from '../../enums/exitCodes.js';
|
|
11
11
|
import { getAccountHomeUrl } from '../urls.js';
|
|
12
|
-
import { componentIsApp, componentIsPublicApp, CONFIG_FILES, getAppCardConfigs, getComponentUid, } from '
|
|
12
|
+
import { componentIsApp, componentIsPublicApp, CONFIG_FILES, getAppCardConfigs, getComponentUid, } from '../structure.js';
|
|
13
13
|
import { ComponentTypes, } from '../../../types/Projects.js';
|
|
14
14
|
import { UI_COLORS, uiCommandReference, uiAccountDescription, uiBetaTag, uiLink, uiLine, } from '../../ui/index.js';
|
|
15
15
|
import { logError } from '../../errorHandlers/index.js';
|
|
@@ -313,7 +313,7 @@ class LocalDevManager {
|
|
|
313
313
|
}
|
|
314
314
|
async devServerSetup() {
|
|
315
315
|
try {
|
|
316
|
-
await
|
|
316
|
+
await DevServerManager_DEPRECATED.setup({
|
|
317
317
|
components: this.runnableComponents,
|
|
318
318
|
onUploadRequired: this.logUploadWarning.bind(this),
|
|
319
319
|
accountId: this.targetAccountId,
|
|
@@ -331,7 +331,7 @@ class LocalDevManager {
|
|
|
331
331
|
}
|
|
332
332
|
async devServerStart() {
|
|
333
333
|
try {
|
|
334
|
-
await
|
|
334
|
+
await DevServerManager_DEPRECATED.start({
|
|
335
335
|
accountId: this.targetAccountId,
|
|
336
336
|
projectConfig: this.projectConfig,
|
|
337
337
|
});
|
|
@@ -346,7 +346,7 @@ class LocalDevManager {
|
|
|
346
346
|
}
|
|
347
347
|
devServerFileChange(filePath, event) {
|
|
348
348
|
try {
|
|
349
|
-
|
|
349
|
+
DevServerManager_DEPRECATED.fileChange({ filePath, event });
|
|
350
350
|
}
|
|
351
351
|
catch (e) {
|
|
352
352
|
if (this.debug) {
|
|
@@ -357,7 +357,7 @@ class LocalDevManager {
|
|
|
357
357
|
}
|
|
358
358
|
async devServerCleanup() {
|
|
359
359
|
try {
|
|
360
|
-
await
|
|
360
|
+
await DevServerManager_DEPRECATED.cleanup();
|
|
361
361
|
return true;
|
|
362
362
|
}
|
|
363
363
|
catch (e) {
|
|
@@ -5,7 +5,7 @@ import path from 'path';
|
|
|
5
5
|
import open from 'open';
|
|
6
6
|
import LocalDevState from './LocalDevState.js';
|
|
7
7
|
import LocalDevLogger from './LocalDevLogger.js';
|
|
8
|
-
import
|
|
8
|
+
import DevServerManager from './DevServerManager.js';
|
|
9
9
|
import { EXIT_CODES } from '../../enums/exitCodes.js';
|
|
10
10
|
import { getProjectConfig } from '../config.js';
|
|
11
11
|
import { handleProjectUpload } from '../upload.js';
|
|
@@ -23,7 +23,7 @@ class LocalDevProcess {
|
|
|
23
23
|
constructor(options) {
|
|
24
24
|
this.state = new LocalDevState(options);
|
|
25
25
|
this._logger = new LocalDevLogger(this.state);
|
|
26
|
-
this.devServerManager = new
|
|
26
|
+
this.devServerManager = new DevServerManager({
|
|
27
27
|
localDevState: this.state,
|
|
28
28
|
logger: this._logger,
|
|
29
29
|
});
|
|
@@ -149,6 +149,7 @@ class LocalDevProcess {
|
|
|
149
149
|
this.openLocalDevUi();
|
|
150
150
|
}
|
|
151
151
|
await this.startDevServers();
|
|
152
|
+
this.state.devServersStarted = true;
|
|
152
153
|
this.logger.monitorConsoleOutput();
|
|
153
154
|
}
|
|
154
155
|
async stop(showProgress = true) {
|
|
@@ -19,6 +19,7 @@ declare class LocalDevState {
|
|
|
19
19
|
private _appData;
|
|
20
20
|
private _devServerMessage;
|
|
21
21
|
private _uploadWarnings;
|
|
22
|
+
private _devServersStarted;
|
|
22
23
|
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectData, debug, initialProjectNodes, initialProjectProfileData, profile, env, }: LocalDevStateConstructorOptions);
|
|
23
24
|
private runListeners;
|
|
24
25
|
get targetProjectAccountId(): number;
|
|
@@ -51,6 +52,8 @@ declare class LocalDevState {
|
|
|
51
52
|
get devServerMessage(): string;
|
|
52
53
|
set devServerMessage(message: LocalDevServerMessage);
|
|
53
54
|
get uploadWarnings(): Set<string>;
|
|
55
|
+
get devServersStarted(): boolean;
|
|
56
|
+
set devServersStarted(started: boolean);
|
|
54
57
|
addUploadWarning(warning: string): void;
|
|
55
58
|
clearUploadWarnings(): void;
|
|
56
59
|
addListener<K extends keyof LocalDevState>(key: K, listener: LocalDevStateListener<K>): void;
|
|
@@ -15,6 +15,7 @@ class LocalDevState {
|
|
|
15
15
|
_appData;
|
|
16
16
|
_devServerMessage;
|
|
17
17
|
_uploadWarnings;
|
|
18
|
+
_devServersStarted;
|
|
18
19
|
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectData, debug, initialProjectNodes, initialProjectProfileData, profile, env, }) {
|
|
19
20
|
this._targetProjectAccountId = targetProjectAccountId;
|
|
20
21
|
this._targetTestingAccountId = targetTestingAccountId;
|
|
@@ -30,6 +31,7 @@ class LocalDevState {
|
|
|
30
31
|
this._appData = {};
|
|
31
32
|
this._devServerMessage = LOCAL_DEV_SERVER_MESSAGE_TYPES.INITIAL;
|
|
32
33
|
this._uploadWarnings = new Set();
|
|
34
|
+
this._devServersStarted = false;
|
|
33
35
|
this._listeners = {};
|
|
34
36
|
}
|
|
35
37
|
runListeners(key) {
|
|
@@ -106,6 +108,13 @@ class LocalDevState {
|
|
|
106
108
|
get uploadWarnings() {
|
|
107
109
|
return this._uploadWarnings;
|
|
108
110
|
}
|
|
111
|
+
get devServersStarted() {
|
|
112
|
+
return this._devServersStarted;
|
|
113
|
+
}
|
|
114
|
+
set devServersStarted(started) {
|
|
115
|
+
this._devServersStarted = started;
|
|
116
|
+
this.runListeners('devServersStarted');
|
|
117
|
+
}
|
|
109
118
|
addUploadWarning(warning) {
|
|
110
119
|
this.uploadWarnings.add(warning);
|
|
111
120
|
this.runListeners('uploadWarnings');
|
|
@@ -9,12 +9,16 @@ declare class LocalDevWebsocketServer {
|
|
|
9
9
|
private sendMessage;
|
|
10
10
|
private handleUpload;
|
|
11
11
|
private handleDeploy;
|
|
12
|
+
private handleAppInstallSuccess;
|
|
13
|
+
private handleAppInstallFailure;
|
|
14
|
+
private handleAppInstallInitiated;
|
|
12
15
|
private setupMessageHandlers;
|
|
13
16
|
private sendCliMetadata;
|
|
14
17
|
private sendProjectData;
|
|
15
18
|
private setupProjectNodesListener;
|
|
16
19
|
private setupAppDataListener;
|
|
17
20
|
private setupUploadWarningsListener;
|
|
21
|
+
private setupDevServersStartedListener;
|
|
18
22
|
private setupStateListeners;
|
|
19
23
|
start(): Promise<void>;
|
|
20
24
|
shutdown(): void;
|
|
@@ -2,13 +2,12 @@ import { WebSocketServer } from 'ws';
|
|
|
2
2
|
import { isPortManagerServerRunning, requestPorts, } from '@hubspot/local-dev-lib/portManager';
|
|
3
3
|
import { uiLogger } from '../../ui/logger.js';
|
|
4
4
|
import { addLocalStateFlag } from '@hubspot/local-dev-lib/config';
|
|
5
|
-
import { LOCAL_DEV_UI_MESSAGE_SEND_TYPES, LOCAL_DEV_SERVER_MESSAGE_TYPES, CONFIG_LOCAL_STATE_FLAGS, } from '../../constants.js';
|
|
5
|
+
import { LOCAL_DEV_UI_MESSAGE_SEND_TYPES, LOCAL_DEV_SERVER_MESSAGE_TYPES, CONFIG_LOCAL_STATE_FLAGS, LOCAL_DEV_WEBSOCKET_SERVER_INSTANCE_ID, } from '../../constants.js';
|
|
6
6
|
import { lib } from '../../../lang/en.js';
|
|
7
7
|
import { removeAnsiCodes } from '../../ui/removeAnsiCodes.js';
|
|
8
|
-
import { isDeployWebsocketMessage, isViewedWelcomeScreenWebsocketMessage, isUploadWebsocketMessage, } from './localDevWebsocketServerUtils.js';
|
|
8
|
+
import { isDeployWebsocketMessage, isViewedWelcomeScreenWebsocketMessage, isUploadWebsocketMessage, isAppInstallFailureWebsocketMessage, isAppInstallSuccessWebsocketMessage, isAppInstallInitiatedWebsocketMessage, } from './localDevWebsocketServerUtils.js';
|
|
9
9
|
import pkg from '../../../package.json' with { type: 'json' };
|
|
10
|
-
const
|
|
11
|
-
const LOCAL_DEV_WEBSOCKET_SERVER_VERSION = 1;
|
|
10
|
+
const LOCAL_DEV_WEBSOCKET_SERVER_VERSION = 2;
|
|
12
11
|
const LOG_PREFIX = '[LocalDevWebsocketServer]';
|
|
13
12
|
const DOMAINS = ['hubspot.com', 'hubspotqa.com'];
|
|
14
13
|
const SUBDOMAINS = ['local', 'app', 'app-na2', 'app-na3', 'app-ap1', 'app-eu1'];
|
|
@@ -62,6 +61,15 @@ class LocalDevWebsocketServer {
|
|
|
62
61
|
},
|
|
63
62
|
});
|
|
64
63
|
}
|
|
64
|
+
async handleAppInstallSuccess() {
|
|
65
|
+
this.localDevProcess.sendDevServerMessage(LOCAL_DEV_SERVER_MESSAGE_TYPES.STATIC_AUTH_APP_INSTALL_SUCCESS);
|
|
66
|
+
}
|
|
67
|
+
async handleAppInstallFailure() {
|
|
68
|
+
this.localDevProcess.sendDevServerMessage(LOCAL_DEV_SERVER_MESSAGE_TYPES.STATIC_AUTH_APP_INSTALL_FAILURE);
|
|
69
|
+
}
|
|
70
|
+
async handleAppInstallInitiated() {
|
|
71
|
+
this.localDevProcess.sendDevServerMessage(LOCAL_DEV_SERVER_MESSAGE_TYPES.OAUTH_APP_INSTALL_INITIATED);
|
|
72
|
+
}
|
|
65
73
|
setupMessageHandlers(websocket) {
|
|
66
74
|
websocket.on('message', data => {
|
|
67
75
|
try {
|
|
@@ -79,6 +87,15 @@ class LocalDevWebsocketServer {
|
|
|
79
87
|
else if (isViewedWelcomeScreenWebsocketMessage(message)) {
|
|
80
88
|
addLocalStateFlag(CONFIG_LOCAL_STATE_FLAGS.LOCAL_DEV_UI_WELCOME);
|
|
81
89
|
}
|
|
90
|
+
else if (isAppInstallSuccessWebsocketMessage(message)) {
|
|
91
|
+
this.handleAppInstallSuccess();
|
|
92
|
+
}
|
|
93
|
+
else if (isAppInstallFailureWebsocketMessage(message)) {
|
|
94
|
+
this.handleAppInstallFailure();
|
|
95
|
+
}
|
|
96
|
+
else if (isAppInstallInitiatedWebsocketMessage(message)) {
|
|
97
|
+
this.handleAppInstallInitiated();
|
|
98
|
+
}
|
|
82
99
|
else {
|
|
83
100
|
this.logError(lib.LocalDevWebsocketServer.errors.unknownMessageType(message.type));
|
|
84
101
|
}
|
|
@@ -147,18 +164,34 @@ class LocalDevWebsocketServer {
|
|
|
147
164
|
this.localDevProcess.removeStateListener('uploadWarnings', listener);
|
|
148
165
|
});
|
|
149
166
|
}
|
|
167
|
+
setupDevServersStartedListener(websocket) {
|
|
168
|
+
const listener = (devServersStarted) => {
|
|
169
|
+
if (devServersStarted) {
|
|
170
|
+
this.sendMessage(websocket, {
|
|
171
|
+
type: LOCAL_DEV_UI_MESSAGE_SEND_TYPES.DEV_SERVERS_STARTED,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
this.localDevProcess.addStateListener('devServersStarted', listener);
|
|
176
|
+
websocket.on('close', () => {
|
|
177
|
+
this.localDevProcess.removeStateListener('devServersStarted', listener);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
150
180
|
setupStateListeners(websocket) {
|
|
151
181
|
this.setupProjectNodesListener(websocket);
|
|
152
182
|
this.setupAppDataListener(websocket);
|
|
153
183
|
this.setupUploadWarningsListener(websocket);
|
|
184
|
+
this.setupDevServersStartedListener(websocket);
|
|
154
185
|
}
|
|
155
186
|
async start() {
|
|
156
187
|
const portManagerIsRunning = await isPortManagerServerRunning();
|
|
157
188
|
if (!portManagerIsRunning) {
|
|
158
189
|
throw new Error(lib.LocalDevWebsocketServer.errors.portManagerNotRunning(LOG_PREFIX));
|
|
159
190
|
}
|
|
160
|
-
const portData = await requestPorts([
|
|
161
|
-
|
|
191
|
+
const portData = await requestPorts([
|
|
192
|
+
{ instanceId: LOCAL_DEV_WEBSOCKET_SERVER_INSTANCE_ID },
|
|
193
|
+
]);
|
|
194
|
+
const port = portData[LOCAL_DEV_WEBSOCKET_SERVER_INSTANCE_ID];
|
|
162
195
|
this.server = new WebSocketServer({ port });
|
|
163
196
|
this.log(lib.LocalDevWebsocketServer.logs.startup(port));
|
|
164
197
|
this.server.on('connection', (ws, req) => {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import LocalDevState from './LocalDevState.js';
|
|
2
|
+
type UIExtensionsDevModeInterfaceConstructorOptions = {
|
|
3
|
+
localDevState: LocalDevState;
|
|
4
|
+
};
|
|
5
|
+
declare class UIExtensionsDevModeInterface {
|
|
6
|
+
localDevState: LocalDevState;
|
|
7
|
+
constructor(options: UIExtensionsDevModeInterfaceConstructorOptions);
|
|
8
|
+
setup(): Promise<void>;
|
|
9
|
+
start(): Promise<void>;
|
|
10
|
+
fileChange(filePath: string, event: string): Promise<void>;
|
|
11
|
+
cleanup(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export default UIExtensionsDevModeInterface;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { requestPorts } from '@hubspot/local-dev-lib/portManager';
|
|
2
|
+
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
3
|
+
import { DevModeUnifiedInterface as UIEDevModeInterface } from '@hubspot/ui-extensions-dev-server';
|
|
4
|
+
import { getHubSpotApiOrigin, getHubSpotWebsiteOrigin, } from '@hubspot/local-dev-lib/urls';
|
|
5
|
+
class UIExtensionsDevModeInterface {
|
|
6
|
+
localDevState;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.localDevState = options.localDevState;
|
|
9
|
+
}
|
|
10
|
+
async setup() {
|
|
11
|
+
return UIEDevModeInterface.setup({
|
|
12
|
+
// @ts-expect-error TODO: reconcile types between CLI and UIE Dev Server
|
|
13
|
+
components: this.localDevState.projectNodes,
|
|
14
|
+
profileData: this.localDevState.projectProfileData,
|
|
15
|
+
logger,
|
|
16
|
+
urls: {
|
|
17
|
+
api: getHubSpotApiOrigin(this.localDevState.env),
|
|
18
|
+
web: getHubSpotWebsiteOrigin(this.localDevState.env),
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async start() {
|
|
23
|
+
return UIEDevModeInterface.start({
|
|
24
|
+
accountId: this.localDevState.targetTestingAccountId,
|
|
25
|
+
// @ts-expect-error TODO: reconcile types between CLI and UIE Dev Server
|
|
26
|
+
projectConfig: this.localDevState.projectConfig,
|
|
27
|
+
requestPorts,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async fileChange(filePath, event) {
|
|
31
|
+
return UIEDevModeInterface.fileChange(filePath, event);
|
|
32
|
+
}
|
|
33
|
+
async cleanup() {
|
|
34
|
+
return UIEDevModeInterface.cleanup();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export default UIExtensionsDevModeInterface;
|
|
@@ -8,7 +8,7 @@ export declare function checkIfParentAccountIsAuthed(accountConfig: CLIAccount):
|
|
|
8
8
|
export declare function checkIfAccountFlagIsSupported(accountConfig: CLIAccount, hasPublicApps: boolean): void;
|
|
9
9
|
export declare function suggestRecommendedNestedAccount(accounts: CLIAccount[], accountConfig: CLIAccount, hasPublicApps: boolean): Promise<ProjectDevTargetAccountPromptResponse>;
|
|
10
10
|
export declare function createSandboxForLocalDev(accountId: number, accountConfig: CLIAccount, env: Environment): Promise<number>;
|
|
11
|
-
export declare function createDeveloperTestAccountForLocalDev(accountId: number, accountConfig: CLIAccount, env: Environment,
|
|
11
|
+
export declare function createDeveloperTestAccountForLocalDev(accountId: number, accountConfig: CLIAccount, env: Environment, useV2?: boolean): Promise<number>;
|
|
12
12
|
export declare function useExistingDevTestAccount(env: Environment, account: DeveloperTestAccount): Promise<void>;
|
|
13
13
|
export declare function hasSandboxes(account: CLIAccount): Promise<boolean>;
|
|
14
14
|
export declare function selectAccountTypePrompt(accountConfig: CLIAccount): Promise<string | null>;
|
|
@@ -138,7 +138,7 @@ export async function createSandboxForLocalDev(accountId, accountConfig, env) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
// Create a developer test account and return its accountId
|
|
141
|
-
export async function createDeveloperTestAccountForLocalDev(accountId, accountConfig, env,
|
|
141
|
+
export async function createDeveloperTestAccountForLocalDev(accountId, accountConfig, env, useV2 = false) {
|
|
142
142
|
let currentPortalCount = 0;
|
|
143
143
|
let maxTestPortals = 10;
|
|
144
144
|
try {
|
|
@@ -168,7 +168,7 @@ export async function createDeveloperTestAccountForLocalDev(accountId, accountCo
|
|
|
168
168
|
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
|
|
169
169
|
});
|
|
170
170
|
trackCommandMetadataUsage('developer-test-account-create', { step: 'project-dev' }, accountId);
|
|
171
|
-
const result = await buildDeveloperTestAccount(name, accountConfig, env, maxTestPortals,
|
|
171
|
+
const result = await buildDeveloperTestAccount(name, accountConfig, env, maxTestPortals, useV2);
|
|
172
172
|
return result;
|
|
173
173
|
}
|
|
174
174
|
catch (err) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function confirmLocalDevIsNotRunning(): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LOCAL_DEV_WEBSOCKET_SERVER_INSTANCE_ID } from '../../../constants.js';
|
|
2
|
+
import { EXIT_CODES } from '../../../enums/exitCodes.js';
|
|
3
|
+
import { getServerPortByInstanceId } from '@hubspot/local-dev-lib/portManager';
|
|
4
|
+
import { uiLogger } from '../../../ui/logger.js';
|
|
5
|
+
import { commands } from '../../../../lang/en.js';
|
|
6
|
+
export async function confirmLocalDevIsNotRunning() {
|
|
7
|
+
try {
|
|
8
|
+
await getServerPortByInstanceId(LOCAL_DEV_WEBSOCKET_SERVER_INSTANCE_ID);
|
|
9
|
+
uiLogger.error(commands.project.dev.errors.localDevAlreadyRunning);
|
|
10
|
+
process.exit(EXIT_CODES.ERROR);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -154,9 +154,8 @@ export async function isDeployedProjectUpToDateWithLocal(projectConfig, accountI
|
|
|
154
154
|
try {
|
|
155
155
|
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'hubspot-project-compare-'));
|
|
156
156
|
const { data: zippedProject } = await downloadProject(accountId, projectConfig.name, deployedBuildId);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const deployedProjectSourceDir = path.join(extractedProjectPath, projectConfig.srcDir);
|
|
157
|
+
await extractZipArchive(zippedProject, sanitizeFileName(projectConfig.name), tempDir, { hideLogs: true });
|
|
158
|
+
const deployedProjectSourceDir = path.join(tempDir, projectConfig.srcDir);
|
|
160
159
|
const { intermediateNodesIndexedByUid: deployedProjectNodes } = await translate({
|
|
161
160
|
projectSourceDir: deployedProjectSourceDir,
|
|
162
161
|
platformVersion: projectConfig.platformVersion,
|
|
@@ -2,3 +2,6 @@ import { LocalDevDeployWebsocketMessage, LocalDevWebsocketMessage } from '../../
|
|
|
2
2
|
export declare function isUploadWebsocketMessage(message: LocalDevWebsocketMessage): boolean;
|
|
3
3
|
export declare function isDeployWebsocketMessage(message: LocalDevWebsocketMessage): message is LocalDevDeployWebsocketMessage;
|
|
4
4
|
export declare function isViewedWelcomeScreenWebsocketMessage(message: LocalDevWebsocketMessage): boolean;
|
|
5
|
+
export declare function isAppInstallSuccessWebsocketMessage(message: LocalDevWebsocketMessage): boolean;
|
|
6
|
+
export declare function isAppInstallInitiatedWebsocketMessage(message: LocalDevWebsocketMessage): boolean;
|
|
7
|
+
export declare function isAppInstallFailureWebsocketMessage(message: LocalDevWebsocketMessage): boolean;
|
|
@@ -8,3 +8,12 @@ export function isDeployWebsocketMessage(message) {
|
|
|
8
8
|
export function isViewedWelcomeScreenWebsocketMessage(message) {
|
|
9
9
|
return (message.type === LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES.VIEWED_WELCOME_SCREEN);
|
|
10
10
|
}
|
|
11
|
+
export function isAppInstallSuccessWebsocketMessage(message) {
|
|
12
|
+
return (message.type === LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES.APP_INSTALL_SUCCESS);
|
|
13
|
+
}
|
|
14
|
+
export function isAppInstallInitiatedWebsocketMessage(message) {
|
|
15
|
+
return (message.type === LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES.APP_INSTALL_INITIATED);
|
|
16
|
+
}
|
|
17
|
+
export function isAppInstallFailureWebsocketMessage(message) {
|
|
18
|
+
return (message.type === LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES.APP_INSTALL_FAILURE);
|
|
19
|
+
}
|
package/lib/projects/urls.d.ts
CHANGED
|
@@ -7,4 +7,3 @@ export declare function getProjectBuildDetailUrl(projectName: string, buildId: n
|
|
|
7
7
|
export declare function getProjectDeployDetailUrl(projectName: string, deployId: number, accountId: number): string;
|
|
8
8
|
export declare function getLocalDevUiUrl(accountId: number, showWelcomeScreen?: boolean): string;
|
|
9
9
|
export declare function getAccountHomeUrl(accountId: number): string;
|
|
10
|
-
export declare function getAppAllowlistUrl(accountId: number, projectName: string, appUid: string): string;
|
package/lib/projects/urls.js
CHANGED
|
@@ -41,6 +41,3 @@ export function getAccountHomeUrl(accountId) {
|
|
|
41
41
|
const baseUrl = getHubSpotWebsiteOrigin(getEnv(accountId) === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD);
|
|
42
42
|
return `${baseUrl}/home?portalId=${accountId}`;
|
|
43
43
|
}
|
|
44
|
-
export function getAppAllowlistUrl(accountId, projectName, appUid) {
|
|
45
|
-
return `${getProjectHomeUrl(accountId)}/project/${projectName}/component/${appUid}/distribution?panel=static-token-allowlist`;
|
|
46
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Separator } from '@inquirer/prompts';
|
|
2
|
-
import {
|
|
2
|
+
import { projectAddPromptV2 } from '../projectAddPrompt.js';
|
|
3
3
|
import { promptUser } from '../promptUtils.js';
|
|
4
4
|
vi.mock('../promptUtils');
|
|
5
5
|
const mockedPromptUser = vi.mocked(promptUser);
|
|
@@ -19,7 +19,7 @@ describe('lib/prompts/projectAddPrompt', () => {
|
|
|
19
19
|
supportedAuthTypes: ['oauth'],
|
|
20
20
|
supportedDistributions: ['private'],
|
|
21
21
|
};
|
|
22
|
-
describe('
|
|
22
|
+
describe('projectAddPromptV2()', () => {
|
|
23
23
|
beforeEach(() => {
|
|
24
24
|
// Mock returns empty result, logic will use selectedComponents when selectedFeatures provided
|
|
25
25
|
mockedPromptUser.mockResolvedValue({});
|
|
@@ -31,7 +31,7 @@ describe('lib/prompts/projectAddPrompt', () => {
|
|
|
31
31
|
};
|
|
32
32
|
const components = [templateChoice];
|
|
33
33
|
const selectedFeatures = ['workflow-action-tool'];
|
|
34
|
-
const result = await
|
|
34
|
+
const result = await projectAddPromptV2(components, selectedFeatures);
|
|
35
35
|
expect(result.componentTemplate).toEqual([
|
|
36
36
|
mockComponentTemplateWithCliSelector,
|
|
37
37
|
]);
|
|
@@ -49,7 +49,7 @@ describe('lib/prompts/projectAddPrompt', () => {
|
|
|
49
49
|
};
|
|
50
50
|
const components = [templateChoice];
|
|
51
51
|
const selectedFeatures = ['module'];
|
|
52
|
-
const result = await
|
|
52
|
+
const result = await projectAddPromptV2(components, selectedFeatures);
|
|
53
53
|
expect(result.componentTemplate).toEqual([mockComponentTemplate]);
|
|
54
54
|
expect(mockedPromptUser).toHaveBeenCalledWith([
|
|
55
55
|
expect.objectContaining({
|
|
@@ -65,7 +65,7 @@ describe('lib/prompts/projectAddPrompt', () => {
|
|
|
65
65
|
};
|
|
66
66
|
const components = [templateChoice];
|
|
67
67
|
const selectedFeatures = ['workflow-action-tool']; // matches cliSelector
|
|
68
|
-
const result = await
|
|
68
|
+
const result = await projectAddPromptV2(components, selectedFeatures);
|
|
69
69
|
expect(result.componentTemplate).toEqual([
|
|
70
70
|
mockComponentTemplateWithCliSelector,
|
|
71
71
|
]);
|
|
@@ -78,7 +78,7 @@ describe('lib/prompts/projectAddPrompt', () => {
|
|
|
78
78
|
const components = [templateChoice];
|
|
79
79
|
const selectedFeatures = ['non-matching-feature'];
|
|
80
80
|
mockedPromptUser.mockResolvedValue({ componentTemplate: [] });
|
|
81
|
-
const result = await
|
|
81
|
+
const result = await projectAddPromptV2(components, selectedFeatures);
|
|
82
82
|
expect(result.componentTemplate).toEqual([]);
|
|
83
83
|
});
|
|
84
84
|
it('should throw error when selected feature component is disabled', async () => {
|
|
@@ -89,7 +89,7 @@ describe('lib/prompts/projectAddPrompt', () => {
|
|
|
89
89
|
};
|
|
90
90
|
const components = [disabledTemplateChoice];
|
|
91
91
|
const selectedFeatures = ['workflow-action-tool'];
|
|
92
|
-
await expect(
|
|
92
|
+
await expect(projectAddPromptV2(components, selectedFeatures)).rejects.toThrow(/Cannot.*feature.*workflow-action/);
|
|
93
93
|
});
|
|
94
94
|
it('should handle multiple components with mixed cliSelector availability', async () => {
|
|
95
95
|
const choice1 = {
|
|
@@ -102,7 +102,7 @@ describe('lib/prompts/projectAddPrompt', () => {
|
|
|
102
102
|
};
|
|
103
103
|
const components = [choice1, choice2];
|
|
104
104
|
const selectedFeatures = ['module', 'workflow-action-tool'];
|
|
105
|
-
const result = await
|
|
105
|
+
const result = await projectAddPromptV2(components, selectedFeatures);
|
|
106
106
|
expect(result.componentTemplate).toEqual([
|
|
107
107
|
mockComponentTemplate,
|
|
108
108
|
mockComponentTemplateWithCliSelector,
|
|
@@ -116,7 +116,7 @@ describe('lib/prompts/projectAddPrompt', () => {
|
|
|
116
116
|
};
|
|
117
117
|
const components = [separator, templateChoice];
|
|
118
118
|
const selectedFeatures = ['module'];
|
|
119
|
-
const result = await
|
|
119
|
+
const result = await projectAddPromptV2(components, selectedFeatures);
|
|
120
120
|
expect(result.componentTemplate).toEqual([mockComponentTemplate]);
|
|
121
121
|
});
|
|
122
122
|
it('should prompt user when no selectedFeatures provided', async () => {
|
|
@@ -129,7 +129,7 @@ describe('lib/prompts/projectAddPrompt', () => {
|
|
|
129
129
|
mockedPromptUser.mockResolvedValue({
|
|
130
130
|
componentTemplate: [mockComponentTemplate],
|
|
131
131
|
});
|
|
132
|
-
const result = await
|
|
132
|
+
const result = await projectAddPromptV2(components, selectedFeatures);
|
|
133
133
|
expect(mockedPromptUser).toHaveBeenCalledWith([
|
|
134
134
|
expect.objectContaining({
|
|
135
135
|
name: 'componentTemplate',
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export declare function installAppBrowserPrompt(installUrl: string, isReinstall?: boolean
|
|
2
|
-
testingAccountId: number;
|
|
3
|
-
projectAccountId: number;
|
|
4
|
-
projectName: string;
|
|
5
|
-
appUid: string;
|
|
6
|
-
}): Promise<void>;
|
|
1
|
+
export declare function installAppBrowserPrompt(installUrl: string, isReinstall?: boolean): Promise<void>;
|
|
7
2
|
export declare function installAppAutoPrompt(): Promise<boolean>;
|
|
@@ -3,7 +3,7 @@ import { promptUser } from './promptUtils.js';
|
|
|
3
3
|
import { EXIT_CODES } from '../enums/exitCodes.js';
|
|
4
4
|
import { lib } from '../../lang/en.js';
|
|
5
5
|
import { uiLogger } from '../ui/logger.js';
|
|
6
|
-
export async function installAppBrowserPrompt(installUrl, isReinstall = false
|
|
6
|
+
export async function installAppBrowserPrompt(installUrl, isReinstall = false) {
|
|
7
7
|
uiLogger.log('');
|
|
8
8
|
if (isReinstall) {
|
|
9
9
|
uiLogger.log(lib.prompts.installAppPrompt.reinstallExplanation);
|
|
@@ -11,11 +11,6 @@ export async function installAppBrowserPrompt(installUrl, isReinstall = false, s
|
|
|
11
11
|
else {
|
|
12
12
|
uiLogger.log(lib.prompts.installAppPrompt.explanation);
|
|
13
13
|
}
|
|
14
|
-
if (staticAuthInstallOptions) {
|
|
15
|
-
const { testingAccountId, projectAccountId, projectName, appUid } = staticAuthInstallOptions;
|
|
16
|
-
uiLogger.log(lib.prompts.installAppPrompt.staticAuthExplanation(projectAccountId, testingAccountId, projectName, appUid));
|
|
17
|
-
uiLogger.log('');
|
|
18
|
-
}
|
|
19
14
|
const { shouldOpenBrowser } = await promptUser({
|
|
20
15
|
name: 'shouldOpenBrowser',
|
|
21
16
|
type: 'confirm',
|
|
@@ -4,12 +4,12 @@ type ProjectAddPromptResponse = {
|
|
|
4
4
|
componentTemplate: ComponentTemplate;
|
|
5
5
|
name: string;
|
|
6
6
|
};
|
|
7
|
-
type
|
|
7
|
+
type ProjectAddPromptResponseV2 = {
|
|
8
8
|
componentTemplate: ComponentTemplate[];
|
|
9
9
|
};
|
|
10
10
|
export declare function projectAddPrompt(components: ComponentTemplate[], promptOptions?: {
|
|
11
11
|
name?: string;
|
|
12
12
|
type?: string;
|
|
13
13
|
}): Promise<ProjectAddPromptResponse>;
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function projectAddPromptV2(components: (ComponentTemplateChoice | Separator)[], selectedFeatures: string[] | undefined): Promise<ProjectAddPromptResponseV2>;
|
|
15
15
|
export {};
|
|
@@ -45,7 +45,7 @@ export async function projectAddPrompt(components, promptOptions = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
return result;
|
|
47
47
|
}
|
|
48
|
-
export async function
|
|
48
|
+
export async function projectAddPromptV2(components, selectedFeatures) {
|
|
49
49
|
const selectedComponents = [];
|
|
50
50
|
if (selectedFeatures) {
|
|
51
51
|
components.forEach(template => {
|