@hubspot/ui-extensions-dev-server 0.8.11 → 0.8.12
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.d.ts +4 -8
- package/dist/lib/DevModeInterface.js +22 -10
- package/dist/lib/build.js +1 -1
- package/dist/lib/constants.d.ts +3 -1
- package/dist/lib/constants.js +6 -2
- package/dist/lib/plugins/devBuildPlugin.js +1 -0
- package/dist/lib/plugins/manifestPlugin.d.ts +2 -0
- package/dist/lib/plugins/manifestPlugin.js +2 -4
- package/dist/lib/types.d.ts +35 -2
- package/package.json +6 -9
- package/dist/lib/plugins/codeInjectionPlugin.d.ts +0 -8
- package/dist/lib/plugins/codeInjectionPlugin.js +0 -30
- package/dist/lib/self.d.ts +0 -0
- package/dist/lib/self.js +0 -4
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExtensionConfig, Logger, PlatformVersion, ProjectComponentMap, ProjectConfig } from './types';
|
|
2
2
|
import { PromptModule } from 'inquirer';
|
|
3
3
|
import { DevServerState } from './DevServerState';
|
|
4
4
|
interface SetupArguments {
|
|
5
5
|
components: ProjectComponentMap;
|
|
6
|
-
extensionConfig?: ExtensionConfig;
|
|
7
6
|
onUploadRequired?: VoidFunction;
|
|
8
7
|
promptUser: PromptModule;
|
|
9
8
|
logger: Logger;
|
|
@@ -12,11 +11,6 @@ interface SetupArguments {
|
|
|
12
11
|
web: string;
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
|
-
interface ProjectConfig {
|
|
16
|
-
name: string;
|
|
17
|
-
srcDir: string;
|
|
18
|
-
platformVersion?: PlatformVersion;
|
|
19
|
-
}
|
|
20
14
|
interface StartArguments {
|
|
21
15
|
accountId?: number;
|
|
22
16
|
requestPorts?: (requestPortsData: Array<{
|
|
@@ -38,9 +32,11 @@ declare class DevModeInterface {
|
|
|
38
32
|
shutdown?: () => Promise<void>;
|
|
39
33
|
logger: Logger;
|
|
40
34
|
urls?: SetupArguments['urls'];
|
|
35
|
+
isConfigured?: boolean;
|
|
36
|
+
isRunning?: boolean;
|
|
41
37
|
_generateAppExtensionMappings(components: ProjectComponentMap): AppExtensionMapping[];
|
|
42
38
|
_getPlatformVersion(projectConfig?: ProjectConfig): PlatformVersion;
|
|
43
|
-
setup({ components,
|
|
39
|
+
setup({ components, onUploadRequired, promptUser, logger, urls, }: SetupArguments): Promise<void>;
|
|
44
40
|
fileChange(filePath: string, __event: unknown): Promise<void>;
|
|
45
41
|
start({ requestPorts, accountId, projectConfig }: StartArguments): Promise<void>;
|
|
46
42
|
cleanup(): Promise<void>;
|
|
@@ -39,10 +39,9 @@ class DevModeInterface {
|
|
|
39
39
|
// Loop over all of the app configs that are passed in
|
|
40
40
|
const allComponentNames = Object.keys(components);
|
|
41
41
|
return allComponentNames.reduce((appExtensionMappings, componentName) => {
|
|
42
|
-
var _a, _b;
|
|
43
42
|
const component = components[componentName];
|
|
44
|
-
if (!(
|
|
45
|
-
return appExtensionMappings; // It's not
|
|
43
|
+
if (!constants_1.SUPPORTED_APP_TYPES.includes(component.type)) {
|
|
44
|
+
return appExtensionMappings; // It's not a modern app, skip it
|
|
46
45
|
}
|
|
47
46
|
// Load all of the extension configs for a particular app.json file
|
|
48
47
|
const extensionsConfigForApp = (0, config_1.loadExtensionConfig)(component.config, component.path);
|
|
@@ -72,15 +71,16 @@ class DevModeInterface {
|
|
|
72
71
|
return (0, utils_1.throwUnhandledPlatformVersionError)(platformVersion);
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
|
-
setup({ components,
|
|
74
|
+
setup({ components, onUploadRequired, promptUser, logger, urls, }) {
|
|
76
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
logger.debug('Setup function was invoked', { components, urls });
|
|
77
|
+
if (this.isConfigured) {
|
|
78
|
+
logger.debug('Dev server has already been configured, skipping');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
77
81
|
this.logger = logger;
|
|
78
82
|
this.onUploadRequired = onUploadRequired;
|
|
79
83
|
this.urls = urls;
|
|
80
|
-
if (extensionConfig) {
|
|
81
|
-
this.configs = [extensionConfig];
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
84
|
const choices = this._generateAppExtensionMappings(components);
|
|
85
85
|
if (choices.length === 0) {
|
|
86
86
|
throw new Error('No extensions to run');
|
|
@@ -107,6 +107,7 @@ class DevModeInterface {
|
|
|
107
107
|
});
|
|
108
108
|
this.configs = answers.extensions;
|
|
109
109
|
}
|
|
110
|
+
this.isConfigured = true;
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
// The contract is for this to be async, so eslint can chill
|
|
@@ -124,6 +125,14 @@ class DevModeInterface {
|
|
|
124
125
|
}
|
|
125
126
|
start({ requestPorts, accountId, projectConfig }) {
|
|
126
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
this.logger.debug('Start function was invoked', {
|
|
129
|
+
accountId,
|
|
130
|
+
projectConfig,
|
|
131
|
+
});
|
|
132
|
+
if (this.isRunning) {
|
|
133
|
+
this.logger.debug('Dev server is already running, not starting again');
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
127
136
|
let expressPort = constants_1.EXPRESS_DEFAULT_PORT;
|
|
128
137
|
let webSocketPort = constants_1.WEBSOCKET_DEFAULT_PORT;
|
|
129
138
|
if (requestPorts) {
|
|
@@ -149,16 +158,19 @@ class DevModeInterface {
|
|
|
149
158
|
urls: this.urls,
|
|
150
159
|
});
|
|
151
160
|
this.shutdown = yield (0, dev_1.startDevMode)(this.devServerState);
|
|
152
|
-
this.devServerState
|
|
161
|
+
const { extensionsMetadata } = this.devServerState;
|
|
162
|
+
extensionsMetadata.forEach((metadata) => {
|
|
153
163
|
const { config: { data: { title, appName }, }, } = metadata;
|
|
154
164
|
this.logger.info(`Running extension '${title}' from app '${appName}'`);
|
|
155
165
|
});
|
|
166
|
+
this.isRunning = true;
|
|
156
167
|
});
|
|
157
168
|
}
|
|
158
169
|
cleanup() {
|
|
159
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
if (this.shutdown) {
|
|
171
|
+
if (this.shutdown && this.isRunning) {
|
|
161
172
|
yield this.shutdown();
|
|
173
|
+
this.isRunning = false;
|
|
162
174
|
}
|
|
163
175
|
});
|
|
164
176
|
}
|
package/dist/lib/build.js
CHANGED
|
@@ -39,7 +39,7 @@ function buildSingleExtension({ file, outputDir = constants_1.OUTPUT_DIR, emptyO
|
|
|
39
39
|
fileName: () => output,
|
|
40
40
|
},
|
|
41
41
|
rollupOptions: Object.assign(Object.assign({}, constants_1.ROLLUP_OPTIONS), { plugins: [
|
|
42
|
-
(0, manifestPlugin_1.default)({ output, extensionPath: root }),
|
|
42
|
+
(0, manifestPlugin_1.default)({ output, extensionPath: root, logger: console }),
|
|
43
43
|
(0, friendlyLoggingPlugin_1.default)({ logger: console }),
|
|
44
44
|
(0, codeBlockingPlugin_1.default)({ logger: console }),
|
|
45
45
|
] }),
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const OUTPUT_DIR = "dist";
|
|
2
|
-
export declare const MAIN_APP_CONFIG = "app.json";
|
|
3
2
|
export declare const MANIFEST_FILE = "manifest.json";
|
|
4
3
|
export declare const EXPRESS_SERVER_ID = "ui-extensions-dev-server";
|
|
5
4
|
export declare const VITE_DEV_SERVER_ID = "ui-extensions-vite-dev-server";
|
|
@@ -22,3 +21,6 @@ export declare const PLATFORM_VERSION: {
|
|
|
22
21
|
readonly V20231: "2023.1";
|
|
23
22
|
readonly V20232: "2023.2";
|
|
24
23
|
};
|
|
24
|
+
export declare const PUBLIC_APP = "public-app";
|
|
25
|
+
export declare const PRIVATE_APP = "private-app";
|
|
26
|
+
export declare const SUPPORTED_APP_TYPES: string[];
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PLATFORM_VERSION = exports.SERVER_CAPABILITIES = exports.WEBSOCKET_MESSAGE_VERSION = exports.EXTENSIONS_MESSAGE_VERSION = exports.ROLLUP_OPTIONS = exports.WEBSOCKET_DEFAULT_PORT = exports.EXPRESS_DEFAULT_PORT = exports.VITE_DEV_SERVER_ID = exports.EXPRESS_SERVER_ID = exports.MANIFEST_FILE = exports.
|
|
3
|
+
exports.SUPPORTED_APP_TYPES = exports.PRIVATE_APP = exports.PUBLIC_APP = exports.PLATFORM_VERSION = exports.SERVER_CAPABILITIES = exports.WEBSOCKET_MESSAGE_VERSION = exports.EXTENSIONS_MESSAGE_VERSION = exports.ROLLUP_OPTIONS = exports.WEBSOCKET_DEFAULT_PORT = exports.EXPRESS_DEFAULT_PORT = exports.VITE_DEV_SERVER_ID = exports.EXPRESS_SERVER_ID = exports.MANIFEST_FILE = exports.OUTPUT_DIR = void 0;
|
|
4
4
|
exports.OUTPUT_DIR = 'dist';
|
|
5
|
-
exports.MAIN_APP_CONFIG = 'app.json';
|
|
6
5
|
exports.MANIFEST_FILE = 'manifest.json';
|
|
7
6
|
exports.EXPRESS_SERVER_ID = 'ui-extensions-dev-server';
|
|
8
7
|
exports.VITE_DEV_SERVER_ID = 'ui-extensions-vite-dev-server';
|
|
@@ -32,3 +31,8 @@ exports.PLATFORM_VERSION = {
|
|
|
32
31
|
V20231: '2023.1',
|
|
33
32
|
V20232: '2023.2',
|
|
34
33
|
};
|
|
34
|
+
exports.PUBLIC_APP = 'public-app';
|
|
35
|
+
// You gotta be kidding me linter
|
|
36
|
+
// eslint-disable-next-line hubspot-dev/no-private-classes
|
|
37
|
+
exports.PRIVATE_APP = 'private-app';
|
|
38
|
+
exports.SUPPORTED_APP_TYPES = [exports.PUBLIC_APP, exports.PRIVATE_APP];
|
|
@@ -96,6 +96,7 @@ const devBuildPlugin = (options) => {
|
|
|
96
96
|
minify: false,
|
|
97
97
|
output: extensionConfig.output,
|
|
98
98
|
extensionPath: extensionConfig.extensionPath,
|
|
99
|
+
logger,
|
|
99
100
|
}),
|
|
100
101
|
(0, codeCheckingPlugin_1.default)({
|
|
101
102
|
output: path_1.default.join(devServerState.outputDir, extensionConfig.output),
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Rollup } from 'vite';
|
|
2
|
+
import { Logger } from '../types';
|
|
2
3
|
export interface ManifestPluginOptions {
|
|
3
4
|
output: string;
|
|
4
5
|
minify?: boolean;
|
|
5
6
|
extensionPath?: string;
|
|
7
|
+
logger: Logger;
|
|
6
8
|
}
|
|
7
9
|
export type ManifestPlugin = (options: ManifestPluginOptions) => Rollup.Plugin;
|
|
8
10
|
declare const manifestPlugin: ManifestPlugin;
|
|
@@ -9,8 +9,6 @@ const fs_1 = require("fs");
|
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
const constants_1 = require("../constants");
|
|
11
11
|
const path_2 = __importDefault(require("path"));
|
|
12
|
-
// @ts-expect-error no type defs for the logger
|
|
13
|
-
const logger_1 = require("@hubspot/cli-lib/logger");
|
|
14
12
|
const utils_1 = require("../utils");
|
|
15
13
|
const PACKAGE_LOCK_FILE = 'package-lock.json';
|
|
16
14
|
const PACKAGE_FILE = 'package.json';
|
|
@@ -20,7 +18,7 @@ const manifestPlugin = (options) => {
|
|
|
20
18
|
name: 'ui-extensions-manifest-generation-plugin',
|
|
21
19
|
enforce: 'post',
|
|
22
20
|
generateBundle(_rollupOptions, bundle) {
|
|
23
|
-
const { output, minify = false, extensionPath = process.cwd() } = options;
|
|
21
|
+
const { output, minify = false, extensionPath = process.cwd(), logger, } = options;
|
|
24
22
|
try {
|
|
25
23
|
const filename = path_2.default.parse(output).name;
|
|
26
24
|
const manifest = _generateManifestContents(bundle, extensionPath);
|
|
@@ -33,7 +31,7 @@ const manifestPlugin = (options) => {
|
|
|
33
31
|
});
|
|
34
32
|
}
|
|
35
33
|
catch (e) {
|
|
36
|
-
|
|
34
|
+
logger.warn(`\nUnable to write manifest file in ${output}, ${e}`);
|
|
37
35
|
}
|
|
38
36
|
},
|
|
39
37
|
};
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PLATFORM_VERSION } from './constants';
|
|
1
|
+
import { PLATFORM_VERSION, PRIVATE_APP, PUBLIC_APP } from './constants';
|
|
2
2
|
export interface ObjectTypes {
|
|
3
3
|
name: string;
|
|
4
4
|
}
|
|
@@ -26,7 +26,12 @@ export interface ExtensionConfigMap {
|
|
|
26
26
|
interface CardConfig {
|
|
27
27
|
file: string;
|
|
28
28
|
}
|
|
29
|
-
export interface
|
|
29
|
+
export interface ProjectConfig {
|
|
30
|
+
name: string;
|
|
31
|
+
srcDir: string;
|
|
32
|
+
platformVersion?: PlatformVersion;
|
|
33
|
+
}
|
|
34
|
+
export interface PrivateAppConfig {
|
|
30
35
|
name: string;
|
|
31
36
|
description: string;
|
|
32
37
|
scopes: string[];
|
|
@@ -38,7 +43,35 @@ export interface AppConfig {
|
|
|
38
43
|
};
|
|
39
44
|
uid?: string;
|
|
40
45
|
}
|
|
46
|
+
export interface PublicAppConfig {
|
|
47
|
+
name: string;
|
|
48
|
+
uid: string;
|
|
49
|
+
logo?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
allowedExternalUrls?: string[];
|
|
52
|
+
auth?: {
|
|
53
|
+
preventAdditionalScopes: boolean;
|
|
54
|
+
preventOptionalScopes: boolean;
|
|
55
|
+
redirectUrls: string[];
|
|
56
|
+
requiredScopes: string[];
|
|
57
|
+
optionalScopes: string[];
|
|
58
|
+
additionalScopes: string[];
|
|
59
|
+
};
|
|
60
|
+
support?: {
|
|
61
|
+
supportUrl: string;
|
|
62
|
+
supportEmail: string;
|
|
63
|
+
documentationUrl: string;
|
|
64
|
+
supportPhone: string;
|
|
65
|
+
};
|
|
66
|
+
extensions: {
|
|
67
|
+
crm: {
|
|
68
|
+
cards: CardConfig[];
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export type AppConfig = PrivateAppConfig | PublicAppConfig;
|
|
41
73
|
export interface ProjectComponent {
|
|
74
|
+
type: typeof PUBLIC_APP | typeof PRIVATE_APP;
|
|
42
75
|
config: AppConfig;
|
|
43
76
|
path: string;
|
|
44
77
|
}
|
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.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
"prepare": "npm run build",
|
|
11
11
|
"lint": "echo 'no lint step for @hubspot/ui-extensions-dev-server'",
|
|
12
12
|
"jest": "jest --watch",
|
|
13
|
-
"integration-test": "npm run
|
|
13
|
+
"integration-test-private-app": "npm run integration-test-private-app --prefix ./integrationTests/fixtures",
|
|
14
|
+
"integration-test-public-app": "npm run integration-test-public-app --prefix ./integrationTests/fixtures",
|
|
15
|
+
"integration-test": "npm run build && npm run integration-test-private-app && npm run integration-test-public-app"
|
|
14
16
|
},
|
|
15
17
|
"publishConfig": {
|
|
16
18
|
"access": "public"
|
|
17
19
|
},
|
|
18
20
|
"exports": {
|
|
19
|
-
".": "./dist/index.js"
|
|
20
|
-
"./self": "./dist/lib/self.js"
|
|
21
|
+
".": "./dist/index.js"
|
|
21
22
|
},
|
|
22
23
|
"files": [
|
|
23
24
|
"dist",
|
|
@@ -26,10 +27,6 @@
|
|
|
26
27
|
"license": "MIT",
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"@hubspot/app-functions-dev-server": "^0.8.11",
|
|
29
|
-
"@hubspot/cli-lib": "^4.1.6",
|
|
30
|
-
"command-line-args": "^5.2.1",
|
|
31
|
-
"command-line-usage": "^7.0.1",
|
|
32
|
-
"console-log-colors": "^0.4.0",
|
|
33
30
|
"cors": "^2.8.5",
|
|
34
31
|
"detect-port": "1.5.1",
|
|
35
32
|
"estraverse": "^5.3.0",
|
|
@@ -67,5 +64,5 @@
|
|
|
67
64
|
"optional": true
|
|
68
65
|
}
|
|
69
66
|
},
|
|
70
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "de63cea5e941c10de794210c1a095ae2468d6a9d"
|
|
71
68
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Rollup } from 'vite';
|
|
2
|
-
export interface CodeInjectionPluginOptions {
|
|
3
|
-
file: string;
|
|
4
|
-
root?: string;
|
|
5
|
-
}
|
|
6
|
-
export type CodeInjectionPlugin = (options: CodeInjectionPluginOptions) => Rollup.Plugin;
|
|
7
|
-
declare const codeInjectionPlugin: CodeInjectionPlugin;
|
|
8
|
-
export default codeInjectionPlugin;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const codeInjectionPlugin = (options) => {
|
|
8
|
-
const { file, root = process.cwd() } = options;
|
|
9
|
-
return {
|
|
10
|
-
name: 'ui-extensions-code-injection-plugin',
|
|
11
|
-
enforce: 'post',
|
|
12
|
-
transform(code, fileBeingTransformed) {
|
|
13
|
-
const absoluteFilePath = path_1.default.isAbsolute(file)
|
|
14
|
-
? file
|
|
15
|
-
: path_1.default.join(root, file);
|
|
16
|
-
if (fileBeingTransformed !== absoluteFilePath) {
|
|
17
|
-
return { code, map: null }; // Not the file we care about, return the same code
|
|
18
|
-
}
|
|
19
|
-
// Update the code to import the self script which houses our overrides
|
|
20
|
-
// This needs to be the first line in the source file so that the overrides get hoisted
|
|
21
|
-
// to the top of the generated source file
|
|
22
|
-
const updatedCode = `import "@hubspot/ui-extensions-dev-server/self"; ${code}`;
|
|
23
|
-
// Return the updated source code. We don't need to include the new code in the
|
|
24
|
-
// sourcemap because we don't want it to show up in the users code when they
|
|
25
|
-
// view the source mapped code in the browser
|
|
26
|
-
return { code: updatedCode, map: null };
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
exports.default = codeInjectionPlugin;
|
package/dist/lib/self.d.ts
DELETED
|
File without changes
|
package/dist/lib/self.js
DELETED