From 047195d082e5e5e9735c50f3a5d30c374ed85b1c Mon Sep 17 00:00:00 2001 From: Merlin Beutlberger Date: Fri, 9 Aug 2019 15:55:09 +0200 Subject: [PATCH] proxyConfiguration: Fix library rewrite path mapping --- lib/proxyConfiguration.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/proxyConfiguration.js b/lib/proxyConfiguration.js index caaf0bae..dbf578a2 100644 --- a/lib/proxyConfiguration.js +++ b/lib/proxyConfiguration.js @@ -19,7 +19,7 @@ function addConfiguration(name, proxyConfig) { proxyConfigurations[name] = proxyConfig; } -async function getConfigurationForProject(project) { +async function getConfigurationForProject(tree) { const configNames = Object.keys(proxyConfigurations); if (configNames.length === 0) { throw new Error(`No proxy configurations have been added yet`); @@ -29,7 +29,7 @@ async function getConfigurationForProject(project) { `This is not yet supported.`); // TODO } - log.verbose(`Applying proxy configuration ${configNames[0]} to project ${project.metadata.name}...`); + log.verbose(`Applying proxy configuration ${configNames[0]} to project ${tree.metadata.name}...`); const config = JSON.parse(JSON.stringify(proxyConfigurations[configNames[0]])); config.rewriteRootPaths = {}; @@ -40,15 +40,15 @@ async function getConfigurationForProject(project) { }; } - mapProjectDependencies(project, (proj) => { - if (proj.specVersion !== "1.1a") { - log.warn(`Project ${project.metadata.name} defines specification version ${proj.specVersion}. ` + + mapProjectDependencies(tree, (project) => { + if (project.specVersion !== "1.1a") { + log.warn(`Project ${project.metadata.name} defines specification version ${project.specVersion}. ` + `Some proxy configuration features require projects to define specification version 1.1a`); } - log.verbose(`Using ABAP URI ${proj.metadata.abapUri} from metadata of project ${proj.metadata.name}`); + log.verbose(`Using ABAP URI ${project.metadata.abapUri} from metadata of project ${project.metadata.name}`); let prefix = ""; - if (proj.type !== "application") { - if (project.resources.pathMappings["/resources"]) { + if (project.type !== "application") { + if (project.resources.pathMappings["/resources/"]) { // If the project defines a /resources path mapping, // we expect this to match the ABAP URI deployment path prefix += "/resources/"; @@ -56,16 +56,16 @@ async function getConfigurationForProject(project) { // If this is not an application and there is no /resources path mapping, somebody does something wild // and hopefully knows what he/she does } - prefix += proj.metadata.namespace; + prefix += project.metadata.namespace; } - config.rewriteRootPaths[proj.metadata.abapUri] = { + config.rewriteRootPaths[project.metadata.abapUri] = { rewriteTo: prefix }; }); if (log.isLevelEnabled("verbose")) { - log.verbose(`Configured ${config.rewriteRootPaths.length} root paths to rewrite for ` + - `project ${project.metadata.name};`); + log.verbose(`Configured ${Object.keys(config.rewriteRootPaths).length} root paths to rewrite for ` + + `project ${tree.metadata.name};`); for (const abapUri in config.rewriteRootPaths) { if (config.rewriteRootPaths.hasOwnProperty(abapUri)) { if (config.rewriteRootPaths[abapUri].rewriteTo) {