Skip to content

Commit 06c5b4f

Browse files
committed
[POC] Proxy Configuration Extension
1 parent bd8c0db commit 06c5b4f

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

lib/projectPreprocessor.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class ProjectPreprocessor {
147147

148148
if (project.kind === "extension") {
149149
// Not a project but an extension
150-
// => remove it as from any known projects that depend on it
150+
// => remove it from any known projects that depend on it
151151
const parents = this.processedProjects[project.id].parents;
152152
for (let i = parents.length - 1; i >= 0; i--) {
153153
parents[i].dependencies.splice(parents[i].dependencies.indexOf(project), 1);
@@ -277,7 +277,7 @@ class ProjectPreprocessor {
277277
}
278278

279279
if (project.specVersion !== "0.1" && project.specVersion !== "1.0" &&
280-
project.specVersion !== "1.1" && project.specVersion !== "2.0") {
280+
project.specVersion !== "1.1" && project.specVersion !== "2.0" && project.specVersion !== "1.1a") {
281281
throw new Error(
282282
`Unsupported specification version ${project.specVersion} defined for project ` +
283283
`${project.id}. Your UI5 CLI installation might be outdated. ` +
@@ -352,7 +352,8 @@ class ProjectPreprocessor {
352352
} else if (extension.specVersion !== "0.1" &&
353353
extension.specVersion !== "1.0" &&
354354
extension.specVersion !== "1.1" &&
355-
extension.specVersion !== "2.0") {
355+
extension.specVersion !== "2.0" &&
356+
extension.specVersion !== "1.1a") {
356357
throw new Error(
357358
`Unsupported specification version ${extension.specVersion} defined for extension ` +
358359
`${extension.metadata.name}. Your UI5 CLI installation might be outdated. ` +
@@ -376,6 +377,13 @@ class ProjectPreprocessor {
376377
case "server-middleware":
377378
this.handleServerMiddleware(extension);
378379
break;
380+
case "proxy-configuration":
381+
if (extension.specVersion !== "1.1a") {
382+
throw new Error(`Extensions of type "proxy-configuration"
383+
must use specification version "1.1a"`);
384+
}
385+
this.handleProxyConfiguration(extension);
386+
break;
379387
default:
380388
throw new Error(`Unknown extension type '${extension.type}' for ${extension.id}`);
381389
}
@@ -637,6 +645,17 @@ class ProjectPreprocessor {
637645

638646
this.normalizeConfig(project);
639647
}
648+
649+
handleProxyConfiguration(extension) {
650+
if (!extension.metadata && !extension.metadata.name) {
651+
throw new Error(`Proxy configuration extension ${extension.id} is missing 'metadata.name' configuration`);
652+
}
653+
if (!extension.proxy || !extension.proxy.configuration) {
654+
throw new Error(`Proxy configuration extension ${extension.id} is missing 'proxy' configuration`);
655+
}
656+
const {proxyConfiguration} = require("@ui5/server");
657+
proxyConfiguration.addConfiguration(extension.metadata.name, extension.proxy.configuration);
658+
}
640659
}
641660

642661
/**

0 commit comments

Comments
 (0)