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 | // Make POT. |
||
144 | makepot: { |
||
145 | command: 'wp pronamic i18n make-pot . languages/pronamic_ideal.pot --slug="pronamic-ideal"' |
||
146 | }, |
||
147 | |||
148 | msgmerge: { |
||
149 | command: 'find languages/*.po -type f -exec msgmerge --update {} languages/pronamic_ideal.pot \\;' |
||
150 | }, |
||
151 | |||
152 | // PlantUML. |
||
153 | plantuml: { |
||
154 | command: 'plantuml ./documentation/*.plantuml' |
||
155 | }, |
||
156 | |||
157 | // WordPress test environment. |
||
158 | test: { |
||
159 | command: 'bash tests/setup.sh' |
||
160 | }, |
||
161 | |||
162 | // Generate readme.txt. |
||
163 | readme_txt: { |
||
164 | command: 'php src/readme-txt/readme.php > readme.txt' |
||
165 | }, |
||
166 | |||
167 | // Generate README.md. |
||
168 | readme_md: { |
||
169 | command: 'php src/readme-md/README.php > README.md' |
||
170 | }, |
||
171 | |||
172 | // Generate CHANGELOG.md. |
||
173 | changelog_md: { |
||
174 | command: 'php src/changelog-md/CHANGELOG.php > CHANGELOG.md' |
||
175 | }, |
||
176 | |||
177 | // Composer. |
||
178 | deploy: { |
||
179 | command: [ |
||
180 | 'cd deploy/latest', |
||
181 | 'composer install --no-dev --prefer-dist' |
||
182 | ].join( '&&' ) |
||
183 | } |
||
184 | }, |
||
185 | |||
186 | // Copy. |
||
187 | copy: { |
||
188 | scripts: { |
||
189 | files: [ |
||
190 | { // JS. |
||
191 | expand: true, |
||
192 | cwd: 'src/js/', |
||
193 | src: '**', |
||
194 | dest: 'js/' |
||
195 | } |
||
196 | ] |
||
197 | }, |
||
198 | assets: { |
||
199 | files: [ |
||
200 | { // Flot - http://www.flotcharts.org/. |
||
201 | expand: true, |
||
202 | cwd: 'node_modules/Flot/', |
||
203 | src: [ |
||
204 | 'jquery.flot.js', |
||
205 | 'jquery.flot.time.js', |
||
206 | 'jquery.flot.resize.js' |
||
207 | ], |
||
208 | dest: 'assets/flot' |
||
209 | }, |
||
210 | { // accounting.js - http://openexchangerates.github.io/accounting.js/. |
||
211 | expand: true, |
||
212 | cwd: 'node_modules/accounting/', |
||
213 | src: 'accounting.js', |
||
214 | dest: 'assets/accounting' |
||
215 | }, |
||
216 | { // Tippy.js - https://atomiks.github.io/tippyjs/. |
||
217 | expand: true, |
||
218 | cwd: 'node_modules/tippy.js/dist', |
||
219 | src: 'tippy.all.js', |
||
220 | dest: 'assets/tippy.js' |
||
221 | } |
||
222 | ] |
||
223 | }, |
||
224 | other: { |
||
225 | files: [ |
||
226 | { // extensions.json. |
||
227 | expand: true, |
||
228 | cwd: 'src/', |
||
229 | src: [ |
||
230 | 'extensions.json' |
||
231 | ], |
||
232 | dest: 'other/' |
||
233 | } |
||
234 | ] |
||
235 | }, |
||
236 | deploy: { |
||
237 | expand: true, |
||
238 | src: [ |
||
239 | '**', |
||
240 | '!composer.lock', |
||
241 | '!Gruntfile.js', |
||
242 | '!package.json', |
||
243 | '!package-lock.json', |
||
244 | '!phpdoc.dist.xml', |
||
245 | '!phpunit.xml', |
||
246 | '!phpunit.xml.dist', |
||
247 | '!phpcs.xml.dist', |
||
248 | '!CHANGELOG.md', |
||
249 | '!README.md', |
||
250 | '!wp-cli.yml', |
||
251 | '!build/**', |
||
252 | '!deploy/**', |
||
253 | '!etc/**', |
||
254 | '!documentation/**', |
||
255 | '!node_modules/**', |
||
256 | '!repositories/**', |
||
257 | '!src/**', |
||
258 | '!tests/**', |
||
259 | '!vendor/**', |
||
260 | '!wordpress/**', |
||
261 | '!wp-content/**' |
||
262 | ], |
||
263 | dest: 'deploy/latest/' |
||
264 | }, |
||
265 | pot_to_dev: { |
||
266 | expand: true, |
||
267 | cwd: 'deploy/latest/languages/', |
||
268 | src: '**', |
||
269 | dest: 'languages/' |
||
270 | } |
||
271 | }, |
||
272 | |||
273 | // Composer. |
||
274 | composer : { |
||
275 | options : { |
||
276 | |||
277 | }, |
||
278 | some_target: { |
||
279 | options : { |
||
280 | cwd: 'deploy/latest' |
||
281 | } |
||
282 | } |
||
283 | }, |
||
284 | |||
285 | // SASS. |
||
286 | sass: { |
||
287 | options: { |
||
288 | style: 'expanded' |
||
289 | }, |
||
290 | build: { |
||
291 | files: [ { |
||
292 | expand: true, |
||
293 | cwd: 'src/sass', |
||
294 | src: '*.scss', |
||
295 | dest: 'src/css', |
||
296 | ext: '.css' |
||
297 | } ] |
||
298 | } |
||
299 | }, |
||
300 | |||
301 | // PostCSS. |
||
302 | postcss: { |
||
303 | options: { |
||
304 | map: false |
||
305 | }, |
||
306 | prefix: { |
||
307 | options: { |
||
308 | processors: [ |
||
309 | require( 'autoprefixer' )(), |
||
310 | require( 'postcss-eol' )() |
||
311 | ] |
||
312 | }, |
||
313 | files: [ { |
||
314 | expand: true, |
||
315 | cwd: 'src/css/', |
||
316 | src: '*.css', |
||
317 | dest: 'css/' |
||
318 | } ] |
||
319 | }, |
||
320 | min: { |
||
321 | options: { |
||
322 | processors: [ |
||
323 | require( 'cssnano' )(), |
||
324 | require( 'postcss-eol' )() |
||
325 | ] |
||
326 | }, |
||
327 | files: [ { |
||
328 | expand: true, |
||
329 | cwd: 'css/', |
||
330 | src: [ |
||
331 | '*.css', |
||
332 | '!*.min.css' |
||
333 | ], |
||
334 | dest: 'css/', |
||
335 | ext: '.min.css' |
||
336 | } ] |
||
337 | } |
||
338 | }, |
||
339 | |||
340 | // Uglify. |
||
341 | uglify: { |
||
342 | scripts: { |
||
343 | files: { |
||
344 | // Pronamic Pay. |
||
345 | 'js/admin.min.js': 'src/js/admin.js', |
||
346 | 'js/admin-reports.min.js': 'src/js/admin-reports.js', |
||
347 | 'js/admin-tour.min.js': 'src/js/admin-tour.js', |
||
348 | // Accounting. |
||
349 | 'assets/accounting/accounting.min.js': 'assets/accounting/accounting.js', |
||
350 | // Flot. |
||
351 | 'assets/flot/jquery.flot.min.js': 'assets/flot/jquery.flot.js', |
||
352 | 'assets/flot/jquery.flot.resize.min.js': 'assets/flot/jquery.flot.resize.js', |
||
353 | 'assets/flot/jquery.flot.time.min.js': 'assets/flot/jquery.flot.time.js', |
||
354 | // Tippy.js. |
||
355 | 'assets/tippy.js/tippy.all.min.js': 'assets/tippy.js/tippy.all.js' |
||
356 | } |
||
357 | } |
||
358 | }, |
||
359 | |||
360 | // Clean. |
||
361 | clean: { |
||
362 | assets: { |
||
363 | src: [ |
||
364 | 'assets', |
||
365 | 'css', |
||
366 | 'images', |
||
367 | 'js' |
||
368 | ] |
||
369 | }, |
||
370 | deploy: { |
||
371 | src: [ 'deploy/latest' ] |
||
372 | }, |
||
373 | deploy_composer: { |
||
374 | src: [ |
||
375 | 'deploy/latest/vendor/pronamic/*/bin/**', |
||
376 | 'deploy/latest/vendor/pronamic/*/documentation', |
||
377 | 'deploy/latest/vendor/pronamic/*/test/**', |
||
378 | 'deploy/latest/vendor/pronamic/*/tests/**', |
||
379 | 'deploy/latest/vendor/pronamic/*/.gitignore', |
||
380 | 'deploy/latest/vendor/pronamic/*/.travis.yml', |
||
381 | 'deploy/latest/vendor/pronamic/*/composer.lock', |
||
382 | 'deploy/latest/vendor/pronamic/*/Gruntfile.js', |
||
383 | 'deploy/latest/vendor/pronamic/*/package.json', |
||
384 | 'deploy/latest/vendor/pronamic/*/package-lock.json', |
||
385 | 'deploy/latest/vendor/pronamic/*/phpcs.ruleset.xml', |
||
386 | 'deploy/latest/vendor/pronamic/*/phpcs.xml.dist', |
||
387 | 'deploy/latest/vendor/pronamic/*/phpmd.ruleset.xml', |
||
388 | 'deploy/latest/vendor/pronamic/*/phpunit.xml.dist', |
||
389 | 'deploy/latest/vendor/pronamic/*/yarn.lock', |
||
390 | 'deploy/latest/vendor/wp-pay*/*/bin/**', |
||
391 | 'deploy/latest/vendor/wp-pay*/*/documentation', |
||
392 | 'deploy/latest/vendor/wp-pay*/*/test/**', |
||
393 | 'deploy/latest/vendor/wp-pay*/*/tests/**', |
||
394 | 'deploy/latest/vendor/wp-pay*/*/.gitignore', |
||
395 | 'deploy/latest/vendor/wp-pay*/*/.scrutinizer.yml', |
||
396 | 'deploy/latest/vendor/wp-pay*/*/.travis.yml', |
||
397 | 'deploy/latest/vendor/wp-pay*/*/composer.lock', |
||
398 | 'deploy/latest/vendor/wp-pay*/*/Gruntfile.js', |
||
399 | 'deploy/latest/vendor/wp-pay*/*/package.json', |
||
400 | 'deploy/latest/vendor/wp-pay*/*/package-lock.json', |
||
401 | 'deploy/latest/vendor/wp-pay*/*/phpcs.ruleset.xml', |
||
402 | 'deploy/latest/vendor/wp-pay*/*/phpcs.xml.dist', |
||
403 | 'deploy/latest/vendor/wp-pay*/*/phpmd.ruleset.xml', |
||
404 | 'deploy/latest/vendor/wp-pay*/*/phpunit.xml.dist', |
||
405 | 'deploy/latest/vendor/wp-pay*/*/yarn.lock' |
||
406 | ] |
||
407 | }, |
||
408 | deploy_wp_content: { |
||
409 | src: [ |
||
410 | 'deploy/latest/wp-content' |
||
411 | ] |
||
412 | } |
||
413 | }, |
||
414 | |||
415 | // Compress. |
||
416 | compress: { |
||
417 | deploy: { |
||
418 | options: { |
||
419 | archive: 'deploy/archives/<%= pkg.name %>.<%= pkg.version %>.zip' |
||
420 | }, |
||
421 | expand: true, |
||
422 | cwd: 'deploy/latest', |
||
423 | src: ['**/*'], |
||
424 | dest: '<%= pkg.name %>/' |
||
425 | } |
||
426 | }, |
||
427 | |||
428 | // Git checkout. |
||
429 | gitcheckout: { |
||
430 | tag: { |
||
431 | options: { |
||
432 | branch: 'tags/<%= pkg.version %>' |
||
433 | } |
||
434 | }, |
||
435 | develop: { |
||
436 | options: { |
||
437 | branch: 'develop' |
||
438 | } |
||
439 | } |
||
440 | }, |
||
441 | |||
442 | // S3. |
||
443 | aws_s3: { |
||
444 | options: { |
||
445 | region: 'eu-central-1' |
||
446 | }, |
||
447 | deploy: { |
||
448 | options: { |
||
449 | bucket: 'downloads.pronamic.eu', |
||
450 | differential: true |
||
451 | }, |
||
452 | files: [ |
||
453 | { |
||
454 | expand: true, |
||
455 | cwd: 'deploy/archives/', |
||
456 | src: '<%= pkg.name %>.<%= pkg.version %>.zip', |
||
457 | dest: 'plugins/<%= pkg.name %>/' |
||
458 | } |
||
459 | ] |
||
460 | } |
||
461 | }, |
||
462 | |||
463 | // WordPress deploy. |
||
464 | rt_wp_deploy: { |
||
465 | app: { |
||
466 | options: { |
||
467 | svnUrl: 'http://plugins.svn.wordpress.org/<%= pkg.name %>/', |
||
468 | svnDir: 'deploy/wp-svn', |
||
469 | svnUsername: 'pronamic', |
||
470 | deployDir: 'deploy/latest', |
||
471 | version: '<%= pkg.version %>' |
||
472 | } |
||
473 | } |
||
474 | }, |
||
475 | |||
476 | webfont: { |
||
477 | icons: { |
||
478 | src: 'src/fonts/images/*.svg', |
||
479 | dest: 'fonts', |
||
480 | options: { |
||
481 | font: 'pronamic-pay-icons', |
||
482 | fontFamilyName: 'Pronamic Pay Icons', |
||
483 | normalize: true, |
||
484 | stylesheets: [ 'css' ], |
||
485 | templateOptions: { |
||
486 | baseClass: 'pronamic-pay-icon', |
||
487 | classPrefix: 'pronamic-pay-icon-' |
||
488 | }, |
||
489 | types: [ 'eot', 'woff2', 'woff', 'ttf', 'svg' ], |
||
490 | fontHeight: 768, |
||
491 | customOutputs: [ { |
||
492 | template: 'src/fonts/templates/variables.scss', |
||
493 | dest: 'src/fonts/_variables.scss' |
||
494 | } ] |
||
495 | } |
||
496 | } |
||
497 | } |
||
498 | } ); |
||
499 | |||
500 | // Default task(s). |
||
501 | grunt.registerTask( 'default', [ 'jshint', 'phplint', 'phpcs', 'phpunit' ] ); |
||
502 | grunt.registerTask( 'assets', [ 'sasslint', 'sass', 'postcss', 'copy:scripts', 'copy:assets', 'copy:other' ] ); |
||
503 | grunt.registerTask( 'min', [ 'uglify', 'imagemin' ] ); |
||
504 | grunt.registerTask( 'plantuml', [ 'shell:plantuml' ] ); |
||
505 | grunt.registerTask( 'pot', [ 'shell:makepot', 'shell:msgmerge' ] ); |
||
506 | |||
507 | grunt.registerTask( 'build_docs', [ |
||
508 | 'shell:readme_txt', |
||
509 | 'shell:readme_md', |
||
510 | 'shell:changelog_md' |
||
511 | ] ); |
||
512 | |||
513 | grunt.registerTask( 'build_assets', [ |
||
514 | 'clean:assets', |
||
515 | 'assets', |
||
516 | 'min' |
||
517 | ] ); |
||
518 | |||
519 | grunt.registerTask( 'build_latest', [ |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
520 | 'clean:deploy', |
||
521 | 'copy:deploy', |
||
522 | 'shell:deploy', |
||
523 | 'clean:deploy_composer', |
||
524 | 'clean:deploy_wp_content' |
||
525 | ] ); |
||
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
![]() |
|||
526 | |||
527 | grunt.registerTask( 'deploy', [ |
||
528 | 'default', |
||
529 | 'build_docs', |
||
530 | 'build_assets', |
||
531 | 'build_latest', |
||
532 | 'makepot', |
||
533 | 'copy:pot_to_dev', |
||
534 | 'compress:deploy' |
||
535 | ] ); |
||
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
![]() |
|||
536 | |||
537 | grunt.registerTask( 'wp-deploy', [ |
||
0 ignored issues
–
show
|
|||
538 | 'gitcheckout:tag', |
||
539 | 'deploy', |
||
540 | 'rt_wp_deploy', |
||
541 | 'gitcheckout:develop' |
||
542 | ] ); |
||
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
![]() |
|||
543 | |||
544 | grunt.registerTask( 's3-deploy', [ |
||
0 ignored issues
–
show
|
|||
545 | 'gitcheckout:tag', |
||
546 | 'deploy', |
||
547 | 'aws_s3:deploy', |
||
548 | 'gitcheckout:develop' |
||
549 | ] ); |
||
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
![]() |
|||
550 | }; |
||
551 |