Skip to content

Commit

Permalink
proxyConfiguration: Fix library rewrite path mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Aug 9, 2019
1 parent a541d67 commit 047195d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/proxyConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand All @@ -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 = {};

Expand All @@ -40,32 +40,32 @@ 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/";

// 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) {
Expand Down

0 comments on commit 047195d

Please sign in to comment.