Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PoC] Proxy Configuration Extension #209

Draft
wants to merge 4 commits into
base: v2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class ProjectPreprocessor {

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

if (project.specVersion !== "0.1" && project.specVersion !== "1.0" &&
project.specVersion !== "1.1" && project.specVersion !== "2.0") {
project.specVersion !== "1.1" && project.specVersion !== "2.0" && project.specVersion !== "2.2a") {
throw new Error(
`Unsupported specification version ${project.specVersion} defined for project ` +
`${project.id}. Your UI5 CLI installation might be outdated. ` +
Expand Down Expand Up @@ -352,7 +352,8 @@ class ProjectPreprocessor {
} else if (extension.specVersion !== "0.1" &&
extension.specVersion !== "1.0" &&
extension.specVersion !== "1.1" &&
extension.specVersion !== "2.0") {
extension.specVersion !== "2.0" &&
extension.specVersion !== "2.2a") {
throw new Error(
`Unsupported specification version ${extension.specVersion} defined for extension ` +
`${extension.metadata.name}. Your UI5 CLI installation might be outdated. ` +
Expand All @@ -376,6 +377,13 @@ class ProjectPreprocessor {
case "server-middleware":
this.handleServerMiddleware(extension);
break;
case "proxy-configuration":
if (extension.specVersion !== "2.2a") {
throw new Error(`Extensions of type "proxy-configuration"
must use specification version "2.2a"`);
}
this.handleProxyConfiguration(extension);
break;
default:
throw new Error(`Unknown extension type '${extension.type}' for ${extension.id}`);
}
Expand Down Expand Up @@ -637,6 +645,17 @@ class ProjectPreprocessor {

this.normalizeConfig(project);
}

handleProxyConfiguration(extension) {
if (!extension.metadata && !extension.metadata.name) {
throw new Error(`Proxy configuration extension ${extension.id} is missing 'metadata.name' configuration`);
}
if (!extension.proxy || !extension.proxy.configuration) {
throw new Error(`Proxy configuration extension ${extension.id} is missing 'proxy' configuration`);
}
const {proxyConfiguration} = require("@ui5/server");
proxyConfiguration.addConfiguration(extension.metadata.name, extension.proxy.configuration);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/validation/schema/ui5.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"specVersion": {
"enum": [
"2.0",
"1.1", "1.0", "0.1"
"2.2a", "1.1", "1.0", "0.1"
],
"errorMessage": "Unsupported \"specVersion\"\nYour UI5 CLI installation might be outdated.\nSupported specification versions: \"2.0\", \"1.1\", \"1.0\", \"0.1\"\nFor details see: https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions"
}
Expand All @@ -28,7 +28,7 @@
"else": {
"if": {
"properties": {
"specVersion": { "enum": ["1.1", "1.0", "0.1"] }
"specVersion": { "enum": ["2.2a", "1.1", "1.0", "0.1"] }
}
},
"then": {
Expand Down
136 changes: 87 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@
"url": "[email protected]:SAP/ui5-project.git"
},
"dependencies": {
"@ui5/builder": "^2.0.0",
"@ui5/builder": "SAP/ui5-builder#feature-proxy",
"@ui5/logger": "^2.0.0",
"@ui5/server": "^2.0.0",
"@ui5/server": "SAP/ui5-server#feature-proxy",
"ajv": "^6.12.0",
"ajv-errors": "^1.0.1",
"chalk": "^3.0.0",
Expand Down