forked from SEDAdigital/XRouting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (50 loc) · 1.85 KB
/
gulpfile.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const gulp = require('gulp'),
format = require('date-format'),
replace = require('gulp-replace'),
pkg = require('./_build/config.json');
const year = new Date().getFullYear();
let phpversion;
let modxversion;
pkg.dependencies.forEach(function (dependency, index) {
switch (pkg.dependencies[index].name) {
case 'php':
phpversion = pkg.dependencies[index].version.replace(/>=/, '');
break;
case 'modx':
modxversion = pkg.dependencies[index].version.replace(/>=/, '');
break;
}
});
const bumpCopyright = function () {
return gulp.src([
'core/components/smartrouting/model/smartrouting/smartrouting.class.php',
'core/components/smartrouting/src/SmartRouting.php'
], {base: './'})
.pipe(replace(/Copyright 2023(-\d{4})? by/g, 'Copyright ' + (year > 2023 ? '2023-' : '') + year + ' by'))
.pipe(gulp.dest('.'));
};
const bumpVersion = function () {
return gulp.src([
'core/components/smartrouting/src/SmartRouting.php'
], {base: './'})
.pipe(replace(/version = '\d+\.\d+\.\d+[-a-z0-9]*'/ig, 'version = \'' + pkg.version + '\''))
.pipe(gulp.dest('.'));
};
const bumpDocs = function () {
return gulp.src([
'mkdocs.yml',
], {base: './'})
.pipe(replace(/© 2023(-\d{4})?/g, '© ' + (year > 2023 ? '2023-' : '') + year))
.pipe(gulp.dest('.'));
};
const bumpRequirements = function () {
return gulp.src([
'docs/index.md',
], {base: './'})
.pipe(replace(/[*-] MODX Revolution \d.\d.*/g, '* MODX Revolution ' + modxversion + '+'))
.pipe(replace(/[*-] PHP (v)?\d.\d.*/g, '* PHP ' + phpversion + '+'))
.pipe(gulp.dest('.'));
};
gulp.task('bump', gulp.series(bumpCopyright, bumpVersion, bumpDocs, bumpRequirements));
// Default Task
gulp.task('default', gulp.series('bump'));