forked from WPBuddy/largo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
273 lines (250 loc) · 5.69 KB
/
Gruntfile.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
module.exports = function(grunt) {
'use strict';
// Load all tasks
require('load-grunt-tasks')(grunt);
// Show elapsed time
require('time-grunt')(grunt);
// Force use of Unix newlines
grunt.util.linefeed = '\n';
// Find what the current theme's directory is, relative to the WordPress root
var path = process.cwd().replace(/^[\s\S]+\/wp-content/, "\/wp-content");
var cssLessFiles = {
'css/style.css': 'less/style.less',
'css/editor-style.css': 'less/editor-style.less',
'homepages/assets/css/single.css': 'homepages/assets/less/single.less',
'homepages/assets/css/top-stories.css': 'homepages/assets/less/top-stories.less',
'homepages/assets/css/legacy-three-column.css': 'homepages/assets/less/legacy-three-column.less'
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
compile: {
options: {
paths: ['less'],
sourceMap: true,
outputSourceFiles: true,
sourceMapBasepath: path,
},
files: cssLessFiles
}
},
uglify: {
target: {
options: {
report: 'gzip'
},
files: [{
expand: true,
cwd: 'js',
src: [
'custom-less-variables.js',
'custom-sidebar.js',
'custom-term-icons.js',
'featured-media.js',
'floating-social-buttons.js',
'image-widget.js',
'largoCore.js',
'load-more-posts.js',
'navigation.js',
'top-terms.js',
'update-page.js',
'widgets-php.js',
'!*.min.js'
],
dest: 'js',
ext: '.min.js'
}]
}
},
cssmin: {
target: {
options: {
report: 'gzip'
},
files: [
{
expand: true,
cwd: 'css',
src: ['*.css', '!*.min.css'],
dest: 'css',
ext: '.min.css'
},
{
expand: true,
cwd: 'homepages/assets/css',
src: ['*.css', '!*.min.css'],
dest: 'homepages/assets/css',
ext: '.min.css'
}
]
}
},
shell: {
apidocs: {
command: [
'cd docs',
'rm -Rf api _build/html/api _build/doctrees/api',
'make php',
].join('&&'),
options: {
stdout: true
}
},
sphinx: {
command: [
'cd docs',
'make html',
].join('&&'),
options: {
stdout: true
}
},
msmerge: {
command: [
'msgmerge -o lang/es_ES.po.merged lang/es_ES.po lang/largo.pot',
'mv lang/es_ES.po.merged lang/es_ES.po'
].join('&&')
}
},
watch: {
less: {
files: [
'less/**/*.less',
'less/**/**/*.less',
'homepages/assets/less/**/*.less'
],
tasks: [
'less:compile',
'cssmin'
]
},
sphinx: {
files: ['docs/*.rst', 'docs/*/*.rst'],
tasks: ['docs']
}
},
pot: {
options: {
text_domain: 'largo',
dest: 'lang/',
keywords: [ //WordPress localization functions
'__:1',
'_e:1',
'_x:1,2c',
'esc_html__:1',
'esc_html_e:1',
'esc_html_x:1,2c',
'esc_attr__:1',
'esc_attr_e:1',
'esc_attr_x:1,2c',
'_ex:1,2c',
'_n:1,2',
'_nx:1,2,4c',
'_n_noop:1,2',
'_nx_noop:1,2,3c'
]
},
files: {
src: '**/*.php',
expand: true
}
},
po2mo: {
files: {
src: 'lang/*.po',
expand: true
}
},
version: {
src: [
'package.json'
],
docs: {
src: [
'docs/conf.py'
]
},
css: {
options: {
prefix: 'Version: '
},
src: [
'style.css',
]
},
readme: {
options: {
prefix: '\\*\\*Current version:\\*\\* v'
},
src: [
'readme.md'
]
}
},
gittag: {
release: {
options: {
tag: 'v<%= pkg.version %>',
message: 'tagging v<%= pkg.version %>'
}
}
},
gitpush: {
release: {
options: {
tags: true,
branch: 'master'
}
}
},
gitmerge: {
release: {
options: {
branch: 'develop',
message: 'Merge branch develop to master'
}
}
},
gitcheckout: {
release: {
options: {
branch: 'master'
}
}
},
confirm: {
release: {
options: {
question: 'Are you sure you want to publish a release?',
input: 'yes,YES,y,Y'
}
}
}
});
// Build API docs only
grunt.registerTask('apidocs', ['shell:apidocs']);
// Build ALL docs
grunt.registerTask('docs', ['shell:sphinx']);
// Build assets, docs and language files
grunt.registerTask('build', 'Build assets, docs and language files', [
'less',
'cssmin',
'uglify',
'apidocs',
'docs',
'pot',
'shell:msmerge'
]);
// Increment version numbers and run a full build
grunt.registerTask('build-release', 'Increment version numbers (based on package.json) and run a full build', [
'version', 'build'
]);
// Checkout master, merge develop to master, tag and push to remote
grunt.registerTask('publish', 'Checkout master, merge develop to master, tag and push to remote', [
'confirm:release',
'gitcheckout:release',
'gitmerge:release',
'gittag:release',
'gitpush:release'
]);
}