forked from epointal/lf-hiker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
120 lines (101 loc) · 3.25 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//need to be very carefull with the replace version number
//there are in files readme others version numbers: for releases, tested browsers, and the most important wordpress
var old_version = '1.12.0';
var version = '1.13.0';
var gulp = require('gulp');
var less = require('gulp-less');
var minify = require('gulp-minify');
var cssmin = require('gulp-cssmin');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var uncss = require('gulp-uncss');
var replace = require('gulp-replace');
gulp.task('default', function() {
console.log("Ne fait rien");
});
// for see if there is unused style
gulp.task('cleancss', function(){
gulp.src(['css/lfh-style.css' ])
.pipe(uncss({
html: [ 'http://rancs.com/blog/fr/presentation/']
}))
.pipe(gulp.dest('clean'));
});
gulp.task('lessify', function(){
gulp.src('css/helper.less')
.pipe(less())
.pipe(gulp.dest('css'));
return gulp.src('css/lfh-style.less')
.pipe(less())
.pipe(gulp.dest('css'));
});
gulp.task('rename', function(){
gulp.src([ 'readme.txt', 'readme.md', 'lf-hiker.php'])
.pipe(rename({suffix: '-back'}))
.pipe(gulp.dest(''));
});
gulp.task('new', /* ['rename'] ,*/ function(){
if(old_version){
//replace version by the new version in files
//readme.txt
// javascript does not supported negative lookahead
//rename the old file
var pattern = new RegExp( old_version+'(?! +\=)', 'g');
gulp.src(['readme-back.txt'])
.pipe(replace(pattern, version))
.pipe(rename({basename: 'readme'}))
.pipe(gulp.dest(''));
//readme (add "###" after version number for the release not be changed)
var pattern = new RegExp( old_version+'(?! +###)', 'g');
gulp.src(['readme-back.md'])
.pipe(replace(pattern, version))
.pipe(rename({basename: 'readme'}))
.pipe(gulp.dest(''));
//lf-hiker.php
var pattern = new RegExp( old_version, 'g');
gulp.src(['lf-hiker-back.php'])
.pipe(replace(pattern, version))
.pipe(rename({basename: 'lf-hiker'}))
.pipe(gulp.dest(''));
//svg file
var pattern = new RegExp( old_version, 'g');
gulp.src(['assets/svg/version'+old_version+'.svg'])
.pipe(replace(pattern, version))
.pipe(rename({basename: 'version'+version}))
.pipe(gulp.dest('assets/svg/'));
}
});
gulp.task('versioning', gulp.series('lessify', function(){
//front my editing css
gulp.src(['css/lfh-style.css'])
.pipe(cssmin())
.pipe(rename({suffix: '-min.'+version}))
.pipe(gulp.dest('dist'));
gulp.src(['css/helper.css', 'css/lfh-post-editor.css'])
.pipe(cssmin())
.pipe(rename({suffix: '.'+version}))
.pipe(gulp.dest('dist'));
//all js in the same file
gulp.src([
'lib/awesome-marker/leaflet.awesome-markers.js',
'lib/leaflet-gpx.js',
'js/lfh-plugin.js'])
.pipe(concat('lfh-front.js'))
.pipe(minify())
.pipe(rename({suffix: '.'+version}))
.pipe(gulp.dest('dist'));
gulp.src(['js/tinymce-lfh-plugin.js',
'js/lfh-post-editor.js',
'js/helper.js'])
.pipe(minify())
.pipe(rename({suffix: '.'+version}))
.pipe(gulp.dest('dist'));
//copy images
//from awesome-marker
gulp.src('lib/awesome-marker/images/*')
.pipe(gulp.dest('dist/images'));
gulp.src('lib/awesome-marker/images/*')
.pipe(gulp.dest('css/images'));
//copy images
return Promise.resolve('versioning done');
}));