Commit 4ad484c4 authored by Tino Goratsch's avatar Tino Goratsch

backport the bump-version gulptask from the next-branch

parent 48434b42
......@@ -3,40 +3,71 @@
* See the LICENCE file at the top-level module directory for licencing details.
*/
argv = require('yargs').argv;
const argv = require('yargs').argv;
module.exports = function (gulp, plugins) {
module.exports = (gulp, plugins) => {
"use strict";
return function () {
if (argv.from === undefined || argv.to === undefined) {
plugins.util.log(plugins.util.colors.red('Error: Please specify the arguments "from" and "to".'));
return;
}
/**
* Reads the current ACP3 CMS version from the package.json
*/
function getCurrentVersion() {
return require('../../package.json').version;
}
function replaceAll(str, find, replace) {
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
function replaceAll(str, find, replace) {
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
function escapeRegExp(str) {
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
function escapeRegExp(str) {
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
/**
* Bumps a given semantic version number by the given console argument
*
* @param {string} version The to be bumped semver string
* @returns {string} Returns the version bumped version string
*/
function bumpVersion(version) {
let versionArray = version.split('.');
if (argv.major) {
versionArray[0]++;
versionArray[1] = versionArray[2] = 0;
} else if (argv.minor) {
versionArray[1]++;
versionArray[2] = 0;
} else if (argv.patch) {
versionArray[2]++;
} else {
throw new Error('Error: Please specify the arguments "major", "minor" or "patch"!');
}
return gulp.src(
[
'./ACP3/Core/composer.json',
'./ACP3/Core/Application/BootstrapInterface.php',
'./ACP3/Modules/ACP3/*/composer.json',
'./installation/composer.json',
'./package.json'
],
{
base: './'
}
)
.pipe(plugins.change(function (content) {
return replaceAll(content, argv.from, argv.to);
}))
.pipe(gulp.dest('./'))
return versionArray.join('.');
}
return () => {
try {
const from = getCurrentVersion();
const bumpedVersion = bumpVersion(from);
return gulp.src(
[
'./ACP3/Core/composer.json',
'./ACP3/Core/Application/BootstrapInterface.php',
'./ACP3/Modules/ACP3/*/composer.json',
'./installation/composer.json',
'./package.json'
],
{
base: './'
}
).pipe(plugins.change((content) => {
return replaceAll(content, from, bumpedVersion);
})).pipe(gulp.dest('./'))
} catch (e) {
plugins.util.log(plugins.util.colors.red(e.message));
}
}
};
This diff is collapsed.
......@@ -14,7 +14,7 @@
"bugs": {
"url": "https://github.com/ACP3/cms/issues"
},
"homepage": "http://www.acp3-cms.net",
"homepage": "https://www.acp3-cms.net",
"private": true,
"devDependencies": {
"@fancyapps/fancybox": "^3.2.5",
......@@ -34,6 +34,6 @@
"jquery": "^2.2.4",
"js-cookie": "^2.2.0",
"moment": "^2.19.4",
"yargs": "^7.0.0"
"yargs": "^8.0.0"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment