@hubspot/ui-extensions-dev-server 0.10.1 → 1.0.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/README.md +23 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -45
- package/dist/lib/DevModeInterface.d.ts +2 -2
- package/dist/lib/DevModeInterface.js +12 -28
- package/dist/lib/DevModeParentInterface.d.ts +2 -2
- package/dist/lib/DevModeParentInterface.js +138 -154
- package/dist/lib/DevModeUnifiedInterface.d.ts +2 -2
- package/dist/lib/DevModeUnifiedInterface.js +28 -49
- package/dist/lib/DevServerState.d.ts +9 -5
- package/dist/lib/DevServerState.js +37 -18
- package/dist/lib/ExtensionsWebSocket.d.ts +25 -0
- package/dist/lib/ExtensionsWebSocket.js +110 -0
- package/dist/lib/__mocks__/config.d.ts +2 -0
- package/dist/lib/__mocks__/config.js +5 -0
- package/dist/lib/__mocks__/isExtensionFile.d.ts +5 -0
- package/dist/lib/__mocks__/isExtensionFile.js +11 -0
- package/dist/lib/__tests__/DevModeInterface.spec.d.ts +1 -0
- package/dist/lib/__tests__/DevModeInterface.spec.js +155 -0
- package/dist/lib/__tests__/DevModeParentInterface.spec.d.ts +1 -0
- package/dist/lib/__tests__/DevModeParentInterface.spec.js +179 -0
- package/dist/lib/__tests__/DevModeUnifiedInterface.spec.d.ts +1 -0
- package/dist/lib/__tests__/DevModeUnifiedInterface.spec.js +236 -0
- package/dist/lib/__tests__/ExtensionsWebSocket.spec.d.ts +1 -0
- package/dist/lib/__tests__/ExtensionsWebSocket.spec.js +304 -0
- package/dist/lib/__tests__/ast.spec.d.ts +1 -0
- package/dist/lib/__tests__/ast.spec.js +737 -0
- package/dist/lib/__tests__/build.spec.d.ts +1 -0
- package/dist/lib/__tests__/build.spec.js +159 -0
- package/dist/lib/__tests__/config.spec.d.ts +1 -0
- package/dist/lib/__tests__/config.spec.js +291 -0
- package/dist/lib/__tests__/dev.spec.d.ts +1 -0
- package/dist/lib/__tests__/dev.spec.js +80 -0
- package/dist/lib/__tests__/extensionsService.spec.d.ts +1 -0
- package/dist/lib/__tests__/extensionsService.spec.js +150 -0
- package/dist/lib/__tests__/factories.d.ts +48 -0
- package/dist/lib/__tests__/factories.js +32 -0
- package/dist/lib/__tests__/fixtures/extensionConfig.d.ts +182 -0
- package/dist/lib/__tests__/fixtures/extensionConfig.js +304 -0
- package/dist/lib/__tests__/fixtures/urls.d.ts +4 -0
- package/dist/lib/__tests__/fixtures/urls.js +4 -0
- package/dist/lib/__tests__/parsing-utils.spec.d.ts +1 -0
- package/dist/lib/__tests__/parsing-utils.spec.js +467 -0
- package/dist/lib/__tests__/plugins/codeBlockingPlugin.spec.d.ts +1 -0
- package/dist/lib/__tests__/plugins/codeBlockingPlugin.spec.js +112 -0
- package/dist/lib/__tests__/plugins/codeCheckingPlugin.spec.d.ts +1 -0
- package/dist/lib/__tests__/plugins/codeCheckingPlugin.spec.js +73 -0
- package/dist/lib/__tests__/plugins/devBuildPlugin.spec.d.ts +1 -0
- package/dist/lib/__tests__/plugins/devBuildPlugin.spec.js +256 -0
- package/dist/lib/__tests__/plugins/friendlyLoggingPlugin.spec.d.ts +1 -0
- package/dist/lib/__tests__/plugins/friendlyLoggingPlugin.spec.js +65 -0
- package/dist/lib/__tests__/plugins/manifestPlugin.spec.d.ts +1 -0
- package/dist/lib/__tests__/plugins/manifestPlugin.spec.js +455 -0
- package/dist/lib/__tests__/plugins/relevantModulesPlugin.spec.d.ts +1 -0
- package/dist/lib/__tests__/plugins/relevantModulesPlugin.spec.js +81 -0
- package/dist/lib/__tests__/server.spec.d.ts +1 -0
- package/dist/lib/__tests__/server.spec.js +152 -0
- package/dist/lib/__tests__/test-utils/ast.d.ts +1 -0
- package/dist/lib/__tests__/test-utils/ast.js +4 -0
- package/dist/lib/__tests__/utils.spec.d.ts +1 -0
- package/dist/lib/__tests__/utils.spec.js +176 -0
- package/dist/lib/ast.d.ts +1 -1
- package/dist/lib/ast.js +22 -29
- package/dist/lib/bin/cli.js +52 -72
- package/dist/lib/build.d.ts +1 -1
- package/dist/lib/build.js +60 -78
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/config.js +31 -34
- package/dist/lib/constants.d.ts +0 -2
- package/dist/lib/constants.js +20 -27
- package/dist/lib/dev.d.ts +1 -1
- package/dist/lib/dev.js +52 -69
- package/dist/lib/extensionsService.d.ts +1 -1
- package/dist/lib/extensionsService.js +21 -15
- package/dist/lib/parsing-utils.d.ts +1 -1
- package/dist/lib/parsing-utils.js +7 -11
- package/dist/lib/plugins/codeBlockingPlugin.d.ts +1 -1
- package/dist/lib/plugins/codeBlockingPlugin.js +5 -8
- package/dist/lib/plugins/codeCheckingPlugin.d.ts +1 -1
- package/dist/lib/plugins/codeCheckingPlugin.js +4 -9
- package/dist/lib/plugins/devBuildPlugin.d.ts +2 -2
- package/dist/lib/plugins/devBuildPlugin.js +74 -99
- package/dist/lib/plugins/friendlyLoggingPlugin.d.ts +2 -2
- package/dist/lib/plugins/friendlyLoggingPlugin.js +4 -12
- package/dist/lib/plugins/manifestPlugin.d.ts +1 -1
- package/dist/lib/plugins/manifestPlugin.js +46 -26
- package/dist/lib/plugins/relevantModulesPlugin.d.ts +2 -2
- package/dist/lib/plugins/relevantModulesPlugin.js +4 -7
- package/dist/lib/server.d.ts +7 -2
- package/dist/lib/server.js +85 -84
- package/dist/lib/types.d.ts +1 -1
- package/dist/lib/types.js +4 -7
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +22 -39
- package/package.json +44 -31
package/README.md
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
|
-
# UI Extensions
|
|
1
|
+
# UI Extensions Dev Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package is a development server library for HubSpot UI Extensions. It provides a Vite and Express-powered server for local development of extensions, which is run via the HubSpot CLI. There is also a `remoteBuild` function, used by Artifactor to generate production builds of extensions.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
This package contains the library functions for running HubSpot UI extensions locally, as well as running a production build for debugging purposes.
|
|
5
|
+
## Installation
|
|
7
6
|
|
|
7
|
+
You can install the package directly to run the CLI command to execute the production build locally:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @hubspot/ui-extensions-dev-server
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
However, most people will use this package indirectly via the [HubSpot cli](https://git.hubteam.com/HubSpot/hubspot-cli-private):
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
hs project dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Key Documentation
|
|
20
|
+
|
|
21
|
+
- [Architectural Overview](./docs/uie-dev-server-overview.md)
|
|
22
|
+
- [How to Contribute](./CONTRIBUTING.md)
|
|
23
|
+
|
|
24
|
+
## Ownership and Issue Management
|
|
25
|
+
|
|
26
|
+
We centerally manage issues in our [primary `ui-extensibility` repo](https://git.hubteam.com/hubspot/ui-extensibility/)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { remoteBuild, buildSingleExtension } from './lib/build';
|
|
2
|
-
import DevModeInterface, { DevModeInterfaceNonSingleton } from './lib/DevModeInterface';
|
|
3
|
-
import DevModeUnifiedInterface, { DevModeUnifiedInterfaceNonSingleton } from './lib/DevModeUnifiedInterface';
|
|
1
|
+
import { remoteBuild, buildSingleExtension } from './lib/build.ts';
|
|
2
|
+
import DevModeInterface, { DevModeInterfaceNonSingleton } from './lib/DevModeInterface.ts';
|
|
3
|
+
import DevModeUnifiedInterface, { DevModeUnifiedInterfaceNonSingleton } from './lib/DevModeUnifiedInterface.ts';
|
|
4
4
|
export { remoteBuild, buildSingleExtension, DevModeInterface, DevModeInterfaceNonSingleton, DevModeUnifiedInterface, DevModeUnifiedInterfaceNonSingleton, };
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.DevModeUnifiedInterfaceNonSingleton = exports.DevModeUnifiedInterface = exports.DevModeInterfaceNonSingleton = exports.DevModeInterface = exports.buildSingleExtension = exports.remoteBuild = void 0;
|
|
37
|
-
const build_1 = require("./lib/build");
|
|
38
|
-
Object.defineProperty(exports, "remoteBuild", { enumerable: true, get: function () { return build_1.remoteBuild; } });
|
|
39
|
-
Object.defineProperty(exports, "buildSingleExtension", { enumerable: true, get: function () { return build_1.buildSingleExtension; } });
|
|
40
|
-
const DevModeInterface_1 = __importStar(require("./lib/DevModeInterface"));
|
|
41
|
-
exports.DevModeInterface = DevModeInterface_1.default;
|
|
42
|
-
Object.defineProperty(exports, "DevModeInterfaceNonSingleton", { enumerable: true, get: function () { return DevModeInterface_1.DevModeInterfaceNonSingleton; } });
|
|
43
|
-
const DevModeUnifiedInterface_1 = __importStar(require("./lib/DevModeUnifiedInterface"));
|
|
44
|
-
exports.DevModeUnifiedInterface = DevModeUnifiedInterface_1.default;
|
|
45
|
-
Object.defineProperty(exports, "DevModeUnifiedInterfaceNonSingleton", { enumerable: true, get: function () { return DevModeUnifiedInterface_1.DevModeUnifiedInterfaceNonSingleton; } });
|
|
1
|
+
import { remoteBuild, buildSingleExtension } from "./lib/build.js";
|
|
2
|
+
import DevModeInterface, { DevModeInterfaceNonSingleton, } from "./lib/DevModeInterface.js";
|
|
3
|
+
import DevModeUnifiedInterface, { DevModeUnifiedInterfaceNonSingleton, } from "./lib/DevModeUnifiedInterface.js";
|
|
4
|
+
export { remoteBuild, buildSingleExtension, DevModeInterface, DevModeInterfaceNonSingleton, DevModeUnifiedInterface, DevModeUnifiedInterfaceNonSingleton, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ProjectComponentMap, AppExtensionMapping, DevModeSetupArguments } from './types';
|
|
2
|
-
import { DevModeParentInterface } from './DevModeParentInterface';
|
|
1
|
+
import { ProjectComponentMap, AppExtensionMapping, DevModeSetupArguments } from './types.ts';
|
|
2
|
+
import { DevModeParentInterface } from './DevModeParentInterface.ts';
|
|
3
3
|
declare class DevModeInterface extends DevModeParentInterface {
|
|
4
4
|
_generateAppExtensionMappings(components: ProjectComponentMap): AppExtensionMapping[];
|
|
5
5
|
setup(args: DevModeSetupArguments): Promise<void>;
|
|
@@ -1,37 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.DevModeInterfaceNonSingleton = void 0;
|
|
15
|
-
const constants_1 = require("./constants");
|
|
16
|
-
const config_1 = require("./config");
|
|
17
|
-
const DevModeParentInterface_1 = require("./DevModeParentInterface");
|
|
18
|
-
class DevModeInterface extends DevModeParentInterface_1.DevModeParentInterface {
|
|
1
|
+
import { SUPPORTED_APP_TYPES, PUBLIC_APP } from "./constants.js";
|
|
2
|
+
import { loadExtensionConfig } from "./config.js";
|
|
3
|
+
import { DevModeParentInterface } from "./DevModeParentInterface.js";
|
|
4
|
+
class DevModeInterface extends DevModeParentInterface {
|
|
19
5
|
_generateAppExtensionMappings(components) {
|
|
20
6
|
// Loop over all of the app configs that are passed in
|
|
21
7
|
const allComponentNames = Object.keys(components);
|
|
22
8
|
return allComponentNames.reduce((appExtensionMappings, componentName) => {
|
|
23
9
|
const component = components[componentName];
|
|
24
|
-
if (!
|
|
10
|
+
if (!SUPPORTED_APP_TYPES.includes(component.type)) {
|
|
25
11
|
return appExtensionMappings; // It's not a modern app, skip it
|
|
26
12
|
}
|
|
27
13
|
// Load all of the extension configs for a particular app.json file
|
|
28
|
-
const extensionsConfigForApp =
|
|
14
|
+
const extensionsConfigForApp = loadExtensionConfig(component.config, component.path);
|
|
29
15
|
const extensionConfigKeys = Object.keys(extensionsConfigForApp);
|
|
30
16
|
// Loop over the loaded extension configs and generate the list of choices to use to prompt the user for input
|
|
31
17
|
extensionConfigKeys.forEach((extensionKey) => {
|
|
32
18
|
const extensionConfig = extensionsConfigForApp[extensionKey];
|
|
33
19
|
if (extensionConfig.appConfig) {
|
|
34
|
-
extensionConfig.appConfig.isPublicApp = component.type ===
|
|
20
|
+
extensionConfig.appConfig.isPublicApp = component.type === PUBLIC_APP;
|
|
35
21
|
}
|
|
36
22
|
appExtensionMappings.push({
|
|
37
23
|
name: `${componentName}/${extensionConfig.data.title}`,
|
|
@@ -41,12 +27,10 @@ class DevModeInterface extends DevModeParentInterface_1.DevModeParentInterface {
|
|
|
41
27
|
return appExtensionMappings;
|
|
42
28
|
}, []);
|
|
43
29
|
}
|
|
44
|
-
setup(args) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
yield this.parentSetup(args);
|
|
48
|
-
});
|
|
30
|
+
async setup(args) {
|
|
31
|
+
args.choices = this._generateAppExtensionMappings(args.components);
|
|
32
|
+
await this.parentSetup(args);
|
|
49
33
|
}
|
|
50
34
|
}
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
export { DevModeInterface as DevModeInterfaceNonSingleton };
|
|
36
|
+
export default new DevModeInterface();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PlatformVersion, ProjectConfig, Logger, ExtensionOutputConfig, ProjectComponentMap, AppExtensionMapping, DevModeStartArguments, DevModeSetupArguments, UnifiedProjectComponentMap, DevModeBaseSetupArguments } from './types';
|
|
2
|
-
import { DevServerState } from './DevServerState';
|
|
1
|
+
import { PlatformVersion, ProjectConfig, Logger, ExtensionOutputConfig, ProjectComponentMap, AppExtensionMapping, DevModeStartArguments, DevModeSetupArguments, UnifiedProjectComponentMap, DevModeBaseSetupArguments } from './types.ts';
|
|
2
|
+
import { DevServerState } from './DevServerState.ts';
|
|
3
3
|
export declare abstract class DevModeParentInterface {
|
|
4
4
|
configs?: ExtensionOutputConfig[];
|
|
5
5
|
devServerState?: DevServerState;
|
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.DevModeParentInterface = void 0;
|
|
16
|
-
const constants_1 = require("./constants");
|
|
17
|
-
const dev_1 = require("./dev");
|
|
18
|
-
const config_1 = require("./config");
|
|
19
|
-
const constants_2 = require("./constants");
|
|
20
|
-
const utils_1 = require("./utils");
|
|
21
|
-
const DevServerState_1 = require("./DevServerState");
|
|
22
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
1
|
+
import { PLATFORM_VERSION } from "./constants.js";
|
|
2
|
+
import { startDevMode } from "./dev.js";
|
|
3
|
+
import { loadLocalConfig } from "./config.js";
|
|
4
|
+
import { throwUnhandledPlatformVersionError } from "./utils.js";
|
|
5
|
+
import { DevServerState } from "./DevServerState.js";
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
import { EXPRESS_DEFAULT_PORT, EXPRESS_SERVER_ID } from "./constants.js";
|
|
23
8
|
const defaultLogger = {
|
|
24
9
|
info: (...args) => {
|
|
25
10
|
console.log(...args);
|
|
@@ -34,27 +19,32 @@ const defaultLogger = {
|
|
|
34
19
|
console.error(...args);
|
|
35
20
|
},
|
|
36
21
|
};
|
|
37
|
-
class DevModeParentInterface {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
export class DevModeParentInterface {
|
|
23
|
+
configs;
|
|
24
|
+
devServerState;
|
|
25
|
+
onUploadRequired;
|
|
26
|
+
logger = defaultLogger;
|
|
27
|
+
urls;
|
|
28
|
+
isConfigured;
|
|
29
|
+
isRunning;
|
|
30
|
+
shutdown;
|
|
41
31
|
_getPlatformVersion(projectConfig) {
|
|
42
|
-
const { platformVersion } = projectConfig
|
|
32
|
+
const { platformVersion } = projectConfig ?? {};
|
|
43
33
|
if (!platformVersion) {
|
|
44
|
-
return
|
|
34
|
+
return PLATFORM_VERSION.V20231;
|
|
45
35
|
}
|
|
46
36
|
switch (platformVersion) {
|
|
47
|
-
case
|
|
48
|
-
return
|
|
49
|
-
case
|
|
50
|
-
return
|
|
51
|
-
case
|
|
52
|
-
return
|
|
53
|
-
case
|
|
54
|
-
case
|
|
55
|
-
return
|
|
37
|
+
case PLATFORM_VERSION.V20231:
|
|
38
|
+
return PLATFORM_VERSION.V20231;
|
|
39
|
+
case PLATFORM_VERSION.V20232:
|
|
40
|
+
return PLATFORM_VERSION.V20232;
|
|
41
|
+
case PLATFORM_VERSION.V20251:
|
|
42
|
+
return PLATFORM_VERSION.V20251;
|
|
43
|
+
case PLATFORM_VERSION.V20252:
|
|
44
|
+
case PLATFORM_VERSION.UNSTABLE:
|
|
45
|
+
return PLATFORM_VERSION.V20252;
|
|
56
46
|
default:
|
|
57
|
-
return
|
|
47
|
+
return throwUnhandledPlatformVersionError(platformVersion);
|
|
58
48
|
}
|
|
59
49
|
}
|
|
60
50
|
_reset() {
|
|
@@ -67,131 +57,125 @@ class DevModeParentInterface {
|
|
|
67
57
|
this.isConfigured = false;
|
|
68
58
|
this.isRunning = false;
|
|
69
59
|
}
|
|
70
|
-
parentSetup(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!input || input.length === 0) {
|
|
94
|
-
return 'Select at least one extension to run';
|
|
95
|
-
}
|
|
96
|
-
const appNames = new Set(input.map((choice) => choice.data.appName));
|
|
97
|
-
if (appNames.size > 1) {
|
|
98
|
-
return 'Running multiple extensions is only supported for a single application';
|
|
99
|
-
}
|
|
100
|
-
return true;
|
|
101
|
-
},
|
|
102
|
-
choices,
|
|
103
|
-
});
|
|
104
|
-
this.configs = answers.extensions;
|
|
105
|
-
}
|
|
106
|
-
this.isConfigured = true;
|
|
107
|
-
if (typeof setActiveApp === 'function') {
|
|
108
|
-
yield setActiveApp((_d = (_c = (_b = this.configs) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.appConfig) === null || _d === void 0 ? void 0 : _d.uid);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
start(_a) {
|
|
113
|
-
return __awaiter(this, arguments, void 0, function* ({ requestPorts, accountId, projectConfig, }) {
|
|
114
|
-
var _b, _c, _d, _e;
|
|
115
|
-
this.logger.debug('Start function was invoked', {
|
|
116
|
-
accountId,
|
|
117
|
-
projectConfig,
|
|
118
|
-
});
|
|
119
|
-
if (this.isRunning) {
|
|
120
|
-
this.logger.debug('Dev server is already running, not starting again');
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
let expressPort = constants_2.EXPRESS_DEFAULT_PORT;
|
|
124
|
-
let webSocketPort = constants_2.WEBSOCKET_DEFAULT_PORT;
|
|
125
|
-
if (requestPorts) {
|
|
126
|
-
try {
|
|
127
|
-
const portData = yield requestPorts([
|
|
128
|
-
{ instanceId: constants_2.EXPRESS_SERVER_ID, port: constants_2.EXPRESS_DEFAULT_PORT },
|
|
129
|
-
{ instanceId: constants_2.VITE_DEV_SERVER_ID, port: constants_2.WEBSOCKET_DEFAULT_PORT },
|
|
130
|
-
]);
|
|
131
|
-
expressPort = portData[constants_2.EXPRESS_SERVER_ID];
|
|
132
|
-
webSocketPort = portData[constants_2.VITE_DEV_SERVER_ID];
|
|
133
|
-
}
|
|
134
|
-
catch (e) {
|
|
135
|
-
if ((e === null || e === void 0 ? void 0 : e.status) === 409) {
|
|
136
|
-
throw new Error('Another instance is already running. To proceed, please stop the existing server and try again.');
|
|
60
|
+
async parentSetup({ onUploadRequired, logger, urls, setActiveApp, choices = [], }) {
|
|
61
|
+
if (this.isConfigured) {
|
|
62
|
+
logger.debug('Dev server has already been configured, skipping');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.logger = logger;
|
|
66
|
+
this.onUploadRequired = onUploadRequired;
|
|
67
|
+
this.urls = urls;
|
|
68
|
+
if (choices.length === 0) {
|
|
69
|
+
throw new Error('No extensions to run');
|
|
70
|
+
}
|
|
71
|
+
else if (choices.length === 1) {
|
|
72
|
+
this.configs = [choices[0].value];
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const promptModule = inquirer.createPromptModule();
|
|
76
|
+
const answers = await promptModule({
|
|
77
|
+
type: 'checkbox',
|
|
78
|
+
name: 'extensions',
|
|
79
|
+
message: 'Which extension(s) would you like to run?',
|
|
80
|
+
validate: (selectedChoices) => {
|
|
81
|
+
if (!selectedChoices || selectedChoices.length === 0) {
|
|
82
|
+
return 'Select at least one extension to run';
|
|
137
83
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
84
|
+
const configs = selectedChoices
|
|
85
|
+
.map((choice) => choice.value)
|
|
86
|
+
.filter((value) => {
|
|
87
|
+
return (typeof value === 'object' && value !== null && 'data' in value);
|
|
88
|
+
});
|
|
89
|
+
if (configs.length !== selectedChoices.length) {
|
|
90
|
+
return 'Invalid extension configuration';
|
|
91
|
+
}
|
|
92
|
+
const appNames = new Set(configs.map((config) => config.data.appName));
|
|
93
|
+
if (appNames.size > 1) {
|
|
94
|
+
return 'Running multiple extensions is only supported for a single application';
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
},
|
|
98
|
+
choices,
|
|
99
|
+
});
|
|
100
|
+
this.configs = answers.extensions;
|
|
101
|
+
}
|
|
102
|
+
this.isConfigured = true;
|
|
103
|
+
if (typeof setActiveApp === 'function') {
|
|
104
|
+
await setActiveApp(this.configs?.[0]?.appConfig?.uid);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async start({ requestPorts, accountId, projectConfig, }) {
|
|
108
|
+
this.logger.debug('Start function was invoked', {
|
|
109
|
+
accountId,
|
|
110
|
+
projectConfig,
|
|
111
|
+
});
|
|
112
|
+
if (this.isRunning) {
|
|
113
|
+
this.logger.debug('Dev server is already running, not starting again');
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
let expressPort = EXPRESS_DEFAULT_PORT;
|
|
117
|
+
if (requestPorts) {
|
|
159
118
|
try {
|
|
160
|
-
|
|
119
|
+
const portData = await requestPorts([
|
|
120
|
+
{ instanceId: EXPRESS_SERVER_ID, port: EXPRESS_DEFAULT_PORT },
|
|
121
|
+
]);
|
|
122
|
+
expressPort = portData[EXPRESS_SERVER_ID];
|
|
161
123
|
}
|
|
162
124
|
catch (e) {
|
|
163
|
-
|
|
164
|
-
|
|
125
|
+
if (e?.status === 409) {
|
|
126
|
+
throw new Error('Another instance is already running. To proceed, please stop the existing server and try again.');
|
|
127
|
+
}
|
|
128
|
+
this.logger.debug('Call to port manager failed, using default ports');
|
|
165
129
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
130
|
+
}
|
|
131
|
+
const { proxy: localDevUrlMapping } = loadLocalConfig(this.configs?.[0]?.path || '', this.logger) || {};
|
|
132
|
+
try {
|
|
133
|
+
this.devServerState = new DevServerState({
|
|
134
|
+
localDevUrlMapping,
|
|
135
|
+
extensionConfigs: this.configs,
|
|
136
|
+
accountId,
|
|
137
|
+
platformVersion: this._getPlatformVersion(projectConfig),
|
|
138
|
+
expressPort,
|
|
139
|
+
logger: this.logger,
|
|
140
|
+
urls: this.urls,
|
|
141
|
+
appConfig: this.configs?.[0]?.appConfig,
|
|
170
142
|
});
|
|
171
|
-
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
this.logger.debug('Error setting up DevServerState', e);
|
|
146
|
+
throw e;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
this.shutdown = await startDevMode(this.devServerState);
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
this.logger.debug('Error starting dev mode', e);
|
|
153
|
+
throw e;
|
|
154
|
+
}
|
|
155
|
+
const { extensionsMetadata } = this.devServerState;
|
|
156
|
+
extensionsMetadata.forEach((metadata) => {
|
|
157
|
+
const { config: { data: { title, appName }, }, } = metadata;
|
|
158
|
+
this.logger.info(`Running extension '${title}' from app '${appName}'`);
|
|
172
159
|
});
|
|
160
|
+
this.isRunning = true;
|
|
173
161
|
}
|
|
174
|
-
// The contract is for this to be async,
|
|
162
|
+
// The contract is for this to be async, with the __event param. Eslint doesn't like it.
|
|
175
163
|
// eslint-disable-next-line require-await
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
});
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
165
|
+
async fileChange(filePath, __event) {
|
|
166
|
+
if (!this.devServerState || !this.devServerState.extensionsMetadata) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const relevantConfigFileChanged = this.devServerState.extensionsMetadata.some((metadata) => metadata.config.extensionConfigPath === filePath);
|
|
170
|
+
if (relevantConfigFileChanged && this.onUploadRequired) {
|
|
171
|
+
this.onUploadRequired();
|
|
172
|
+
}
|
|
186
173
|
}
|
|
187
|
-
cleanup() {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
this._reset();
|
|
194
|
-
});
|
|
174
|
+
async cleanup() {
|
|
175
|
+
if (this.shutdown) {
|
|
176
|
+
await this.shutdown();
|
|
177
|
+
}
|
|
178
|
+
// Since the DevModeInterface is a singleton, we need to wipe out the state when we shutdown
|
|
179
|
+
this._reset();
|
|
195
180
|
}
|
|
196
181
|
}
|
|
197
|
-
exports.DevModeParentInterface = DevModeParentInterface;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AppExtensionMapping, UnifiedProjectComponentMap, UnifiedDevModeSetupArguments, ProfileVariables } from './types';
|
|
2
|
-
import { DevModeParentInterface } from './DevModeParentInterface';
|
|
1
|
+
import { AppExtensionMapping, UnifiedProjectComponentMap, UnifiedDevModeSetupArguments, ProfileVariables } from './types.ts';
|
|
2
|
+
import { DevModeParentInterface } from './DevModeParentInterface.ts';
|
|
3
3
|
declare class DevModeUnifiedInterface extends DevModeParentInterface {
|
|
4
4
|
_generateAppExtensionMappings(components: UnifiedProjectComponentMap, profileData?: ProfileVariables): AppExtensionMapping[];
|
|
5
5
|
setup(args: UnifiedDevModeSetupArguments): Promise<void>;
|