Passed
Push — develop ( 0ab3b3...b2499d )
by Remco
04:50
created

Gruntfile.js (35 issues)

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