-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpomParser.js
40 lines (31 loc) · 1.06 KB
/
pomParser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const xmlParser = require("./xmlParser");
const pomParser = pomFile => {
let { xml } = xmlParser(pomFile);
let xmlProperties = xml.project.properties[0];
let properties = new Map();
for (let property in xmlProperties) {
properties.set(property, xmlProperties[property][0]);
}
let dependencies = xml.project.dependencies[0].dependency;
let plugins = xml.project.build[0].plugins[0].plugin;
// Curryable function
const findElementByArtifactId = elements => artifactId =>
elements.find(
element => element.artifactId && element.artifactId[0] === artifactId
);
const findDependency = findElementByArtifactId(dependencies);
const findPlugin = findElementByArtifactId(plugins);
let muleMavenPlugin = findPlugin("mule-maven-plugin");
// Currently assuming if not using the Mule Maven Plugin then deploying on-prem.
let isOnPrem =
!muleMavenPlugin || properties.get("deployment.type") === "arm";
return {
findDependency,
findPlugin,
properties,
muleMavenPlugin,
isOnPrem,
xml
};
};
module.exports = pomParser;