@hubspot/ui-extensions-dev-server 0.0.1-beta.1 → 0.0.1-beta.2
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/constants.js +5 -0
- package/package.json +2 -2
- package/server.js +7 -1
- package/tests/testDevServer.js +7 -0
package/constants.js
CHANGED
|
@@ -16,10 +16,15 @@ const ROLLUP_OPTIONS = {
|
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
const EXTENSIONS_MESSAGE_VERSION = 0;
|
|
20
|
+
const WEBSOCKET_MESSAGE_VERSION = 0;
|
|
21
|
+
|
|
19
22
|
module.exports = {
|
|
20
23
|
VITE_DEFAULT_PORT,
|
|
21
24
|
ROLLUP_OPTIONS,
|
|
22
25
|
MAIN_APP_CONFIG,
|
|
23
26
|
PROJECT_CONFIG,
|
|
24
27
|
OUTPUT_DIR,
|
|
28
|
+
EXTENSIONS_MESSAGE_VERSION,
|
|
29
|
+
WEBSOCKET_MESSAGE_VERSION,
|
|
25
30
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/ui-extensions-dev-server",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"optional": true
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "3bad0a556e00ca7c628916da199bb6f6b787ad6f"
|
|
62
62
|
}
|
package/server.js
CHANGED
|
@@ -5,6 +5,10 @@ const http = require('http');
|
|
|
5
5
|
const logger = require('./logger');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const cors = require('cors');
|
|
8
|
+
const {
|
|
9
|
+
EXTENSIONS_MESSAGE_VERSION,
|
|
10
|
+
WEBSOCKET_MESSAGE_VERSION,
|
|
11
|
+
} = require('./constants');
|
|
8
12
|
|
|
9
13
|
function startDevServer(outputDir, port, extensionConfig) {
|
|
10
14
|
const callback = `http://hslocal.net:${port}/${extensionConfig?.output}`;
|
|
@@ -41,6 +45,7 @@ function _setupWebSocketServer(server, extensionConfig, callback) {
|
|
|
41
45
|
appName: extensionConfig?.appName,
|
|
42
46
|
title: extensionConfig?.name,
|
|
43
47
|
callback,
|
|
48
|
+
version: WEBSOCKET_MESSAGE_VERSION,
|
|
44
49
|
};
|
|
45
50
|
|
|
46
51
|
wss.on('connection', client => {
|
|
@@ -99,12 +104,13 @@ function _addExtensionsEndpoint(server, port) {
|
|
|
99
104
|
} = manifest;
|
|
100
105
|
|
|
101
106
|
const response = {
|
|
107
|
+
websocket: `ws://localhost:${port}`,
|
|
108
|
+
version: EXTENSIONS_MESSAGE_VERSION,
|
|
102
109
|
extensions: [
|
|
103
110
|
{
|
|
104
111
|
appName,
|
|
105
112
|
title: name,
|
|
106
113
|
callback: `http://hslocal.net:${port}/${output}`,
|
|
107
|
-
websocket: `ws://localhost:${port}`,
|
|
108
114
|
manifest: {
|
|
109
115
|
...manifest,
|
|
110
116
|
extension: undefined,
|
package/tests/testDevServer.js
CHANGED
|
@@ -4,6 +4,10 @@ const path = require('path');
|
|
|
4
4
|
const assert = require('assert');
|
|
5
5
|
const http = require('http');
|
|
6
6
|
const WebSocket = require('ws');
|
|
7
|
+
const {
|
|
8
|
+
WEBSOCKET_MESSAGE_VERSION,
|
|
9
|
+
EXTENSIONS_MESSAGE_VERSION,
|
|
10
|
+
} = require('../constants');
|
|
7
11
|
|
|
8
12
|
const testResults = {
|
|
9
13
|
buildTestPassed: false,
|
|
@@ -156,6 +160,8 @@ function testExpressServer(results, logger) {
|
|
|
156
160
|
extension.callback,
|
|
157
161
|
`http://${host}:${port}/PhoneLines.js`
|
|
158
162
|
);
|
|
163
|
+
assert.equal(body.websocket, `ws://localhost:${port}`);
|
|
164
|
+
assert.strictEquals(body.version, EXTENSIONS_MESSAGE_VERSION);
|
|
159
165
|
logger.info('- Express serving extension data 🚀');
|
|
160
166
|
results.extensionsEndpointPassed = true;
|
|
161
167
|
});
|
|
@@ -172,6 +178,7 @@ function testWebSocketServer(results, logger) {
|
|
|
172
178
|
assert(message.event === 'start');
|
|
173
179
|
assert.strictEqual(message.appName, 'Example App React UI');
|
|
174
180
|
assert.strictEqual(message.title, 'Phone Lines');
|
|
181
|
+
assert.strictEqual(message.version, WEBSOCKET_MESSAGE_VERSION);
|
|
175
182
|
logger.info('- WebSocket server connected and sending messages 🚀');
|
|
176
183
|
results.webSocketTestPassed = true;
|
|
177
184
|
ws.close(); // The test passed, close the connection
|