@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/dist/lib/bin/cli.js
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
17
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
-
const node_util_1 = require("node:util");
|
|
19
|
-
const node_child_process_1 = require("node:child_process");
|
|
20
|
-
const commander_1 = require("commander");
|
|
21
|
-
const ora_1 = __importDefault(require("ora"));
|
|
22
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
23
|
-
const build_1 = require("../build");
|
|
24
|
-
const program = new commander_1.Command()
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
import { exec } from 'node:child_process';
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import ora from 'ora';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { remoteBuild } from "../build.js";
|
|
10
|
+
const program = new Command()
|
|
25
11
|
.name('ui-extension-tools')
|
|
26
12
|
.alias('uie')
|
|
27
13
|
.description('Tools for managing and building HubSpot UI Extensions.');
|
|
@@ -49,34 +35,32 @@ program
|
|
|
49
35
|
.option('-v, --profile-variables <path>', 'path to a json file with profile variables')
|
|
50
36
|
.command('build <module>', { isDefault: true })
|
|
51
37
|
.description('Build extension source code.')
|
|
52
|
-
.action((module) =>
|
|
38
|
+
.action(async (module) => {
|
|
53
39
|
const options = getOptions(module);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
40
|
+
await runCommand('lockfile', options);
|
|
41
|
+
await runCommand('install', options);
|
|
42
|
+
await runCommand('build', options);
|
|
43
|
+
});
|
|
58
44
|
program.parse(process.argv);
|
|
59
|
-
function runCommand(command, options) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
});
|
|
45
|
+
async function runCommand(command, options) {
|
|
46
|
+
const { start, fn, success, error } = buildSteps[command];
|
|
47
|
+
const spinner = ora();
|
|
48
|
+
try {
|
|
49
|
+
spinner.start(start);
|
|
50
|
+
await fn(options);
|
|
51
|
+
spinner.succeed(chalk.green(success));
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
spinner.fail(chalk.red(error));
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
spinner.stop();
|
|
59
|
+
}
|
|
76
60
|
}
|
|
77
61
|
// Mirrors: https://git.hubteam.com/HubSpot/Artifactor/blob/f5cbea91d7a7dfb6278e878ae583e69022384fb5/ArtifactorFunctions/functions/node_18x/uie-remote-build/index.js#L59-L63
|
|
78
62
|
function build({ extensionRoot, extensionDist, entrypoint, profileVariables, }) {
|
|
79
|
-
return
|
|
63
|
+
return remoteBuild({
|
|
80
64
|
root: extensionRoot,
|
|
81
65
|
entryPoint: entrypoint,
|
|
82
66
|
outputDir: extensionDist,
|
|
@@ -86,43 +70,39 @@ function build({ extensionRoot, extensionDist, entrypoint, profileVariables, })
|
|
|
86
70
|
});
|
|
87
71
|
}
|
|
88
72
|
// Mirrors: https://git.hubteam.com/HubSpot/Artifactor/blob/f5cbea91d7a7dfb6278e878ae583e69022384fb5/ArtifactorFunctions/functions/node_18x/uie-remote-build/index.js#L53-L57
|
|
89
|
-
function installDeps(options) {
|
|
90
|
-
|
|
91
|
-
yield execAsync('npm ci --ignore-scripts --no-audit --no-optional --no-fund', options);
|
|
92
|
-
});
|
|
73
|
+
async function installDeps(options) {
|
|
74
|
+
await execAsync('npm ci --ignore-scripts --no-audit --no-optional --no-fund', options);
|
|
93
75
|
}
|
|
94
76
|
// Mirrors: https://git.hubteam.com/HubSpot/Artifactor/blob/f5cbea91d7a7dfb6278e878ae583e69022384fb5/ArtifactorFunctions/functions/node_18x/uie-remote-build/index.js#L131-L136
|
|
95
|
-
function generateLockfile(options) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
});
|
|
77
|
+
async function generateLockfile(options) {
|
|
78
|
+
const { extensionRoot, spinner } = options;
|
|
79
|
+
if (fs.existsSync(path.join(extensionRoot, 'package-lock.json'))) {
|
|
80
|
+
spinner.info('Existing lockfile found, skipping generation');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
spinner.info('No lockfile found, generating...');
|
|
84
|
+
await execAsync('npm install --package-lock-only', options);
|
|
85
|
+
}
|
|
106
86
|
}
|
|
107
87
|
function getOptions(modulePath) {
|
|
108
|
-
const entrypoint =
|
|
88
|
+
const entrypoint = path.isAbsolute(modulePath)
|
|
109
89
|
? modulePath
|
|
110
|
-
:
|
|
111
|
-
const extensionRoot =
|
|
112
|
-
const extensionDist =
|
|
113
|
-
const spinner = (
|
|
90
|
+
: path.resolve(process.cwd(), modulePath);
|
|
91
|
+
const extensionRoot = path.dirname(entrypoint);
|
|
92
|
+
const extensionDist = path.join(extensionRoot, 'dist');
|
|
93
|
+
const spinner = ora();
|
|
114
94
|
// The Artifactor changes related to this are not yet available.
|
|
115
95
|
// When it is, this will mirror the process where if applicable, a profile-variables.json file is available in the build bundle.
|
|
116
96
|
const programOptions = program.opts();
|
|
117
97
|
let profileVariables = {};
|
|
118
98
|
if (programOptions.profileVariables) {
|
|
119
99
|
const profileVariablePath = programOptions.profileVariables;
|
|
120
|
-
const profileVariableFullPath =
|
|
100
|
+
const profileVariableFullPath = path.isAbsolute(profileVariablePath)
|
|
121
101
|
? profileVariablePath
|
|
122
|
-
:
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
profileVariables = JSON.parse(
|
|
102
|
+
: path.resolve(process.cwd(), profileVariablePath);
|
|
103
|
+
if (fs.existsSync(profileVariableFullPath) &&
|
|
104
|
+
path.extname(profileVariableFullPath) === '.json') {
|
|
105
|
+
profileVariables = JSON.parse(fs.readFileSync(profileVariableFullPath, 'utf-8'));
|
|
126
106
|
}
|
|
127
107
|
}
|
|
128
108
|
return {
|
|
@@ -134,5 +114,5 @@ function getOptions(modulePath) {
|
|
|
134
114
|
};
|
|
135
115
|
}
|
|
136
116
|
function execAsync(command, options) {
|
|
137
|
-
return
|
|
117
|
+
return promisify(exec)(command, { cwd: options.extensionRoot });
|
|
138
118
|
}
|
package/dist/lib/build.d.ts
CHANGED
package/dist/lib/build.js
CHANGED
|
@@ -1,85 +1,67 @@
|
|
|
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.extensionErrorBaseMessage = void 0;
|
|
16
|
-
exports.buildSingleExtension = buildSingleExtension;
|
|
17
|
-
exports.remoteBuild = remoteBuild;
|
|
18
|
-
const vite_1 = require("vite");
|
|
19
|
-
const constants_1 = require("./constants");
|
|
20
|
-
const manifestPlugin_1 = __importDefault(require("./plugins/manifestPlugin"));
|
|
21
|
-
const path_1 = __importDefault(require("path"));
|
|
22
|
-
const utils_1 = require("./utils");
|
|
23
|
-
const codeBlockingPlugin_1 = __importDefault(require("./plugins/codeBlockingPlugin"));
|
|
24
|
-
const friendlyLoggingPlugin_1 = __importDefault(require("./plugins/friendlyLoggingPlugin"));
|
|
1
|
+
import { build } from 'vite';
|
|
2
|
+
import { ROLLUP_OPTIONS, OUTPUT_DIR } from "./constants.js";
|
|
3
|
+
import manifestPlugin from "./plugins/manifestPlugin.js";
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { getUrlSafeFileName } from "./utils.js";
|
|
6
|
+
import codeBlockingPlugin from "./plugins/codeBlockingPlugin.js";
|
|
7
|
+
import friendlyLoggingPlugin from "./plugins/friendlyLoggingPlugin.js";
|
|
25
8
|
const allowedExtensions = ['.js', '.ts', '.tsx', '.jsx'];
|
|
26
|
-
|
|
27
|
-
function buildSingleExtension(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
export const extensionErrorBaseMessage = `Supported file extensions are [${allowedExtensions.join(', ')}], received:`;
|
|
10
|
+
export async function buildSingleExtension({ file, outputDir = OUTPUT_DIR, emptyOutDir = true, minify = false, root = process.cwd(), // This is the vite default, so using that as our default
|
|
11
|
+
logLevel = 'info', appConfig, }) {
|
|
12
|
+
const output = getUrlSafeFileName(file);
|
|
13
|
+
await build({
|
|
14
|
+
logLevel,
|
|
15
|
+
root,
|
|
16
|
+
define: {
|
|
17
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
|
|
18
|
+
},
|
|
19
|
+
build: {
|
|
20
|
+
lib: {
|
|
21
|
+
entry: file,
|
|
22
|
+
name: output,
|
|
23
|
+
formats: ['iife'],
|
|
24
|
+
fileName: () => output,
|
|
36
25
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
manifestConfig: appConfig,
|
|
50
|
-
}),
|
|
51
|
-
(0, friendlyLoggingPlugin_1.default)({ logger: console }),
|
|
52
|
-
(0, codeBlockingPlugin_1.default)({ logger: console, extensionPath: root }),
|
|
53
|
-
] }),
|
|
54
|
-
outDir: outputDir,
|
|
55
|
-
emptyOutDir,
|
|
56
|
-
minify,
|
|
26
|
+
rollupOptions: {
|
|
27
|
+
...ROLLUP_OPTIONS,
|
|
28
|
+
plugins: [
|
|
29
|
+
manifestPlugin({
|
|
30
|
+
output,
|
|
31
|
+
extensionPath: root,
|
|
32
|
+
logger: console,
|
|
33
|
+
manifestConfig: appConfig,
|
|
34
|
+
}),
|
|
35
|
+
friendlyLoggingPlugin({ logger: console }),
|
|
36
|
+
codeBlockingPlugin({ logger: console, extensionPath: root }),
|
|
37
|
+
],
|
|
57
38
|
},
|
|
58
|
-
|
|
39
|
+
outDir: outputDir,
|
|
40
|
+
emptyOutDir,
|
|
41
|
+
minify,
|
|
42
|
+
},
|
|
59
43
|
});
|
|
60
44
|
}
|
|
61
|
-
function remoteBuild(args) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
appConfig,
|
|
83
|
-
});
|
|
45
|
+
export async function remoteBuild(args) {
|
|
46
|
+
const { root, entryPoint, outputDir = OUTPUT_DIR, logLevel, appConfig, } = args;
|
|
47
|
+
if (!root) {
|
|
48
|
+
console.error('remoteBuild Error: root is required');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!entryPoint) {
|
|
52
|
+
console.error('remoteBuild Error: entryPoint is required');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const fileInfo = path.parse(entryPoint);
|
|
56
|
+
if (!allowedExtensions.includes(fileInfo.ext)) {
|
|
57
|
+
throw new Error(`${extensionErrorBaseMessage} ${fileInfo.ext}`);
|
|
58
|
+
}
|
|
59
|
+
await buildSingleExtension({
|
|
60
|
+
file: entryPoint,
|
|
61
|
+
outputDir,
|
|
62
|
+
minify: true,
|
|
63
|
+
root,
|
|
64
|
+
logLevel,
|
|
65
|
+
appConfig,
|
|
84
66
|
});
|
|
85
67
|
}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppConfig, ExtensionConfigMap, LocalAppConfig, Logger } from './types';
|
|
1
|
+
import { AppConfig, ExtensionConfigMap, LocalAppConfig, Logger } from './types.ts';
|
|
2
2
|
export declare function loadConfigByPath<T = unknown>(configPath: string): T;
|
|
3
3
|
export declare function validateCardConfig(config?: unknown): Error | true;
|
|
4
4
|
export declare function loadExtensionConfig(appConfig: AppConfig, appPath: string): ExtensionConfigMap;
|
package/dist/lib/config.js
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.loadConfigByPath = loadConfigByPath;
|
|
9
|
-
exports.validateCardConfig = validateCardConfig;
|
|
10
|
-
exports.loadExtensionConfig = loadExtensionConfig;
|
|
11
|
-
exports.validateProxyConfigKey = validateProxyConfigKey;
|
|
12
|
-
exports.validateProxyConfigValue = validateProxyConfigValue;
|
|
13
|
-
exports.loadLocalConfig = loadLocalConfig;
|
|
14
|
-
const fs_1 = __importDefault(require("fs"));
|
|
15
|
-
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const utils_1 = require("./utils");
|
|
17
|
-
function loadConfigByPath(configPath) {
|
|
18
|
-
const source = fs_1.default.readFileSync(configPath).toString();
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { buildSourceId, getUrlSafeFileName } from "./utils.js";
|
|
4
|
+
export function loadConfigByPath(configPath) {
|
|
5
|
+
const source = fs.readFileSync(configPath).toString();
|
|
19
6
|
return JSON.parse(source);
|
|
20
7
|
}
|
|
21
|
-
function validateCardConfig(config) {
|
|
8
|
+
export function validateCardConfig(config) {
|
|
22
9
|
if (!config || typeof config !== 'object') {
|
|
23
10
|
return new Error('Card config must be an object');
|
|
24
11
|
}
|
|
@@ -54,16 +41,14 @@ function validateCardConfig(config) {
|
|
|
54
41
|
}
|
|
55
42
|
return true;
|
|
56
43
|
}
|
|
57
|
-
function loadExtensionConfig(appConfig, appPath) {
|
|
58
|
-
|
|
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;
|
|
44
|
+
export function loadExtensionConfig(appConfig, appPath) {
|
|
45
|
+
const crmCardsSubConfigFiles = appConfig?.extensions?.crm?.cards;
|
|
60
46
|
if (!crmCardsSubConfigFiles) {
|
|
61
47
|
throw new Error("Unable to find extensions files, make sure the 'extensions.crm.cards' array is defined in the application configuration file");
|
|
62
48
|
}
|
|
63
49
|
const outputConfig = {};
|
|
64
50
|
crmCardsSubConfigFiles.forEach((card) => {
|
|
65
|
-
|
|
66
|
-
const cardConfigPath = path_1.default.join(appPath, card.file);
|
|
51
|
+
const cardConfigPath = path.join(appPath, card.file);
|
|
67
52
|
try {
|
|
68
53
|
const cardConfig = loadConfigByPath(cardConfigPath);
|
|
69
54
|
const validation = validateCardConfig(cardConfig);
|
|
@@ -71,11 +56,23 @@ function loadExtensionConfig(appConfig, appPath) {
|
|
|
71
56
|
console.error(`[DevServer] Extension config ${cardConfigPath} is invalid: ${validation.message}`);
|
|
72
57
|
}
|
|
73
58
|
if (cardConfig && cardConfig.data) {
|
|
74
|
-
const cardConfigDir =
|
|
75
|
-
const entryPointPath =
|
|
59
|
+
const cardConfigDir = path.parse(cardConfigPath).dir;
|
|
60
|
+
const entryPointPath = path.join(cardConfigDir, cardConfig.data?.module?.file);
|
|
76
61
|
cardConfig.data.module.file = entryPointPath;
|
|
77
|
-
const sourceId =
|
|
78
|
-
outputConfig[sourceId || `${entryPointPath}-${cardConfig.data.location}`] =
|
|
62
|
+
const sourceId = buildSourceId(appConfig, cardConfig);
|
|
63
|
+
outputConfig[sourceId || `${entryPointPath}-${cardConfig.data.location}`] = {
|
|
64
|
+
...cardConfig,
|
|
65
|
+
output: getUrlSafeFileName(entryPointPath),
|
|
66
|
+
path: appPath,
|
|
67
|
+
extensionPath: path.parse(entryPointPath).dir,
|
|
68
|
+
extensionConfigPath: cardConfigPath,
|
|
69
|
+
data: {
|
|
70
|
+
...cardConfig.data,
|
|
71
|
+
appName: appConfig.name,
|
|
72
|
+
sourceId,
|
|
73
|
+
},
|
|
74
|
+
appConfig,
|
|
75
|
+
};
|
|
79
76
|
}
|
|
80
77
|
}
|
|
81
78
|
catch (e) {
|
|
@@ -84,7 +81,7 @@ function loadExtensionConfig(appConfig, appPath) {
|
|
|
84
81
|
});
|
|
85
82
|
return outputConfig;
|
|
86
83
|
}
|
|
87
|
-
function validateProxyConfigKey(urlKey, logger, localConfigPath) {
|
|
84
|
+
export function validateProxyConfigKey(urlKey, logger, localConfigPath) {
|
|
88
85
|
try {
|
|
89
86
|
const url = new URL(urlKey);
|
|
90
87
|
if (url.pathname !== '/') {
|
|
@@ -95,7 +92,7 @@ function validateProxyConfigKey(urlKey, logger, localConfigPath) {
|
|
|
95
92
|
logger.warn(`The key "${urlKey}" in "${localConfigPath}" is an invalid url`);
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
|
-
function validateProxyConfigValue(value, key, logger, localConfigPath) {
|
|
95
|
+
export function validateProxyConfigValue(value, key, logger, localConfigPath) {
|
|
99
96
|
try {
|
|
100
97
|
// eslint-disable-next-line no-new
|
|
101
98
|
new URL(value);
|
|
@@ -104,14 +101,14 @@ function validateProxyConfigValue(value, key, logger, localConfigPath) {
|
|
|
104
101
|
logger.warn(`The value "${value}" for key "${key}" in "${localConfigPath}" is an invalid url`);
|
|
105
102
|
}
|
|
106
103
|
}
|
|
107
|
-
function loadLocalConfig(appPath, logger) {
|
|
104
|
+
export function loadLocalConfig(appPath, logger) {
|
|
108
105
|
const localConfigFilename = 'local.json';
|
|
109
|
-
const localConfigPath =
|
|
110
|
-
if (!
|
|
106
|
+
const localConfigPath = path.join(appPath, localConfigFilename);
|
|
107
|
+
if (!fs.existsSync(localConfigPath)) {
|
|
111
108
|
return undefined;
|
|
112
109
|
}
|
|
113
110
|
try {
|
|
114
|
-
const localConfig = JSON.parse(
|
|
111
|
+
const localConfig = JSON.parse(fs.readFileSync(localConfigPath).toString());
|
|
115
112
|
const { proxy = {} } = localConfig;
|
|
116
113
|
Object.entries(proxy).forEach((entry) => {
|
|
117
114
|
const [key, value] = entry;
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export declare const OUTPUT_DIR = "dist";
|
|
2
2
|
export declare const MANIFEST_FILE = "manifest.json";
|
|
3
3
|
export declare const EXPRESS_SERVER_ID = "ui-extensions-dev-server";
|
|
4
|
-
export declare const VITE_DEV_SERVER_ID = "ui-extensions-vite-dev-server";
|
|
5
4
|
export declare const EXPRESS_DEFAULT_PORT = 5173;
|
|
6
|
-
export declare const WEBSOCKET_DEFAULT_PORT = 5174;
|
|
7
5
|
export declare const ROLLUP_OPTIONS: {
|
|
8
6
|
external: string[];
|
|
9
7
|
output: {
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.EXPRESS_SERVER_ID = 'ui-extensions-dev-server';
|
|
7
|
-
exports.VITE_DEV_SERVER_ID = 'ui-extensions-vite-dev-server';
|
|
8
|
-
exports.EXPRESS_DEFAULT_PORT = 5173;
|
|
9
|
-
exports.WEBSOCKET_DEFAULT_PORT = 5174;
|
|
10
|
-
exports.ROLLUP_OPTIONS = {
|
|
1
|
+
export const OUTPUT_DIR = 'dist';
|
|
2
|
+
export const MANIFEST_FILE = 'manifest.json';
|
|
3
|
+
export const EXPRESS_SERVER_ID = 'ui-extensions-dev-server';
|
|
4
|
+
export const EXPRESS_DEFAULT_PORT = 5173;
|
|
5
|
+
export const ROLLUP_OPTIONS = {
|
|
11
6
|
// Deps to exclude from the bundle
|
|
12
7
|
external: ['react', 'react-dom', '@remote-ui/react'],
|
|
13
8
|
output: {
|
|
@@ -19,32 +14,30 @@ exports.ROLLUP_OPTIONS = {
|
|
|
19
14
|
extend: true,
|
|
20
15
|
},
|
|
21
16
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
export const EXTENSIONS_MESSAGE_VERSION = 2;
|
|
18
|
+
export const WEBSOCKET_MESSAGE_VERSION = 1;
|
|
19
|
+
export const PROXY_CAPABILITY = 'app-backend-proxy-server';
|
|
20
|
+
export const SERVER_CAPABILITIES = [
|
|
26
21
|
// Supports running app functions locally
|
|
27
22
|
'app-functions-local-dev',
|
|
28
23
|
'source-id',
|
|
29
24
|
'account-id',
|
|
30
25
|
];
|
|
31
|
-
|
|
26
|
+
export const PLATFORM_VERSION = {
|
|
32
27
|
V20231: '2023.1',
|
|
33
28
|
V20232: '2023.2',
|
|
34
29
|
V20251: '2025.1',
|
|
35
30
|
V20252: '2025.2',
|
|
36
31
|
UNSTABLE: 'unstable',
|
|
37
32
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
exports.SETTINGS_EXTENSION,
|
|
49
|
-
exports.PAGE_EXTENSION,
|
|
33
|
+
export const PUBLIC_APP = 'public-app';
|
|
34
|
+
export const PRIVATE_APP = 'private-app';
|
|
35
|
+
export const CARD_EXTENSION = 'CARD';
|
|
36
|
+
export const SETTINGS_EXTENSION = 'SETTINGS';
|
|
37
|
+
export const PAGE_EXTENSION = 'PAGE';
|
|
38
|
+
export const SUPPORTED_APP_TYPES = [PUBLIC_APP, PRIVATE_APP];
|
|
39
|
+
export const SUPPORTED_EXTENSION_TYPES = [
|
|
40
|
+
CARD_EXTENSION,
|
|
41
|
+
SETTINGS_EXTENSION,
|
|
42
|
+
PAGE_EXTENSION,
|
|
50
43
|
];
|
package/dist/lib/dev.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DevServerState } from './DevServerState';
|
|
1
|
+
import { DevServerState } from './DevServerState.ts';
|
|
2
2
|
export declare function startDevMode(devServerState: DevServerState): Promise<() => Promise<void>>;
|