1
|
|
|
/* jshint node:true */ |
|
|
|
|
2
|
|
|
module.exports = function( grunt ) { |
3
|
|
|
require( 'load-grunt-tasks' )( grunt ); |
4
|
|
|
|
5
|
|
|
// Project configuration. |
6
|
|
|
grunt.initConfig( { |
7
|
|
|
pkg: grunt.file.readJSON( 'package.json' ), |
8
|
|
|
|
9
|
|
|
// PHPLint |
|
|
|
|
10
|
|
|
phplint: { |
11
|
|
|
core: [ |
12
|
|
|
'**/*.php', |
13
|
|
|
'!build/**', |
14
|
|
|
'!deploy/**', |
15
|
|
|
'!includes/xmlseclibs/**', |
16
|
|
|
'!node_modules/**', |
17
|
|
|
'!repositories/**', |
18
|
|
|
'!vendor/**', |
19
|
|
|
'!wp-content/**', |
20
|
|
|
'!wordpress/**' |
21
|
|
|
], |
22
|
|
|
wp_pay: [ |
23
|
|
|
'vendor/wp-pay/**/*.php', |
24
|
|
|
'vendor/wp-pay-extensions/**/*.php', |
25
|
|
|
'vendor/wp-pay-gateways/**/*.php' |
26
|
|
|
] |
27
|
|
|
}, |
28
|
|
|
|
29
|
|
|
// PHP Code Sniffer. |
30
|
|
|
phpcs: { |
31
|
|
|
core: { |
32
|
|
|
src: [ |
33
|
|
|
'admin/**/*.php', |
34
|
|
|
'includes/**/*.php', |
35
|
|
|
'!includes/updates/**', |
36
|
|
|
'views/**/*.php', |
37
|
|
|
'pronamic-ideal.php', |
38
|
|
|
'uninstall.php' |
39
|
|
|
] |
40
|
|
|
}, |
41
|
|
|
options: { |
42
|
|
|
bin: 'vendor/bin/phpcs', |
43
|
|
|
standard: 'phpcs.xml.dist', |
44
|
|
|
showSniffCodes: true |
45
|
|
|
} |
46
|
|
|
}, |
47
|
|
|
|
48
|
|
|
// PHPUnit. |
49
|
|
|
phpunit: { |
50
|
|
|
options: { |
51
|
|
|
bin: 'vendor/bin/phpunit' |
52
|
|
|
}, |
53
|
|
|
classes: { |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
}, |
57
|
|
|
|
58
|
|
|
// JSHint. |
59
|
|
|
jshint: { |
60
|
|
|
options: grunt.file.readJSON( '.jshintrc' ), |
61
|
|
|
grunt: [ 'Gruntfile.js' ], |
62
|
|
|
plugin: [ |
63
|
|
|
'src/js/*.js' |
64
|
|
|
] |
65
|
|
|
}, |
66
|
|
|
|
67
|
|
|
// Sass Lint. |
68
|
|
|
sasslint: { |
69
|
|
|
options: { |
70
|
|
|
configFile: '.sass-lint.yml' |
71
|
|
|
}, |
72
|
|
|
target: [ |
73
|
|
|
'src/sass/**/*.scss' |
74
|
|
|
] |
75
|
|
|
}, |
76
|
|
|
|
77
|
|
|
// Check textdomain errors. |
78
|
|
|
checktextdomain: { |
79
|
|
|
options:{ |
80
|
|
|
text_domain: 'pronamic_ideal', |
81
|
|
|
keywords: [ |
82
|
|
|
'__:1,2d', |
83
|
|
|
'_e:1,2d', |
84
|
|
|
'_x:1,2c,3d', |
85
|
|
|
'esc_html__:1,2d', |
86
|
|
|
'esc_html_e:1,2d', |
87
|
|
|
'esc_html_x:1,2c,3d', |
88
|
|
|
'esc_attr__:1,2d', |
89
|
|
|
'esc_attr_e:1,2d', |
90
|
|
|
'esc_attr_x:1,2c,3d', |
91
|
|
|
'_ex:1,2c,3d', |
92
|
|
|
'_n:1,2,4d', |
93
|
|
|
'_nx:1,2,4c,5d', |
94
|
|
|
'_n_noop:1,2,3d', |
95
|
|
|
'_nx_noop:1,2,3c,4d' |
96
|
|
|
] |
97
|
|
|
}, |
98
|
|
|
files: { |
99
|
|
|
src: [ |
100
|
|
|
'**/*.php', |
101
|
|
|
'!build/**', |
102
|
|
|
'!deploy/**', |
103
|
|
|
'!node_modules/**', |
104
|
|
|
'!tests/**', |
105
|
|
|
'!wordpress/**', |
106
|
|
|
'!wp-content/**' |
107
|
|
|
], |
108
|
|
|
expand: true |
109
|
|
|
} |
110
|
|
|
}, |
111
|
|
|
|
112
|
|
|
// Make POT. |
113
|
|
|
makepot: { |
114
|
|
|
target: { |
115
|
|
|
options: { |
116
|
|
|
cwd: 'deploy/latest', |
117
|
|
|
domainPath: 'languages', |
118
|
|
|
type: 'wp-plugin', |
119
|
|
|
mainFile: 'pronamic-ideal.php', |
120
|
|
|
exclude: [ 'vendor/pronamic/.*' ], |
121
|
|
|
updatePoFiles: true, |
122
|
|
|
updateTimestamp: false |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
}, |
126
|
|
|
|
127
|
|
|
// Imagemin. |
128
|
|
|
imagemin: { |
129
|
|
|
build: { |
130
|
|
|
files: [ |
131
|
|
|
{ // Images |
|
|
|
|
132
|
|
|
expand: true, |
133
|
|
|
cwd: 'src/images/', |
134
|
|
|
src: ['**/*.{png,jpg,gif,svg,ico}'], |
135
|
|
|
dest: 'images/' |
136
|
|
|
} |
137
|
|
|
] |
138
|
|
|
} |
139
|
|
|
}, |
140
|
|
|
|
141
|
|
|
// Shell. |
142
|
|
|
shell: { |
143
|
|
|
// PlantUML. |
144
|
|
|
plantuml: { |
145
|
|
|
command: 'plantuml ./documentation/*.plantuml' |
146
|
|
|
}, |
147
|
|
|
|
148
|
|
|
// WordPress test environment. |
149
|
|
|
test: { |
150
|
|
|
command: 'bash tests/setup.sh' |
151
|
|
|
}, |
152
|
|
|
|
153
|
|
|
// Generate readme.txt. |
154
|
|
|
readme_txt: { |
155
|
|
|
command: 'php src/readme-txt/readme.php > readme.txt' |
156
|
|
|
}, |
157
|
|
|
|
158
|
|
|
// Generate README.md. |
159
|
|
|
readme_md: { |
160
|
|
|
command: 'php src/readme-md/README.php > README.md' |
161
|
|
|
}, |
162
|
|
|
|
163
|
|
|
// Generate CHANGELOG.md. |
164
|
|
|
changelog_md: { |
165
|
|
|
command: 'php src/changelog-md/CHANGELOG.php > CHANGELOG.md' |
166
|
|
|
}, |
167
|
|
|
|
168
|
|
|
// Composer. |
169
|
|
|
deploy: { |
170
|
|
|
command: [ |
171
|
|
|
'cd deploy/latest', |
172
|
|
|
'composer install --no-dev --prefer-dist' |
173
|
|
|
].join( '&&' ) |
174
|
|
|
} |
175
|
|
|
}, |
176
|
|
|
|
177
|
|
|
// Copy. |
178
|
|
|
copy: { |
179
|
|
|
scripts: { |
180
|
|
|
files: [ |
181
|
|
|
{ // JS. |
182
|
|
|
expand: true, |
183
|
|
|
cwd: 'src/js/', |
184
|
|
|
src: '**', |
185
|
|
|
dest: 'js/' |
186
|
|
|
} |
187
|
|
|
] |
188
|
|
|
}, |
189
|
|
|
assets: { |
190
|
|
|
files: [ |
191
|
|
|
{ // Flot - http://www.flotcharts.org/. |
192
|
|
|
expand: true, |
193
|
|
|
cwd: 'node_modules/flot/', |
194
|
|
|
src: [ |
195
|
|
|
'jquery.flot.js', |
196
|
|
|
'jquery.flot.time.js', |
197
|
|
|
'jquery.flot.resize.js' |
198
|
|
|
], |
199
|
|
|
dest: 'assets/flot' |
200
|
|
|
}, |
201
|
|
|
{ // accounting.js - http://openexchangerates.github.io/accounting.js/. |
202
|
|
|
expand: true, |
203
|
|
|
cwd: 'node_modules/accounting/', |
204
|
|
|
src: 'accounting.js', |
205
|
|
|
dest: 'assets/accounting' |
206
|
|
|
}, |
207
|
|
|
{ // Tippy.js - https://atomiks.github.io/tippyjs/. |
208
|
|
|
expand: true, |
209
|
|
|
cwd: 'node_modules/tippy.js/dist', |
210
|
|
|
src: 'tippy.all.js', |
211
|
|
|
dest: 'assets/tippy.js' |
212
|
|
|
} |
213
|
|
|
] |
214
|
|
|
}, |
215
|
|
|
other: { |
216
|
|
|
files: [ |
217
|
|
|
{ // extensions.json. |
218
|
|
|
expand: true, |
219
|
|
|
cwd: 'src/', |
220
|
|
|
src: [ |
221
|
|
|
'extensions.json' |
222
|
|
|
], |
223
|
|
|
dest: 'other/' |
224
|
|
|
} |
225
|
|
|
] |
226
|
|
|
}, |
227
|
|
|
deploy: { |
228
|
|
|
expand: true, |
229
|
|
|
src: [ |
230
|
|
|
'**', |
231
|
|
|
'!composer.lock', |
232
|
|
|
'!Gruntfile.js', |
233
|
|
|
'!package.json', |
234
|
|
|
'!package-lock.json', |
235
|
|
|
'!phpdoc.dist.xml', |
236
|
|
|
'!phpunit.xml', |
237
|
|
|
'!phpunit.xml.dist', |
238
|
|
|
'!phpcs.xml.dist', |
239
|
|
|
'!CHANGELOG.md', |
240
|
|
|
'!README.md', |
241
|
|
|
'!yarn.lock', |
242
|
|
|
'!build/**', |
243
|
|
|
'!deploy/**', |
244
|
|
|
'!etc/**', |
245
|
|
|
'!documentation/**', |
246
|
|
|
'!node_modules/**', |
247
|
|
|
'!repositories/**', |
248
|
|
|
'!src/**', |
249
|
|
|
'!tests/**', |
250
|
|
|
'!vendor/**', |
251
|
|
|
'!wordpress/**', |
252
|
|
|
'!wp-content/**' |
253
|
|
|
], |
254
|
|
|
dest: 'deploy/latest/' |
255
|
|
|
}, |
256
|
|
|
pot_to_dev: { |
257
|
|
|
expand: true, |
258
|
|
|
cwd: 'deploy/latest/languages/', |
259
|
|
|
src: '**', |
260
|
|
|
dest: 'languages/' |
261
|
|
|
} |
262
|
|
|
}, |
263
|
|
|
|
264
|
|
|
// Composer. |
265
|
|
|
composer : { |
266
|
|
|
options : { |
267
|
|
|
|
268
|
|
|
}, |
269
|
|
|
some_target: { |
270
|
|
|
options : { |
271
|
|
|
cwd: 'deploy/latest' |
272
|
|
|
} |
273
|
|
|
} |
274
|
|
|
}, |
275
|
|
|
|
276
|
|
|
// SASS. |
277
|
|
|
sass: { |
278
|
|
|
options: { |
279
|
|
|
style: 'expanded' |
280
|
|
|
}, |
281
|
|
|
build: { |
282
|
|
|
files: [ { |
283
|
|
|
expand: true, |
284
|
|
|
cwd: 'src/sass', |
285
|
|
|
src: '*.scss', |
286
|
|
|
dest: 'src/css', |
287
|
|
|
ext: '.css' |
288
|
|
|
} ] |
289
|
|
|
} |
290
|
|
|
}, |
291
|
|
|
|
292
|
|
|
// PostCSS. |
293
|
|
|
postcss: { |
294
|
|
|
options: { |
295
|
|
|
map: false |
296
|
|
|
}, |
297
|
|
|
prefix: { |
298
|
|
|
options: { |
299
|
|
|
processors: [ |
300
|
|
|
require( 'autoprefixer' )(), |
301
|
|
|
require( 'postcss-eol' )() |
302
|
|
|
] |
303
|
|
|
}, |
304
|
|
|
files: [ { |
305
|
|
|
expand: true, |
306
|
|
|
cwd: 'src/css/', |
307
|
|
|
src: '*.css', |
308
|
|
|
dest: 'css/' |
309
|
|
|
} ] |
310
|
|
|
}, |
311
|
|
|
min: { |
312
|
|
|
options: { |
313
|
|
|
processors: [ |
314
|
|
|
require( 'cssnano' )(), |
315
|
|
|
require( 'postcss-eol' )() |
316
|
|
|
] |
317
|
|
|
}, |
318
|
|
|
files: [ { |
319
|
|
|
expand: true, |
320
|
|
|
cwd: 'css/', |
321
|
|
|
src: [ |
322
|
|
|
'*.css', |
323
|
|
|
'!*.min.css' |
324
|
|
|
], |
325
|
|
|
dest: 'css/', |
326
|
|
|
ext: '.min.css' |
327
|
|
|
} ] |
328
|
|
|
} |
329
|
|
|
}, |
330
|
|
|
|
331
|
|
|
// Uglify. |
332
|
|
|
uglify: { |
333
|
|
|
scripts: { |
334
|
|
|
files: { |
335
|
|
|
// Pronamic Pay. |
336
|
|
|
'js/admin.min.js': 'src/js/admin.js', |
337
|
|
|
'js/admin-reports.min.js': 'src/js/admin-reports.js', |
338
|
|
|
'js/admin-tour.min.js': 'src/js/admin-tour.js', |
339
|
|
|
// Accounting. |
340
|
|
|
'assets/accounting/accounting.min.js': 'assets/accounting/accounting.js', |
341
|
|
|
// Flot. |
342
|
|
|
'assets/flot/jquery.flot.min.js': 'assets/flot/jquery.flot.js', |
343
|
|
|
'assets/flot/jquery.flot.resize.min.js': 'assets/flot/jquery.flot.resize.js', |
344
|
|
|
'assets/flot/jquery.flot.time.min.js': 'assets/flot/jquery.flot.time.js', |
345
|
|
|
// Tippy.js. |
346
|
|
|
'assets/tippy.js/tippy.all.min.js': 'assets/tippy.js/tippy.all.js' |
347
|
|
|
} |
348
|
|
|
} |
349
|
|
|
}, |
350
|
|
|
|
351
|
|
|
// Clean. |
352
|
|
|
clean: { |
353
|
|
|
assets: { |
354
|
|
|
src: [ |
355
|
|
|
'assets', |
356
|
|
|
'css', |
357
|
|
|
'images', |
358
|
|
|
'js' |
359
|
|
|
] |
360
|
|
|
}, |
361
|
|
|
deploy: { |
362
|
|
|
src: [ 'deploy/latest' ] |
363
|
|
|
}, |
364
|
|
|
deploy_composer: { |
365
|
|
|
src: [ |
366
|
|
|
'deploy/latest/vendor/pronamic/*/bin/**', |
367
|
|
|
'deploy/latest/vendor/pronamic/*/documentation', |
368
|
|
|
'deploy/latest/vendor/pronamic/*/test/**', |
369
|
|
|
'deploy/latest/vendor/pronamic/*/tests/**', |
370
|
|
|
'deploy/latest/vendor/pronamic/*/.gitignore', |
371
|
|
|
'deploy/latest/vendor/pronamic/*/.travis.yml', |
372
|
|
|
'deploy/latest/vendor/pronamic/*/composer.lock', |
373
|
|
|
'deploy/latest/vendor/pronamic/*/Gruntfile.js', |
374
|
|
|
'deploy/latest/vendor/pronamic/*/package.json', |
375
|
|
|
'deploy/latest/vendor/pronamic/*/package-lock.json', |
376
|
|
|
'deploy/latest/vendor/pronamic/*/phpcs.ruleset.xml', |
377
|
|
|
'deploy/latest/vendor/pronamic/*/phpcs.xml.dist', |
378
|
|
|
'deploy/latest/vendor/pronamic/*/phpmd.ruleset.xml', |
379
|
|
|
'deploy/latest/vendor/pronamic/*/phpunit.xml.dist', |
380
|
|
|
'deploy/latest/vendor/pronamic/*/yarn.lock', |
381
|
|
|
'deploy/latest/vendor/wp-pay*/*/bin/**', |
382
|
|
|
'deploy/latest/vendor/wp-pay*/*/documentation', |
383
|
|
|
'deploy/latest/vendor/wp-pay*/*/test/**', |
384
|
|
|
'deploy/latest/vendor/wp-pay*/*/tests/**', |
385
|
|
|
'deploy/latest/vendor/wp-pay*/*/.gitignore', |
386
|
|
|
'deploy/latest/vendor/wp-pay*/*/.travis.yml', |
387
|
|
|
'deploy/latest/vendor/wp-pay*/*/composer.lock', |
388
|
|
|
'deploy/latest/vendor/wp-pay*/*/Gruntfile.js', |
389
|
|
|
'deploy/latest/vendor/wp-pay*/*/package.json', |
390
|
|
|
'deploy/latest/vendor/wp-pay*/*/package-lock.json', |
391
|
|
|
'deploy/latest/vendor/wp-pay*/*/phpcs.ruleset.xml', |
392
|
|
|
'deploy/latest/vendor/wp-pay*/*/phpcs.xml.dist', |
393
|
|
|
'deploy/latest/vendor/wp-pay*/*/phpmd.ruleset.xml', |
394
|
|
|
'deploy/latest/vendor/wp-pay*/*/phpunit.xml.dist', |
395
|
|
|
'deploy/latest/vendor/wp-pay*/*/yarn.lock' |
396
|
|
|
] |
397
|
|
|
}, |
398
|
|
|
deploy_wp_content: { |
399
|
|
|
src: [ |
400
|
|
|
'deploy/latest/wp-content' |
401
|
|
|
] |
402
|
|
|
} |
403
|
|
|
}, |
404
|
|
|
|
405
|
|
|
// Compress. |
406
|
|
|
compress: { |
407
|
|
|
deploy: { |
408
|
|
|
options: { |
409
|
|
|
archive: 'deploy/archives/<%= pkg.name %>.<%= pkg.version %>.zip' |
410
|
|
|
}, |
411
|
|
|
expand: true, |
412
|
|
|
cwd: 'deploy/latest', |
413
|
|
|
src: ['**/*'], |
414
|
|
|
dest: '<%= pkg.name %>/' |
415
|
|
|
} |
416
|
|
|
}, |
417
|
|
|
|
418
|
|
|
// Git checkout. |
419
|
|
|
gitcheckout: { |
420
|
|
|
tag: { |
421
|
|
|
options: { |
422
|
|
|
branch: 'tags/<%= pkg.version %>' |
423
|
|
|
} |
424
|
|
|
}, |
425
|
|
|
develop: { |
426
|
|
|
options: { |
427
|
|
|
branch: 'develop' |
428
|
|
|
} |
429
|
|
|
} |
430
|
|
|
}, |
431
|
|
|
|
432
|
|
|
// S3. |
433
|
|
|
aws_s3: { |
434
|
|
|
options: { |
435
|
|
|
region: 'eu-central-1' |
436
|
|
|
}, |
437
|
|
|
deploy: { |
438
|
|
|
options: { |
439
|
|
|
bucket: 'downloads.pronamic.eu', |
440
|
|
|
differential: true |
441
|
|
|
}, |
442
|
|
|
files: [ |
443
|
|
|
{ |
444
|
|
|
expand: true, |
445
|
|
|
cwd: 'deploy/archives/', |
446
|
|
|
src: '<%= pkg.name %>.<%= pkg.version %>.zip', |
447
|
|
|
dest: 'plugins/<%= pkg.name %>/' |
448
|
|
|
} |
449
|
|
|
] |
450
|
|
|
} |
451
|
|
|
}, |
452
|
|
|
|
453
|
|
|
// WordPress deploy. |
454
|
|
|
rt_wp_deploy: { |
455
|
|
|
app: { |
456
|
|
|
options: { |
457
|
|
|
svnUrl: 'http://plugins.svn.wordpress.org/<%= pkg.name %>/', |
458
|
|
|
svnDir: 'deploy/wp-svn', |
459
|
|
|
svnUsername: 'pronamic', |
460
|
|
|
deployDir: 'deploy/latest', |
461
|
|
|
version: '<%= pkg.version %>' |
462
|
|
|
} |
463
|
|
|
} |
464
|
|
|
}, |
465
|
|
|
|
466
|
|
|
webfont: { |
467
|
|
|
icons: { |
468
|
|
|
src: 'src/fonts/images/*.svg', |
469
|
|
|
dest: 'fonts', |
470
|
|
|
options: { |
471
|
|
|
font: 'pronamic-pay-icons', |
472
|
|
|
fontFamilyName: 'Pronamic Pay Icons', |
473
|
|
|
normalize: true, |
474
|
|
|
stylesheets: [ 'css' ], |
475
|
|
|
templateOptions: { |
476
|
|
|
baseClass: 'pronamic-pay-icon', |
477
|
|
|
classPrefix: 'pronamic-pay-icon-' |
478
|
|
|
}, |
479
|
|
|
types: [ 'eot', 'woff2', 'woff', 'ttf', 'svg' ], |
480
|
|
|
fontHeight: 768, |
481
|
|
|
customOutputs: [ { |
482
|
|
|
template: 'src/fonts/templates/variables.scss', |
483
|
|
|
dest: 'src/fonts/_variables.scss' |
484
|
|
|
} ] |
485
|
|
|
} |
486
|
|
|
} |
487
|
|
|
} |
488
|
|
|
} ); |
489
|
|
|
|
490
|
|
|
// Default task(s). |
491
|
|
|
grunt.registerTask( 'default', [ 'jshint', 'phplint', 'phpcs', 'phpunit' ] ); |
492
|
|
|
grunt.registerTask( 'assets', [ 'sasslint', 'sass', 'postcss', 'copy:scripts', 'copy:assets', 'copy:other' ] ); |
493
|
|
|
grunt.registerTask( 'min', [ 'uglify', 'imagemin' ] ); |
494
|
|
|
grunt.registerTask( 'plantuml', [ 'shell:plantuml' ] ); |
495
|
|
|
grunt.registerTask( 'pot', [ 'build_latest', 'makepot', 'copy:pot_to_dev' ] ); |
496
|
|
|
|
497
|
|
|
grunt.registerTask( 'build_docs', [ |
498
|
|
|
'shell:readme_txt', |
499
|
|
|
'shell:readme_md', |
500
|
|
|
'shell:changelog_md' |
501
|
|
|
] ); |
502
|
|
|
|
503
|
|
|
grunt.registerTask( 'build_assets', [ |
504
|
|
|
'clean:assets', |
505
|
|
|
'assets', |
506
|
|
|
'min' |
507
|
|
|
] ); |
508
|
|
|
|
509
|
|
|
grunt.registerTask( 'build_latest', [ |
510
|
|
|
'clean:deploy', |
511
|
|
|
'copy:deploy', |
512
|
|
|
'shell:deploy', |
513
|
|
|
'clean:deploy_composer', |
514
|
|
|
'clean:deploy_wp_content' |
515
|
|
|
] ); |
516
|
|
|
|
517
|
|
|
grunt.registerTask( 'deploy', [ |
518
|
|
|
'default', |
519
|
|
|
'build_docs', |
520
|
|
|
'build_assets', |
521
|
|
|
'build_latest', |
522
|
|
|
'makepot', |
523
|
|
|
'copy:pot_to_dev', |
524
|
|
|
'compress:deploy' |
525
|
|
|
] ); |
526
|
|
|
|
527
|
|
|
grunt.registerTask( 'wp-deploy', [ |
528
|
|
|
'gitcheckout:tag', |
529
|
|
|
'deploy', |
530
|
|
|
'rt_wp_deploy', |
531
|
|
|
'gitcheckout:develop' |
532
|
|
|
] ); |
533
|
|
|
|
534
|
|
|
grunt.registerTask( 's3-deploy', [ |
535
|
|
|
'gitcheckout:tag', |
536
|
|
|
'deploy', |
537
|
|
|
'aws_s3:deploy', |
538
|
|
|
'gitcheckout:develop' |
539
|
|
|
] ); |
540
|
|
|
}; |
541
|
|
|
|