@hubspot/ui-extensions-dev-server 0.8.37 → 0.8.39
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/dist/lib/DevModeInterface.js +9 -9
- package/dist/lib/ast.js +1 -2
- package/dist/lib/build.js +8 -8
- package/dist/lib/config.js +6 -7
- package/dist/lib/dev.js +1 -2
- package/dist/lib/plugins/codeBlockingPlugin.js +1 -1
- package/dist/lib/plugins/devBuildPlugin.js +2 -2
- package/dist/lib/plugins/manifestPlugin.js +1 -1
- package/dist/lib/plugins/relevantModulesPlugin.js +1 -2
- package/dist/lib/server.js +4 -4
- package/dist/lib/utils.js +8 -8
- package/package.json +3 -3
|
@@ -85,9 +85,9 @@ class DevModeInterface {
|
|
|
85
85
|
this.isConfigured = false;
|
|
86
86
|
this.isRunning = false;
|
|
87
87
|
}
|
|
88
|
-
setup(
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
setup(_a) {
|
|
89
|
+
return __awaiter(this, arguments, void 0, function* ({ components, onUploadRequired, promptUser, logger, urls, setActiveApp, }) {
|
|
90
|
+
var _b, _c, _d;
|
|
91
91
|
logger.debug('Setup function was invoked', { components, urls });
|
|
92
92
|
if (this.isConfigured) {
|
|
93
93
|
logger.debug('Dev server has already been configured, skipping');
|
|
@@ -124,7 +124,7 @@ class DevModeInterface {
|
|
|
124
124
|
}
|
|
125
125
|
this.isConfigured = true;
|
|
126
126
|
if (typeof setActiveApp === 'function') {
|
|
127
|
-
yield setActiveApp((
|
|
127
|
+
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);
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
130
|
}
|
|
@@ -141,9 +141,9 @@ class DevModeInterface {
|
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
start(
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
start(_a) {
|
|
145
|
+
return __awaiter(this, arguments, void 0, function* ({ requestPorts, accountId, projectConfig }) {
|
|
146
|
+
var _b, _c, _d, _e;
|
|
147
147
|
this.logger.debug('Start function was invoked', {
|
|
148
148
|
accountId,
|
|
149
149
|
projectConfig,
|
|
@@ -167,7 +167,7 @@ class DevModeInterface {
|
|
|
167
167
|
this.logger.debug('Call to port manager failed, using default ports');
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
const { proxy: localDevUrlMapping } = (0, config_1.loadLocalConfig)(((
|
|
170
|
+
const { proxy: localDevUrlMapping } = (0, config_1.loadLocalConfig)(((_c = (_b = this.configs) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.path) || '', this.logger) || {};
|
|
171
171
|
this.devServerState = new DevServerState_1.DevServerState({
|
|
172
172
|
localDevUrlMapping,
|
|
173
173
|
extensionConfigs: this.configs,
|
|
@@ -177,7 +177,7 @@ class DevModeInterface {
|
|
|
177
177
|
webSocketPort,
|
|
178
178
|
logger: this.logger,
|
|
179
179
|
urls: this.urls,
|
|
180
|
-
appConfig: (
|
|
180
|
+
appConfig: (_e = (_d = this.configs) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.appConfig,
|
|
181
181
|
});
|
|
182
182
|
this.shutdown = yield (0, dev_1.startDevMode)(this.devServerState);
|
|
183
183
|
const { extensionsMetadata } = this.devServerState;
|
package/dist/lib/ast.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable hubspot-dev/no-unsupported-ts-syntax */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.traverseAbstractSyntaxTree =
|
|
4
|
+
exports.traverseAbstractSyntaxTree = traverseAbstractSyntaxTree;
|
|
5
5
|
// @ts-expect-error no type defs
|
|
6
6
|
const estraverse_1 = require("estraverse");
|
|
7
7
|
function _isVariableImported(node, variableName) {
|
|
@@ -62,4 +62,3 @@ function traverseAbstractSyntaxTree(ast, checks) {
|
|
|
62
62
|
});
|
|
63
63
|
return state;
|
|
64
64
|
}
|
|
65
|
-
exports.traverseAbstractSyntaxTree = traverseAbstractSyntaxTree;
|
package/dist/lib/build.js
CHANGED
|
@@ -12,7 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.extensionErrorBaseMessage = void 0;
|
|
16
|
+
exports.buildSingleExtension = buildSingleExtension;
|
|
17
|
+
exports.remoteBuild = remoteBuild;
|
|
16
18
|
const vite_1 = require("vite");
|
|
17
19
|
const constants_1 = require("./constants");
|
|
18
20
|
const manifestPlugin_1 = __importDefault(require("./plugins/manifestPlugin"));
|
|
@@ -22,9 +24,9 @@ const codeBlockingPlugin_1 = __importDefault(require("./plugins/codeBlockingPlug
|
|
|
22
24
|
const friendlyLoggingPlugin_1 = __importDefault(require("./plugins/friendlyLoggingPlugin"));
|
|
23
25
|
const allowedExtensions = ['.js', '.ts', '.tsx', '.jsx'];
|
|
24
26
|
exports.extensionErrorBaseMessage = `Supported file extensions are [${allowedExtensions.join(', ')}], received:`;
|
|
25
|
-
function buildSingleExtension(
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
function buildSingleExtension(_a) {
|
|
28
|
+
return __awaiter(this, arguments, void 0, function* ({ file, outputDir = constants_1.OUTPUT_DIR, emptyOutDir = true, minify = false, root = process.cwd(), // This is the vite default, so using that as our default
|
|
29
|
+
logLevel = 'info', }) {
|
|
28
30
|
const output = (0, utils_1.getUrlSafeFileName)(file);
|
|
29
31
|
yield (0, vite_1.build)({
|
|
30
32
|
logLevel,
|
|
@@ -51,9 +53,8 @@ logLevel = 'info', }) {
|
|
|
51
53
|
});
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
|
-
|
|
55
|
-
function
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
function remoteBuild(root_1, entryPoint_1) {
|
|
57
|
+
return __awaiter(this, arguments, void 0, function* (root, entryPoint, outputDir = constants_1.OUTPUT_DIR, logLevel) {
|
|
57
58
|
const fileInfo = path_1.default.parse(entryPoint);
|
|
58
59
|
if (!allowedExtensions.includes(fileInfo.ext)) {
|
|
59
60
|
throw new Error(`${exports.extensionErrorBaseMessage} ${fileInfo.ext}`);
|
|
@@ -67,4 +68,3 @@ function remoteBuild(root, entryPoint, outputDir = constants_1.OUTPUT_DIR, logLe
|
|
|
67
68
|
});
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
|
-
exports.remoteBuild = remoteBuild;
|
package/dist/lib/config.js
CHANGED
|
@@ -5,7 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
8
|
+
exports.loadConfigByPath = loadConfigByPath;
|
|
9
|
+
exports.validateCardConfig = validateCardConfig;
|
|
10
|
+
exports.loadExtensionConfig = loadExtensionConfig;
|
|
11
|
+
exports.validateProxyConfigKey = validateProxyConfigKey;
|
|
12
|
+
exports.validateProxyConfigValue = validateProxyConfigValue;
|
|
13
|
+
exports.loadLocalConfig = loadLocalConfig;
|
|
9
14
|
const fs_1 = __importDefault(require("fs"));
|
|
10
15
|
const path_1 = __importDefault(require("path"));
|
|
11
16
|
const utils_1 = require("./utils");
|
|
@@ -13,7 +18,6 @@ function loadConfigByPath(configPath) {
|
|
|
13
18
|
const source = fs_1.default.readFileSync(configPath).toString();
|
|
14
19
|
return JSON.parse(source);
|
|
15
20
|
}
|
|
16
|
-
exports.loadConfigByPath = loadConfigByPath;
|
|
17
21
|
function validateCardConfig(config) {
|
|
18
22
|
if (!config || typeof config !== 'object') {
|
|
19
23
|
return new Error('Card config must be an object');
|
|
@@ -50,7 +54,6 @@ function validateCardConfig(config) {
|
|
|
50
54
|
}
|
|
51
55
|
return true;
|
|
52
56
|
}
|
|
53
|
-
exports.validateCardConfig = validateCardConfig;
|
|
54
57
|
function loadExtensionConfig(appConfig, appPath) {
|
|
55
58
|
var _a, _b;
|
|
56
59
|
const crmCardsSubConfigFiles = (_b = (_a = appConfig === null || appConfig === void 0 ? void 0 : appConfig.extensions) === null || _a === void 0 ? void 0 : _a.crm) === null || _b === void 0 ? void 0 : _b.cards;
|
|
@@ -81,7 +84,6 @@ function loadExtensionConfig(appConfig, appPath) {
|
|
|
81
84
|
});
|
|
82
85
|
return outputConfig;
|
|
83
86
|
}
|
|
84
|
-
exports.loadExtensionConfig = loadExtensionConfig;
|
|
85
87
|
function validateProxyConfigKey(urlKey, logger, localConfigPath) {
|
|
86
88
|
try {
|
|
87
89
|
const url = new URL(urlKey);
|
|
@@ -93,7 +95,6 @@ function validateProxyConfigKey(urlKey, logger, localConfigPath) {
|
|
|
93
95
|
logger.warn(`The key "${urlKey}" in "${localConfigPath}" is an invalid url`);
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
|
-
exports.validateProxyConfigKey = validateProxyConfigKey;
|
|
97
98
|
function validateProxyConfigValue(value, key, logger, localConfigPath) {
|
|
98
99
|
try {
|
|
99
100
|
// eslint-disable-next-line no-new
|
|
@@ -103,7 +104,6 @@ function validateProxyConfigValue(value, key, logger, localConfigPath) {
|
|
|
103
104
|
logger.warn(`The value "${value}" for key "${key}" in "${localConfigPath}" is an invalid url`);
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
|
-
exports.validateProxyConfigValue = validateProxyConfigValue;
|
|
107
107
|
function loadLocalConfig(appPath, logger) {
|
|
108
108
|
const localConfigFilename = 'local.json';
|
|
109
109
|
const localConfigPath = path_1.default.join(appPath, localConfigFilename);
|
|
@@ -125,4 +125,3 @@ function loadLocalConfig(appPath, logger) {
|
|
|
125
125
|
return undefined;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
exports.loadLocalConfig = loadLocalConfig;
|
package/dist/lib/dev.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.startDevMode =
|
|
15
|
+
exports.startDevMode = startDevMode;
|
|
16
16
|
const vite_1 = require("vite");
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const server_1 = __importDefault(require("./server"));
|
|
@@ -73,4 +73,3 @@ function startDevMode(devServerState) {
|
|
|
73
73
|
return shutdownServer;
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
exports.startDevMode = startDevMode;
|
|
@@ -6,7 +6,7 @@ const ast_1 = require("../ast");
|
|
|
6
6
|
const codeBlockingPlugin = ({ logger }) => {
|
|
7
7
|
return {
|
|
8
8
|
name: 'ui-extensions-code-blocking-plugin',
|
|
9
|
-
enforce: 'post',
|
|
9
|
+
enforce: 'post', // run after default rollup plugins
|
|
10
10
|
transform(code, filename) {
|
|
11
11
|
if ((0, utils_1.isNodeModule)(filename)) {
|
|
12
12
|
return { code, map: null }; // We don't want to parse node modules
|
|
@@ -68,7 +68,7 @@ const devBuildPlugin = (options) => {
|
|
|
68
68
|
} }));
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
const devBuild = (
|
|
71
|
+
const devBuild = (server_1, extensionMetadata_1, ...args_1) => __awaiter(void 0, [server_1, extensionMetadata_1, ...args_1], void 0, function* (server, extensionMetadata, emptyOutDir = false) {
|
|
72
72
|
try {
|
|
73
73
|
const { config: extensionConfig } = extensionMetadata;
|
|
74
74
|
yield (0, vite_1.build)({
|
|
@@ -150,7 +150,7 @@ const devBuildPlugin = (options) => {
|
|
|
150
150
|
yield devBuild(localServer, devServerState.extensionsMetadata[i], i === 0);
|
|
151
151
|
}
|
|
152
152
|
}),
|
|
153
|
-
handleHotUpdate: (
|
|
153
|
+
handleHotUpdate: (_a) => __awaiter(void 0, [_a], void 0, function* ({ file, server }) {
|
|
154
154
|
// If the file is not in the relevantModules list, it's update is inconsequential
|
|
155
155
|
const extensionsToRebuild = devServerState.extensionsMetadata.filter((metadata) => {
|
|
156
156
|
const { config } = metadata;
|
|
@@ -16,7 +16,7 @@ const EXTENSIONS_PATH = 'src/app/extensions/';
|
|
|
16
16
|
const manifestPlugin = (options) => {
|
|
17
17
|
return {
|
|
18
18
|
name: 'ui-extensions-manifest-generation-plugin',
|
|
19
|
-
enforce: 'post',
|
|
19
|
+
enforce: 'post', // run after default rollup plugins
|
|
20
20
|
generateBundle(_rollupOptions, bundle) {
|
|
21
21
|
const { output, minify = false, extensionPath = process.cwd(), logger, } = options;
|
|
22
22
|
try {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRelevantModules =
|
|
3
|
+
exports.getRelevantModules = getRelevantModules;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const relevantModules = {};
|
|
6
6
|
function getRelevantModules(output) {
|
|
7
7
|
return relevantModules[output] || [];
|
|
8
8
|
}
|
|
9
|
-
exports.getRelevantModules = getRelevantModules;
|
|
10
9
|
const relevantModulesPlugin = ({ output, logger }) => {
|
|
11
10
|
return {
|
|
12
11
|
name: 'ui-extensions-relevant-modules-plugin',
|
package/dist/lib/server.js
CHANGED
|
@@ -31,9 +31,9 @@ function listen(app, port) {
|
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
function startDevServer(
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
function startDevServer(_a) {
|
|
35
|
+
return __awaiter(this, arguments, void 0, function* ({ devServerState, viteDevServer, }) {
|
|
36
|
+
var _b;
|
|
37
37
|
const app = (0, express_1.default)();
|
|
38
38
|
// Setup middleware
|
|
39
39
|
app.use((0, cors_1.default)());
|
|
@@ -75,7 +75,7 @@ function startDevServer({ devServerState, viteDevServer, }) {
|
|
|
75
75
|
}
|
|
76
76
|
throw new Error(e);
|
|
77
77
|
}
|
|
78
|
-
(
|
|
78
|
+
(_b = devServerState.extensionsMetadata) === null || _b === void 0 ? void 0 : _b.forEach((metadata) => {
|
|
79
79
|
const { baseMessage } = metadata;
|
|
80
80
|
devServerState.logger.debug(`Listening at ${baseMessage.callback}`);
|
|
81
81
|
});
|
package/dist/lib/utils.js
CHANGED
|
@@ -3,7 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.UnhandledPlatformVersionError = void 0;
|
|
7
|
+
exports.getUrlSafeFileName = getUrlSafeFileName;
|
|
8
|
+
exports.stripAnsiColorCodes = stripAnsiColorCodes;
|
|
9
|
+
exports.loadManifest = loadManifest;
|
|
10
|
+
exports.buildSourceId = buildSourceId;
|
|
11
|
+
exports.isNodeModule = isNodeModule;
|
|
12
|
+
exports.throwUnhandledPlatformVersionError = throwUnhandledPlatformVersionError;
|
|
13
|
+
exports.extractAllowedUrls = extractAllowedUrls;
|
|
7
14
|
const path_1 = __importDefault(require("path"));
|
|
8
15
|
const fs_1 = __importDefault(require("fs"));
|
|
9
16
|
const constants_1 = require("./constants");
|
|
@@ -11,7 +18,6 @@ function getUrlSafeFileName(filePath) {
|
|
|
11
18
|
const { name } = path_1.default.parse(filePath);
|
|
12
19
|
return encodeURIComponent(`${name}.js`);
|
|
13
20
|
}
|
|
14
|
-
exports.getUrlSafeFileName = getUrlSafeFileName;
|
|
15
21
|
// Strips ANSI color codes out of strings because we don't want to pass them to the browser
|
|
16
22
|
function stripAnsiColorCodes(stringWithColorCodes) {
|
|
17
23
|
if (!stringWithColorCodes) {
|
|
@@ -21,7 +27,6 @@ function stripAnsiColorCodes(stringWithColorCodes) {
|
|
|
21
27
|
// eslint-disable-next-line no-control-regex
|
|
22
28
|
/[\u001b][[]*([0-9]{1,4};?)*[m]/g, '');
|
|
23
29
|
}
|
|
24
|
-
exports.stripAnsiColorCodes = stripAnsiColorCodes;
|
|
25
30
|
function loadManifest(outputDir, output) {
|
|
26
31
|
try {
|
|
27
32
|
return JSON.parse(fs_1.default
|
|
@@ -32,14 +37,12 @@ function loadManifest(outputDir, output) {
|
|
|
32
37
|
return {};
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
|
-
exports.loadManifest = loadManifest;
|
|
36
40
|
function buildSourceId(appConfig, extensionConfig) {
|
|
37
41
|
if (appConfig.uid && extensionConfig.data.uid) {
|
|
38
42
|
return `${appConfig.uid}::${extensionConfig.data.uid}`;
|
|
39
43
|
}
|
|
40
44
|
return null;
|
|
41
45
|
}
|
|
42
|
-
exports.buildSourceId = buildSourceId;
|
|
43
46
|
function isNodeModule(filepath) {
|
|
44
47
|
if (!filepath) {
|
|
45
48
|
return false;
|
|
@@ -47,7 +50,6 @@ function isNodeModule(filepath) {
|
|
|
47
50
|
const directory = path_1.default.parse(filepath).dir;
|
|
48
51
|
return directory.includes('node_modules');
|
|
49
52
|
}
|
|
50
|
-
exports.isNodeModule = isNodeModule;
|
|
51
53
|
class UnhandledPlatformVersionError extends Error {
|
|
52
54
|
constructor(platformVersion) {
|
|
53
55
|
super(`Unsupported platform version "${platformVersion}"`);
|
|
@@ -57,11 +59,9 @@ exports.UnhandledPlatformVersionError = UnhandledPlatformVersionError;
|
|
|
57
59
|
function throwUnhandledPlatformVersionError(platformVersion) {
|
|
58
60
|
throw new UnhandledPlatformVersionError(platformVersion);
|
|
59
61
|
}
|
|
60
|
-
exports.throwUnhandledPlatformVersionError = throwUnhandledPlatformVersionError;
|
|
61
62
|
function extractAllowedUrls(appConfig) {
|
|
62
63
|
if (!appConfig || !('allowedUrls' in appConfig) || !appConfig.allowedUrls) {
|
|
63
64
|
return [];
|
|
64
65
|
}
|
|
65
66
|
return appConfig.allowedUrls;
|
|
66
67
|
}
|
|
67
|
-
exports.extractAllowedUrls = extractAllowedUrls;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/ui-extensions-dev-server",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.39",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@hubspot/app-functions-dev-server": "0.8.
|
|
27
|
+
"@hubspot/app-functions-dev-server": "0.8.39",
|
|
28
28
|
"cors": "^2.8.5",
|
|
29
29
|
"detect-port": "1.5.1",
|
|
30
30
|
"estraverse": "^5.3.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"optional": true
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "3dbfe0afee58682d51c4a5eb7e0e40a6e3920631"
|
|
67
67
|
}
|