@hubspot/ui-extensions-dev-server 0.6.1-next.9 → 0.7.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/cli/run.js +1 -2
- package/cli/utils.js +0 -5
- package/lib/DevModeInterface.js +0 -7
- package/lib/build.js +6 -2
- package/lib/dev.js +4 -1
- package/lib/plugins/codeInjectionPlugin.js +7 -4
- package/lib/plugins/devBuildPlugin.js +6 -6
- package/lib/server.js +7 -11
- package/package.json +3 -3
package/cli/run.js
CHANGED
|
@@ -15,7 +15,7 @@ const { loadConfigByPath, loadExtensionConfig } = require('./config');
|
|
|
15
15
|
|
|
16
16
|
// eslint-disable-next-line no-floating-promise/no-floating-promise
|
|
17
17
|
(async () => {
|
|
18
|
-
const { DEV_MODE, BUILD_MODE, extension, help
|
|
18
|
+
const { DEV_MODE, BUILD_MODE, extension, help } = parseArgs();
|
|
19
19
|
|
|
20
20
|
if (help || !(DEV_MODE || BUILD_MODE)) {
|
|
21
21
|
showHelp(OUTPUT_DIR);
|
|
@@ -31,7 +31,6 @@ const { loadConfigByPath, loadExtensionConfig } = require('./config');
|
|
|
31
31
|
allExtensionsConfig[path.join(extensionPath, extension)];
|
|
32
32
|
}
|
|
33
33
|
await DevModeInterface.setup({
|
|
34
|
-
alpha,
|
|
35
34
|
promptUser: inquirer.createPromptModule(),
|
|
36
35
|
components: {
|
|
37
36
|
[appConfig.name]: {
|
package/cli/utils.js
CHANGED
|
@@ -14,7 +14,6 @@ function parseArgs() {
|
|
|
14
14
|
const optionDefinitions = [
|
|
15
15
|
{ name: 'port', alias: 'p', type: Number },
|
|
16
16
|
{ name: 'extension', alias: 'e', type: String },
|
|
17
|
-
{ name: 'alpha', type: Boolean },
|
|
18
17
|
{ name: 'help', alias: 'h', type: Boolean },
|
|
19
18
|
];
|
|
20
19
|
|
|
@@ -49,10 +48,6 @@ function showHelp(OUTPUT_DIR) {
|
|
|
49
48
|
description:
|
|
50
49
|
'The extension entrypoint file to build or start local development for',
|
|
51
50
|
},
|
|
52
|
-
{
|
|
53
|
-
name: 'alpha',
|
|
54
|
-
description: 'Run app functions locally.',
|
|
55
|
-
},
|
|
56
51
|
{
|
|
57
52
|
name: 'help',
|
|
58
53
|
alias: 'h',
|
package/lib/DevModeInterface.js
CHANGED
|
@@ -55,11 +55,6 @@ class DevModeInterface {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
async setup({
|
|
58
|
-
// This flag is used for whether to enable local serverless on the dev server pre-INBOUND.
|
|
59
|
-
// If the user runs `hs project dev --local-all`, the flag is set to true.
|
|
60
|
-
// By INBOUND, we will remove the flag and make the dev server handle both extensions
|
|
61
|
-
// and app functions locally.
|
|
62
|
-
alpha = false,
|
|
63
58
|
debug = false,
|
|
64
59
|
accountId,
|
|
65
60
|
httpClient,
|
|
@@ -68,7 +63,6 @@ class DevModeInterface {
|
|
|
68
63
|
extensionConfig,
|
|
69
64
|
logger,
|
|
70
65
|
}) {
|
|
71
|
-
this.alpha = alpha;
|
|
72
66
|
this.debug = debug;
|
|
73
67
|
this.accountId = accountId;
|
|
74
68
|
this.httpClient = httpClient;
|
|
@@ -111,7 +105,6 @@ class DevModeInterface {
|
|
|
111
105
|
app: { path: appPath },
|
|
112
106
|
accountId: this.accountId,
|
|
113
107
|
httpClient: this.httpClient,
|
|
114
|
-
enabled: !!this.alpha,
|
|
115
108
|
};
|
|
116
109
|
|
|
117
110
|
this.shutdown = await startDevMode({
|
package/lib/build.js
CHANGED
|
@@ -52,7 +52,7 @@ async function buildSingleExtension({
|
|
|
52
52
|
rollupOptions: {
|
|
53
53
|
...ROLLUP_OPTIONS,
|
|
54
54
|
plugins: [
|
|
55
|
-
manifestPlugin({
|
|
55
|
+
manifestPlugin({ output, logger }),
|
|
56
56
|
codeInjectionPlugin({ file }),
|
|
57
57
|
],
|
|
58
58
|
},
|
|
@@ -75,12 +75,16 @@ async function remoteBuild(
|
|
|
75
75
|
throw new Error(`${extensionErrorBaseMessage} ${fileInfo.ext}`);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
const output = getUrlSafeFileName(entryPoint);
|
|
78
79
|
await buildSingleExtension({
|
|
79
80
|
file: entryPoint,
|
|
81
|
+
outputFileName: output,
|
|
80
82
|
outputDir,
|
|
83
|
+
plugins: {
|
|
84
|
+
rollup: [manifestPlugin({ minify: true, output, logger })],
|
|
85
|
+
},
|
|
81
86
|
minify: true,
|
|
82
87
|
root,
|
|
83
|
-
logger
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
90
|
|
package/lib/dev.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
|
-
function codeInjectionPlugin() {
|
|
3
|
+
function codeInjectionPlugin(options = {}) {
|
|
4
|
+
const { file, root = process.cwd() } = options;
|
|
4
5
|
return {
|
|
5
6
|
name: 'ui-extensions-code-injection-plugin',
|
|
6
7
|
enforce: 'post', // run after default rollup plugins
|
|
7
|
-
transform(code,
|
|
8
|
-
const
|
|
8
|
+
transform(code, fileBeingTransformed) {
|
|
9
|
+
const absoluteFilePath = path.isAbsolute(file)
|
|
10
|
+
? file
|
|
11
|
+
: path.join(root, file);
|
|
9
12
|
|
|
10
|
-
if (
|
|
13
|
+
if (fileBeingTransformed !== absoluteFilePath) {
|
|
11
14
|
return { code, map: null }; // Not the file we care about, return the same code
|
|
12
15
|
}
|
|
13
16
|
|
|
@@ -2,7 +2,6 @@ const { ROLLUP_OPTIONS, WEBSOCKET_MESSAGE_VERSION } = require('../constants');
|
|
|
2
2
|
const { build } = require('vite');
|
|
3
3
|
const manifestPlugin = require('./manifestPlugin');
|
|
4
4
|
const { stripAnsiColorCodes } = require('../utils');
|
|
5
|
-
const codeInjectionPlugin = require('./codeInjectionPlugin');
|
|
6
5
|
|
|
7
6
|
function devBuildPlugin(options = {}) {
|
|
8
7
|
const { extensionConfig, outputDir, baseMessage, logger } = options;
|
|
@@ -66,7 +65,6 @@ function devBuildPlugin(options = {}) {
|
|
|
66
65
|
output: extensionConfig.output,
|
|
67
66
|
logger,
|
|
68
67
|
}),
|
|
69
|
-
codeInjectionPlugin({ file: extensionConfig.data.module.file }),
|
|
70
68
|
],
|
|
71
69
|
output: {
|
|
72
70
|
...ROLLUP_OPTIONS.output,
|
|
@@ -103,7 +101,7 @@ function devBuildPlugin(options = {}) {
|
|
|
103
101
|
});
|
|
104
102
|
});
|
|
105
103
|
localServer.ws.on('build', async () => {
|
|
106
|
-
logger.
|
|
104
|
+
logger.debug('Browser has requested a build, rebuilding');
|
|
107
105
|
const successful = await devBuild(localServer);
|
|
108
106
|
if (successful) {
|
|
109
107
|
server.ws.send({
|
|
@@ -121,12 +119,14 @@ function devBuildPlugin(options = {}) {
|
|
|
121
119
|
return [];
|
|
122
120
|
}
|
|
123
121
|
|
|
122
|
+
logger.info(`Extension ${extensionConfig.data.title} updated, compiled`);
|
|
123
|
+
|
|
124
124
|
if (server.ws.clients.size === 0) {
|
|
125
|
-
logger.
|
|
125
|
+
logger.debug('Bundle updated, no browsers connected to notify');
|
|
126
126
|
return [];
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
logger.
|
|
129
|
+
logger.debug('Bundle updated, notifying connected browsers');
|
|
130
130
|
server.ws.send({
|
|
131
131
|
...versionedBaseMessage,
|
|
132
132
|
event: 'update',
|
|
@@ -137,7 +137,7 @@ function devBuildPlugin(options = {}) {
|
|
|
137
137
|
if (error) {
|
|
138
138
|
logger.error(error);
|
|
139
139
|
}
|
|
140
|
-
logger.
|
|
140
|
+
logger.debug('Sending shutdown message to connected browsers');
|
|
141
141
|
if (localServer && localServer.ws) {
|
|
142
142
|
localServer.ws.send({
|
|
143
143
|
...versionedBaseMessage,
|
package/lib/server.js
CHANGED
|
@@ -21,22 +21,18 @@ function startDevServer({
|
|
|
21
21
|
app.use(cors());
|
|
22
22
|
app.use(express.static(outputDir));
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
AppFunctionExecutionService({ ...functionsConfig, logger })
|
|
30
|
-
);
|
|
31
|
-
logger.info('Serving app functions locally');
|
|
32
|
-
}
|
|
24
|
+
app.use(
|
|
25
|
+
'/api/crm-extensibility/execution/internal/v3',
|
|
26
|
+
AppFunctionExecutionService({ ...functionsConfig, logger })
|
|
27
|
+
);
|
|
28
|
+
logger.info('Serving app functions locally');
|
|
33
29
|
|
|
34
30
|
const endpointsAdded = extensionsService.add(
|
|
35
31
|
app,
|
|
36
32
|
webSocketPort,
|
|
37
33
|
outputDir,
|
|
38
34
|
baseMessage,
|
|
39
|
-
|
|
35
|
+
SERVER_CAPABILITIES
|
|
40
36
|
);
|
|
41
37
|
|
|
42
38
|
endpointsAdded.forEach(endpoint => {
|
|
@@ -54,7 +50,7 @@ function startDevServer({
|
|
|
54
50
|
await viteDevServer.pluginContainer.close();
|
|
55
51
|
// Stop new connections to express server
|
|
56
52
|
server.close(() => {});
|
|
57
|
-
logger.info('
|
|
53
|
+
logger.info('Extension dev server done cleaning up');
|
|
58
54
|
};
|
|
59
55
|
}
|
|
60
56
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/ui-extensions-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@hubspot/app-functions-dev-server": "^0.
|
|
36
|
+
"@hubspot/app-functions-dev-server": "^0.7.0",
|
|
37
37
|
"command-line-args": "^5.2.1",
|
|
38
38
|
"command-line-usage": "^7.0.1",
|
|
39
39
|
"console-log-colors": "^0.4.0",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"optional": true
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "60f780b26b92ab097b24f162bf485fde5fd26528"
|
|
71
71
|
}
|