1 | /* jshint node:true */ |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
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 |
||
0 ignored issues
–
show
|
|||
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 |
||
0 ignored issues
–
show
|
|||
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 | '!build/**', |
||
242 | '!deploy/**', |
||
243 | '!etc/**', |
||
244 | '!documentation/**', |
||
245 | '!node_modules/**', |
||
246 | '!repositories/**', |
||
247 | '!src/**', |
||
248 | '!tests/**', |
||
249 | '!vendor/**', |
||
250 | '!wordpress/**', |
||
251 | '!wp-content/**' |
||
252 | ], |
||
253 | dest: 'deploy/latest/' |
||
254 | }, |
||
255 | pot_to_dev: { |
||
256 | expand: true, |
||
257 | cwd: 'deploy/latest/languages/', |
||
258 | src: '**', |
||
259 | dest: 'languages/' |
||
260 | } |
||
261 | }, |
||
262 | |||
263 | // Composer. |
||
264 | composer : { |
||
265 | options : { |
||
266 | |||
267 | }, |
||
268 | some_target: { |
||
269 | options : { |
||
270 | cwd: 'deploy/latest' |
||
271 | } |
||
272 | } |
||
273 | }, |
||
274 | |||
275 | // SASS. |
||
276 | sass: { |
||
277 | options: { |
||
278 | style: 'expanded' |
||
279 | }, |
||
280 | build: { |
||
281 | files: [ { |
||
282 | expand: true, |
||
283 | cwd: 'src/sass', |
||
284 | src: '*.scss', |
||
285 | dest: 'src/css', |
||
286 | ext: '.css' |
||
287 | } ] |
||
288 | } |
||
289 | }, |
||
290 | |||
291 | // PostCSS. |
||
292 | postcss: { |
||
293 | options: { |
||
294 | map: false |
||
295 | }, |
||
296 | prefix: { |
||
297 | options: { |
||
298 | processors: [ |
||
299 | require( 'autoprefixer' )(), |
||
300 | require( 'postcss-eol' )() |
||
301 | ] |
||
302 | }, |
||
303 | files: [ { |
||
304 | expand: true, |
||
305 | cwd: 'src/css/', |
||
306 | src: '*.css', |
||
307 | dest: 'css/' |
||
308 | } ] |
||
309 | }, |
||
310 | min: { |
||
311 | options: { |
||
312 | processors: [ |
||
313 | require( 'cssnano' )(), |
||
314 | require( 'postcss-eol' )() |
||
315 | ] |
||
316 | }, |
||
317 | files: [ { |
||
318 | expand: true, |
||
319 | cwd: 'css/', |
||
320 | src: [ |
||
321 | '*.css', |
||
322 | '!*.min.css' |
||
323 | ], |
||
324 | dest: 'css/', |
||
325 | ext: '.min.css' |
||
326 | } ] |
||
327 | } |
||
328 | }, |
||
329 | |||
330 | // Uglify. |
||
331 | uglify: { |
||
332 | scripts: { |
||
333 | files: { |
||
334 | // Pronamic Pay. |
||
335 | 'js/admin.min.js': 'src/js/admin.js', |
||
336 | 'js/admin-reports.min.js': 'src/js/admin-reports.js', |
||
337 | 'js/admin-tour.min.js': 'src/js/admin-tour.js', |
||
338 | // Accounting. |
||
339 | 'assets/accounting/accounting.min.js': 'assets/accounting/accounting.js', |
||
340 | // Flot. |
||
341 | 'assets/flot/jquery.flot.min.js': 'assets/flot/jquery.flot.js', |
||
342 | 'assets/flot/jquery.flot.resize.min.js': 'assets/flot/jquery.flot.resize.js', |
||
343 | 'assets/flot/jquery.flot.time.min.js': 'assets/flot/jquery.flot.time.js', |
||
344 | // Tippy.js. |
||
345 | 'assets/tippy.js/tippy.all.min.js': 'assets/tippy.js/tippy.all.js' |
||
346 | } |
||
347 | } |
||
348 | }, |
||
349 | |||
350 | // Clean. |
||
351 | clean: { |
||
352 | assets: { |
||
353 | src: [ |
||
354 | 'assets', |
||
355 | 'css', |
||
356 | 'images', |
||
357 | 'js' |
||
358 | ] |
||
359 | }, |
||
360 | deploy: { |
||
361 | src: [ 'deploy/latest' ] |
||
362 | }, |
||
363 | deploy_composer: { |
||
364 | src: [ |
||
365 | 'deploy/latest/vendor/pronamic/*/bin/**', |
||
366 | 'deploy/latest/vendor/pronamic/*/documentation', |
||
367 | 'deploy/latest/vendor/pronamic/*/test/**', |
||
368 | 'deploy/latest/vendor/pronamic/*/tests/**', |
||
369 | 'deploy/latest/vendor/pronamic/*/.gitignore', |
||
370 | 'deploy/latest/vendor/pronamic/*/.travis.yml', |
||
371 | 'deploy/latest/vendor/pronamic/*/composer.lock', |
||
372 | 'deploy/latest/vendor/pronamic/*/Gruntfile.js', |
||
373 | 'deploy/latest/vendor/pronamic/*/package.json', |
||
374 | 'deploy/latest/vendor/pronamic/*/package-lock.json', |
||
375 | 'deploy/latest/vendor/pronamic/*/phpcs.ruleset.xml', |
||
376 | 'deploy/latest/vendor/pronamic/*/phpcs.xml.dist', |
||
377 | 'deploy/latest/vendor/pronamic/*/phpmd.ruleset.xml', |
||
378 | 'deploy/latest/vendor/pronamic/*/phpunit.xml.dist', |
||
379 | 'deploy/latest/vendor/wp-pay*/*/bin/**', |
||
380 | 'deploy/latest/vendor/wp-pay*/*/documentation', |
||
381 | 'deploy/latest/vendor/wp-pay*/*/test/**', |
||
382 | 'deploy/latest/vendor/wp-pay*/*/tests/**', |
||
383 | 'deploy/latest/vendor/wp-pay*/*/.gitignore', |
||
384 | 'deploy/latest/vendor/wp-pay*/*/.travis.yml', |
||
385 | 'deploy/latest/vendor/wp-pay*/*/composer.lock', |
||
386 | 'deploy/latest/vendor/wp-pay*/*/Gruntfile.js', |
||
387 | 'deploy/latest/vendor/wp-pay*/*/package.json', |
||
388 | 'deploy/latest/vendor/wp-pay*/*/package-lock.json', |
||
389 | 'deploy/latest/vendor/wp-pay*/*/phpcs.ruleset.xml', |
||
390 | 'deploy/latest/vendor/wp-pay*/*/phpcs.xml.dist', |
||
391 | 'deploy/latest/vendor/wp-pay*/*/phpmd.ruleset.xml', |
||
392 | 'deploy/latest/vendor/wp-pay*/*/phpunit.xml.dist' |
||
393 | ] |
||
394 | }, |
||
395 | deploy_wp_content: { |
||
396 | src: [ |
||
397 | 'deploy/latest/wp-content' |
||
398 | ] |
||
399 | } |
||
400 | }, |
||
401 | |||
402 | // Compress. |
||
403 | compress: { |
||
404 | deploy: { |
||
405 | options: { |
||
406 | archive: 'deploy/archives/<%= pkg.name %>.<%= pkg.version %>.zip' |
||
407 | }, |
||
408 | expand: true, |
||
409 | cwd: 'deploy/latest', |
||
410 | src: ['**/*'], |
||
411 | dest: '<%= pkg.name %>/' |
||
412 | } |
||
413 | }, |
||
414 | |||
415 | // Git checkout. |
||
416 | gitcheckout: { |
||
417 | tag: { |
||
418 | options: { |
||
419 | branch: 'tags/<%= pkg.version %>' |
||
420 | } |
||
421 | }, |
||
422 | develop: { |
||
423 | options: { |
||
424 | branch: 'develop' |
||
425 | } |
||
426 | } |
||
427 | }, |
||
428 | |||
429 | // S3. |
||
430 | aws_s3: { |
||
431 | options: { |
||
432 | region: 'eu-central-1' |
||
433 | }, |
||
434 | deploy: { |
||
435 | options: { |
||
436 | bucket: 'downloads.pronamic.eu', |
||
437 | differential: true |
||
438 | }, |
||
439 | files: [ |
||
440 | { |
||
441 | expand: true, |
||
442 | cwd: 'deploy/archives/', |
||
443 | src: '<%= pkg.name %>.<%= pkg.version %>.zip', |
||
444 | dest: 'plugins/<%= pkg.name %>/' |
||
445 | } |
||
446 | ] |
||
447 | } |
||
448 | }, |
||
449 | |||
450 | // WordPress deploy. |
||
451 | rt_wp_deploy: { |
||
452 | app: { |
||
453 | options: { |
||
454 | svnUrl: 'http://plugins.svn.wordpress.org/<%= pkg.name %>/', |
||
455 | svnDir: 'deploy/wp-svn', |
||
456 | svnUsername: 'pronamic', |
||
457 | deployDir: 'deploy/latest', |
||
458 | version: '<%= pkg.version %>' |
||
459 | } |
||
460 | } |
||
461 | }, |
||
462 | |||
463 | webfont: { |
||
464 | icons: { |
||
465 | src: 'src/fonts/images/*.svg', |
||
466 | dest: 'fonts', |
||
467 | options: { |
||
468 | font: 'pronamic-pay-icons', |
||
469 | fontFamilyName: 'Pronamic Pay Icons', |
||
470 | normalize: true, |
||
471 | stylesheets: [ 'css' ], |
||
472 | templateOptions: { |
||
473 | baseClass: 'pronamic-pay-icon', |
||
474 | classPrefix: 'pronamic-pay-icon-' |
||
475 | }, |
||
476 | types: [ 'eot', 'woff2', 'woff', 'ttf', 'svg' ], |
||
477 | fontHeight: 768, |
||
478 | customOutputs: [ { |
||
479 | template: 'src/fonts/templates/variables.scss', |
||
480 | dest: 'src/fonts/_variables.scss' |
||
481 | } ] |
||
482 | } |
||
483 | } |
||
484 | } |
||
485 | } ); |
||
486 | |||
487 | // Default task(s). |
||
488 | grunt.registerTask( 'default', [ 'jshint', 'phplint', 'phpcs', 'phpunit' ] ); |
||
489 | grunt.registerTask( 'assets', [ 'sasslint', 'sass', 'postcss', 'copy:scripts', 'copy:assets', 'copy:other' ] ); |
||
490 | grunt.registerTask( 'min', [ 'uglify', 'imagemin' ] ); |
||
491 | grunt.registerTask( 'plantuml', [ 'shell:plantuml' ] ); |
||
492 | grunt.registerTask( 'pot', [ 'build_latest', 'makepot', 'copy:pot_to_dev' ] ); |
||
493 | |||
494 | grunt.registerTask( 'build_docs', [ |
||
495 | 'shell:readme_txt', |
||
496 | 'shell:readme_md', |
||
497 | 'shell:changelog_md' |
||
498 | ] ); |
||
499 | |||
500 | grunt.registerTask( 'build_assets', [ |
||
501 | 'clean:assets', |
||
502 | 'assets', |
||
503 | 'min' |
||
504 | ] ); |
||
505 | |||
506 | grunt.registerTask( 'build_latest', [ |
||
507 | 'clean:deploy', |
||
508 | 'copy:deploy', |
||
509 | 'shell:deploy', |
||
510 | 'clean:deploy_composer', |
||
511 | 'clean:deploy_wp_content' |
||
512 | ] ); |
||
513 | |||
514 | grunt.registerTask( 'deploy', [ |
||
515 | 'default', |
||
516 | 'build_docs', |
||
517 | 'build_assets', |
||
518 | 'build_latest', |
||
519 | 'makepot', |
||
520 | 'copy:pot_to_dev', |
||
521 | 'compress:deploy' |
||
522 | ] ); |
||
523 | |||
524 | grunt.registerTask( 'wp-deploy', [ |
||
525 | 'gitcheckout:tag', |
||
526 | 'deploy', |
||
527 | 'rt_wp_deploy', |
||
528 | 'gitcheckout:develop' |
||
529 | ] ); |
||
530 | |||
531 | grunt.registerTask( 's3-deploy', [ |
||
532 | 'gitcheckout:tag', |
||
533 | 'deploy', |
||
534 | 'aws_s3:deploy', |
||
535 | 'gitcheckout:develop' |
||
536 | ] ); |
||
537 | }; |
||
538 |