From 16227751f3c3a60192d6c277434ec85ab2d13b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Membr=C3=A9?= Date: Fri, 17 Jan 2020 15:11:44 +0100 Subject: [PATCH] :sparkles: Add maven preset (#172) --- DOCUMENTATION.md | 1 + packages/gitmoji-changelog-cli/package.json | 1 + .../src/presets/maven.js | 32 +++++++++++++++++++ yarn.lock | 28 +++++++++++++++- 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 packages/gitmoji-changelog-cli/src/presets/maven.js diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index d81d753..f500977 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -84,6 +84,7 @@ _This workflow is related to the `node` preset but can be adapted to your own te - node (default preset) - generic +- maven You didn't the preset you need in the list? Consider adding it. Presets are stored in a [presets](packages/gitmoji-changelog-cli/src/presets) folder in the `cli` package. diff --git a/packages/gitmoji-changelog-cli/package.json b/packages/gitmoji-changelog-cli/package.json index 75ba00e..d4d82e9 100644 --- a/packages/gitmoji-changelog-cli/package.json +++ b/packages/gitmoji-changelog-cli/package.json @@ -39,6 +39,7 @@ "issue-reporter": "^0.2.0", "libnpm": "^1.0.0", "lodash": "^4.17.11", + "pom-parser": "^1.2.0", "rc": "^1.2.8", "semver": "^5.6.0", "semver-compare": "^1.0.0", diff --git a/packages/gitmoji-changelog-cli/src/presets/maven.js b/packages/gitmoji-changelog-cli/src/presets/maven.js new file mode 100644 index 0000000..a9100a0 --- /dev/null +++ b/packages/gitmoji-changelog-cli/src/presets/maven.js @@ -0,0 +1,32 @@ +const pomParser = require('pom-parser') + +module.exports = async () => { + try { + const opts = { + filePath: 'pom.xml', + } + const pomPromise = new Promise((resolve, reject) => { + pomParser.parse(opts, (err, pomResponse) => { + if (err) { + reject(err) + return + } + + resolve(pomResponse.pomObject) + }) + }) + + const { + project: { + groupid, artifactid, version, description, + }, + } = await pomPromise + return { + name: `${groupid}.${artifactid}`, + version: version, + description: description, + } + } catch (e) { + return null + } +} diff --git a/yarn.lock b/yarn.lock index a1a4fe7..c088355 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4864,6 +4864,14 @@ pn@^1.1.0: resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb" integrity sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA== +pom-parser@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/pom-parser/-/pom-parser-1.2.0.tgz#d705b379432c6ed33bbbadc096c0263d37eb44fe" + integrity sha512-v5QRdaXWS/Qg2KX3rYNSI8dxuEH1DVh8HcayKQwqfaGFVzI5EJxHqK2ThBBsRvmscEHkbyPrBzno1sq9l54uiA== + dependencies: + traverse "^0.6.6" + xml2js "^0.4.9" + posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" @@ -5397,7 +5405,7 @@ sane@^2.0.0: optionalDependencies: fsevents "^1.2.3" -sax@^1.2.4: +sax@>=0.6.0, sax@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== @@ -6060,6 +6068,11 @@ tr46@^1.0.1: dependencies: punycode "^2.1.0" +traverse@^0.6.6: + version "0.6.6" + resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137" + integrity sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc= + trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" @@ -6440,6 +6453,19 @@ xml-name-validator@^3.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== +xml2js@^0.4.9: + version "0.4.23" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.23.tgz#a0c69516752421eb2ac758ee4d4ccf58843eac66" + integrity sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug== + dependencies: + sax ">=0.6.0" + xmlbuilder "~11.0.0" + +xmlbuilder@~11.0.0: + version "11.0.1" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3" + integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA== + xregexp@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020"