Skip to content

Commit

Permalink
build: adds prettier and proper plugin.xml version patching
Browse files Browse the repository at this point in the history
  • Loading branch information
timbru31 committed Dec 31, 2019
1 parent 61bb415 commit bf6a2ea
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/www/detect-webview-engine.js
package-lock.json
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"printWidth": 140,
"useTabs": false
}
58 changes: 58 additions & 0 deletions .versionrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"scripts": {
"prebump": "node scripts/patch-plugin-xml-version.js",
"precommit": "git add plugin.xml",
"postchangelog": "npx prettier --write CHANGELOG.md"
},
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "revert",
"section": "Reverts"
},
{
"type": "docs",
"section": "Documentation",
"hidden": true
},
{
"type": "style",
"section": "Styles",
"hidden": true
},
{
"type": "chore",
"section": "Miscellaneous Chores",
"hidden": true
},
{
"type": "refactor",
"section": "Code Refactoring"
},
{
"type": "test",
"section": "Tests",
"hidden": true
},
{
"type": "build",
"section": "Build System"
},
{
"type": "ci",
"section": "Continuous Integration",
"hidden": true
}
]
}
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"devDependencies": {
"@types/cordova": "^0.0.34",
"prettier": "^1.19.1",
"standard-version": "^7.0.1",
"tslint": "^5.20.1",
"typescript": "^3.7.4"
Expand Down
35 changes: 35 additions & 0 deletions scripts/patch-plugin-xml-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const packageJson = require('../package.json');
const conventionalRecommendedBump = require('conventional-recommended-bump');
const semver = require('semver');
const replace = require('replace');

const getNextVersion = currentVersion => {
return new Promise((resolve, reject) => {
conventionalRecommendedBump(
{
preset: 'angular'
},
(err, release) => {
if (err) {
reject(err);
return;
}

const nextVersion = semver.valid(release.releaseType) || semver.inc(currentVersion, release.releaseType);

resolve(nextVersion);
}
);
});
};

getNextVersion(packageJson.version)
.then(version => {
replace({
regex: /(id="[\w\.-]+" version=")([\w\.-]+)(")/,
replacement: `$1${version}$3`,
paths: ['./plugin.xml'],
silent: true
});
})
.catch(error => console.log(error));

0 comments on commit bf6a2ea

Please sign in to comment.