-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
173 lines (139 loc) · 4.45 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
'use strict';
/*
* Gulp Builder for WordPress Plugin FAU ORGA Breadcrumb
*/
const
{src, dest, watch, series, parallel} = require('gulp'),
sass = require('gulp-sass')(require('sass')),
bump = require('gulp-bump'),
semver = require('semver'),
info = require('./package.json'),
wpPot = require('gulp-wp-pot'),
touch = require('gulp-touch-cmd'),
header = require('gulp-header'),
rename = require('gulp-rename'),
yargs = require('yargs')
;
/**
* Template for banner to add to file headers
*/
var banner = [
'/*!',
'Plugin Name: <%= info.name %>',
'Version: <%= info.version %>',
'Requires at least: <%= info.compatibility.wprequires %>',
'Tested up to: <%= info.compatibility.wptestedup %>',
'Requires PHP: <%= info.compatibility.phprequires %>',
'Description: <%= info.description %>',
'Theme URI: <%= info.repository.url %>',
'GitHub Plugin URI: <%= info.repository.url %>',
'GitHub Issue URL: <%= info.repository.issues %>',
'Author: <%= info.author.name %>',
'Author URI: <%= info.author.url %>',
'License: <%= info.license %>',
'License URI: <%= info.licenseurl %>',
'Tags: <%= info.tags %>',
'Text Domain: <%= info.textdomain %>',
'*/'].join('\n');
/*
* Compile main style with SASS and clean them up
*/
function buildmainstyle() {
return src([info.source.sass + info.source.cssmain + '.scss'])
.pipe(header(banner, { info : info }))
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rename(info.source.cssmain + '.css'))
.pipe(dest(info.dest.css))
.pipe(touch());
}
/*
* Compile main style for dev without postcss minifying
*/
function devbuildmainstyle() {
return src([info.source.sass + info.source.cssmain + '.scss'])
.pipe(header(banner, { info : info }))
.pipe(sass({sourceComments: true, outputStyle: 'expanded'}).on('error', sass.logError))
.pipe(rename(info.source.cssmain + '.css'))
.pipe(dest(info.dest.css))
.pipe(touch());
}
/*
* Compile admin style with SASS and clean them up
*/
function buildadminstyle() {
// var plugins = [
// autoprefixer(),
// cssnano()
// ];
return src([info.source.sass + info.source.cssadmin + '.scss'])
.pipe(header(banner, { info : info }))
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
// .pipe(postcss(plugins))
.pipe(rename(info.source.cssadmin + '.css'))
.pipe(dest(info.dest.css))
.pipe(touch());
}
/*
* Compile admin style for dev without postcss minifying
*/
function devbuildadminstyle() {
return src([info.source.sass + info.source.cssadmin + '.scss'])
.pipe(header(banner, { info : info }))
.pipe(sass().on('error', sass.logError))
.pipe(rename(info.source.cssadmin + '.css'))
.pipe(dest(info.dest.css))
.pipe(touch());
}
function updatepot() {
return src(['**/*.php', '!vendor/**/*.php'])
.pipe(
wpPot({
domain: info.textdomain,
package: info.name,
team: info.author,
bugReport: info.repository.issues,
ignoreTemplateNameHeader: true
})
)
.pipe(dest(`languages/${info.textdomain}.pot`))
.pipe(touch());;
};
/*
* Update Version on Patch-Level
* (All other levels we are doing manually; This level has to update automatically on each build)
*/
function upversionpatch() {
var newVer = semver.inc(info.version, 'patch');
return src(['./package.json', info.main])
.pipe(bump({
version: newVer
}))
.pipe(dest('./'))
.pipe(touch());
};
/*
* Update DEV Version on prerelease level.
* Reason: in the Theme function, we will recognise the prerelease version by its syntax.
* This will allow the theme automatically switch to the non-minified-files instead of
* the minified versions.
* In other words: If we use dev, the theme wil load script files without ".min.".
*/
function devversion() {
var newVer = semver.inc(info.version, 'prerelease');
return src(['./package.json', info.main])
.pipe(bump({
version: newVer
}))
.pipe(dest('./'))
.pipe(touch());;
};
exports.pot = updatepot;
exports.devversion = devversion;
exports.buildmainstyle = buildmainstyle;
exports.buildadminstyle = buildadminstyle;
var dev = series(devbuildadminstyle, devbuildmainstyle, devversion);
exports.cssdev = devbuildmainstyle;
exports.css = devbuildmainstyle;
exports.dev = dev;
exports.build = series(buildadminstyle, buildmainstyle, upversionpatch);
exports.default = dev;