Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/intuit/node-pom-parser
Parsing Java's pom.xml and properly returning the json object, including attributes and values.
https://github.com/intuit/node-pom-parser
enterprise hacktoberfest hacktoberfest2022 javascript json nexus node-pom-parser parser pom
Last synced: 25 days ago
JSON representation
Parsing Java's pom.xml and properly returning the json object, including attributes and values.
- Host: GitHub
- URL: https://github.com/intuit/node-pom-parser
- Owner: intuit
- License: mit
- Created: 2014-11-24T00:44:52.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-10-03T15:25:38.000Z (about 1 year ago)
- Last Synced: 2024-11-07T20:46:43.366Z (about 1 month ago)
- Topics: enterprise, hacktoberfest, hacktoberfest2022, javascript, json, nexus, node-pom-parser, parser, pom
- Language: TypeScript
- Homepage:
- Size: 73.2 KB
- Stars: 22
- Watchers: 6
- Forks: 28
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Node.js pom.xml Parser
[![CI Build Status](https://github.com/intuit/node-pom-parser/actions/workflows/unit-tests.yml/badge.svg?branch=master)](https://github.com/intuit/node-pom-parser/actions/workflows/unit-tests.yml)
![npm](https://img.shields.io/npm/v/node-pom-parser)
[![CodeQL Analysis](https://github.com/intuit/node-pom-parser/actions/workflows/codeql.yml/badge.svg?branch=master)](https://github.com/intuit/node-pom-parser/actions/workflows/codeql.yml)
[![Coverage Status](https://coveralls.io/repos/intuit/node-pom-parser/badge.svg?branch=master&service=github)](https://coveralls.io/github/intuit/node-pom-parser?branch=master)
![License](https://img.shields.io/github/license/intuit/node-pom-parser)[![NPM](https://nodei.co/npm/pom-parser.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/pom-parser/)
# pom-parser
Parsing Java's `pom.xml` file and properly returning the JSON object, including all it's attributes and values.
# Motivation
* Your enterprise decided to move production code written in Java to Node.js
* Your enterprise uses a centralized Nexus repository where your Java project uses pom.xml to manage app packaging
* Your enterprise still plans to use Nexus repository to package Node.js applications
* Your enterprise engineers want an API to retrieve information from the pom.xml file from those Node.js apps# Features
* Reads any `pom.xml`
* All XML elements are placed into properties
* All XML element attributes are merged into the parent element
* Both the XML string and the parsed object are returned
* You can provide parsing options# Contributing
Pull requests are welcome!
* See if an issue is already open, if not open
* Discuss with team to prevent duplicate effort
* Work up the PR and add/update unit tests
* Raise PR against the `master` branch for the next release
* Ensure all the Github Actions/checks are passing# Installation
```sh
$ npm install --save node-pom-parser
$ yarn add node-pom-parser
```# Use
* Printing the object
```js
import parse from './lib/index.js';
import { dirname } from 'path';
import { fileURLToPath } from 'url';//var pomParser = require("./lib/index");
// The required options, including the filePath.
// Other parsing options from https://github.com/Leonidas-from-XIV/node-xml2js#optionsconst __dirname = dirname(fileURLToPath(import.meta.url));
var opts = {
filePath: __dirname + "/test/fixture/pom.xml", // The path to a pom file
};
// Parse the pom based on a path
parse(opts, function(err, pomResponse) {
if (err) {
console.log("ERROR: " + err);
process.exit(1);
}// The original pom xml that was loaded is provided.
console.log("XML: " + pomResponse.pomXml);
// The parsed pom pbject.
console.log("OBJECT: " + JSON.stringify(pomResponse.pomObject));
});
```
It should print the follow object with the following properties:* '_' represents the text value of an element with attributes and text values.
```js
{
"project": {
"xmlns": "http://maven.apache.org/POM/4.0.0",
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation": "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd",
"parent": {
"artifactid": "tynamo-parent",
"groupid": "org.tynamo",
"version": "0.0.9"
},
"modelversion": {
"_": "4.0.0",
"parallel": "now"
},
"groupid": "org.tynamo.examples",
"artifactid": "tynamo-example-federatedaccounts",
"version": "0.0.1-SNAPSHOT",
"packaging": "war",
"name": "Tynamo Example - Federated Accounts",
"properties": {
"tapestry-release-version": "5.3.1",
"gae.version": "1.3.0",
"gae.home": "${settings.localRepository}/com/google/appengine/appengine-api-1.0-sdk/${gae.version}/appengine-java-sdk-${gae.version}",
"gae.application.version": "0"
},
"build": {
"finalname": "federatedaccounts",
"resources": {
"resource": [
{
"directory": "src/main/resources"
},
{
"directory": "src/main/filtered-resources",
"filtering": "true"
}
]
},
"plugins": {
"plugin": [
{
"groupid": "org.apache.maven.plugins",
"artifactid": "maven-compiler-plugin",
"configuration": {
"source": "1.6",
"target": "1.6",
"optimize": "true"
}
},
{
"groupid": "net.kindleit",
"artifactid": "maven-gae-plugin",
"version": "0.8.0",
"configuration": {
"serverid": "tynamo-example-federatedaccounts"
}
},
{
"groupid": "org.apache.maven.plugins",
"artifactid": "maven-war-plugin",
"configuration": {
"webresources": {
"resource": {
"directory": "src/main/webapp",
"filtering": "true",
"includes": {
"include": "**/appengine-web.xml"
}
}
}
}
}
]
}
},
"reporting": {
"plugins": {
"plugin": {
"groupid": "org.apache.tapestry",
"artifactid": "tapestry-component-report",
"version": "${tapestry-release-version}",
"configuration": {
"rootpackage": "org.tynamo"
}
}
}
},
"dependencies": {
"dependency": [
{
"groupid": "com.google.appengine",
"artifactid": "appengine-api-1.0-sdk",
"version": "${gae.version}"
},
{
"groupid": "com.h2database",
"artifactid": "h2"
},
{
"groupid": "org.apache.tapestry",
"artifactid": "tapestry-core",
"version": "${tapestry-release-version}"
},
{
"groupid": "javax.servlet",
"artifactid": "servlet-api",
"version": "2.5",
"type": "jar",
"scope": "provided"
}
]
},
"profiles": {
"profile": {
"id": "repositories",
"repositories": {
"repository": {
"id": "maven-gae-plugin-repo",
"name": "maven-gae-plugin repository",
"url": "http://maven-gae-plugin.googlecode.com/svn/repository"
}
},
"pluginrepositories": {
"pluginrepository": {
"id": "maven-gae-plugin-repo",
"name": "maven-gae-plugin repository",
"url": "http://maven-gae-plugin.googlecode.com/svn/repository"
}
}
}
}
}
}
```# License
`node-pom-parser` is provided under the MIT license.