pronamic /
wp-pronamic-ideal
| 1 | /* jshint node:true */ |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | module.exports = function( grunt ) { |
||
| 3 | require( 'load-grunt-tasks' )( grunt ); |
||
| 4 | |||
| 5 | // Project configuration. |
||
| 6 | grunt.initConfig( { |
||
|
0 ignored issues
–
show
|
|||
| 7 | pkg: grunt.file.readJSON( 'package.json' ), |
||
| 8 | |||
| 9 | // PHPLint |
||
|
0 ignored issues
–
show
|
|||
| 10 | phplint: { |
||
| 11 | plugin: [ |
||
| 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 | plugin: { |
||
| 99 | src: [ |
||
| 100 | '**/*.php', |
||
| 101 | '!build/**', |
||
| 102 | '!deploy/**', |
||
| 103 | '!node_modules/**', |
||
| 104 | '!repositories/**', |
||
| 105 | '!vendor/**', |
||
| 106 | '!wordpress/**', |
||
| 107 | '!wp-content/**' |
||
| 108 | ], |
||
| 109 | expand: true |
||
| 110 | }, |
||
| 111 | wp_pay: { |
||
| 112 | src: [ |
||
| 113 | 'vendor/wp-pay/**/*.php', |
||
| 114 | 'vendor/wp-pay-gateways/**/*.php', |
||
| 115 | 'vendor/wp-pay-extensions/**/*.php' |
||
| 116 | ], |
||
| 117 | expand: true |
||
| 118 | } |
||
| 119 | }, |
||
| 120 | |||
| 121 | // Imagemin. |
||
| 122 | imagemin: { |
||
| 123 | build: { |
||
| 124 | files: [ |
||
| 125 | { // Images |
||
|
0 ignored issues
–
show
|
|||
| 126 | expand: true, |
||
| 127 | cwd: 'src/images/', |
||
| 128 | src: ['**/*.{png,jpg,gif,svg,ico}'], |
||
| 129 | dest: 'images/' |
||
| 130 | } |
||
| 131 | ] |
||
| 132 | } |
||
| 133 | }, |
||
| 134 | |||
| 135 | // Shell. |
||
| 136 | shell: { |
||
| 137 | // Make POT. |
||
| 138 | makepot: { |
||
| 139 | command: 'wp pronamic i18n make-pot . languages/pronamic_ideal.pot --slug="pronamic-ideal"' |
||
| 140 | }, |
||
| 141 | |||
| 142 | msgmerge: { |
||
| 143 | command: 'find languages/*.po -type f -exec msgmerge --update {} languages/pronamic_ideal.pot \\;' |
||
| 144 | }, |
||
| 145 | |||
| 146 | // PlantUML. |
||
| 147 | plantuml: { |
||
| 148 | command: 'plantuml ./documentation/*.plantuml' |
||
| 149 | }, |
||
| 150 | |||
| 151 | // Generate readme.txt. |
||
| 152 | readme_txt: { |
||
| 153 | command: 'php src/readme-txt/readme.php > readme.txt' |
||
| 154 | }, |
||
| 155 | |||
| 156 | // Generate README.md. |
||
| 157 | readme_md: { |
||
| 158 | command: 'php src/readme-md/README.php > README.md' |
||
| 159 | }, |
||
| 160 | |||
| 161 | // Generate CHANGELOG.md. |
||
| 162 | changelog_md: { |
||
| 163 | command: 'php src/changelog-md/CHANGELOG.php > CHANGELOG.md' |
||
| 164 | } |
||
| 165 | }, |
||
| 166 | |||
| 167 | // Copy. |
||
| 168 | copy: { |
||
| 169 | scripts: { |
||
| 170 | files: [ |
||
| 171 | { // JS. |
||
| 172 | expand: true, |
||
| 173 | cwd: 'src/js/', |
||
| 174 | src: '**', |
||
| 175 | dest: 'js/' |
||
| 176 | } |
||
| 177 | ] |
||
| 178 | }, |
||
| 179 | assets: { |
||
| 180 | files: [ |
||
| 181 | { // Flot - http://www.flotcharts.org/. |
||
| 182 | expand: true, |
||
| 183 | cwd: 'node_modules/Flot/', |
||
| 184 | src: [ |
||
| 185 | 'jquery.flot.js', |
||
| 186 | 'jquery.flot.time.js', |
||
| 187 | 'jquery.flot.resize.js' |
||
| 188 | ], |
||
| 189 | dest: 'assets/flot' |
||
| 190 | }, |
||
| 191 | { // accounting.js - http://openexchangerates.github.io/accounting.js/. |
||
| 192 | expand: true, |
||
| 193 | cwd: 'node_modules/accounting/', |
||
| 194 | src: 'accounting.js', |
||
| 195 | dest: 'assets/accounting' |
||
| 196 | }, |
||
| 197 | { // Tippy.js - https://atomiks.github.io/tippyjs/. |
||
| 198 | expand: true, |
||
| 199 | cwd: 'node_modules/tippy.js/dist', |
||
| 200 | src: 'tippy.all.js', |
||
| 201 | dest: 'assets/tippy.js' |
||
| 202 | } |
||
| 203 | ] |
||
| 204 | }, |
||
| 205 | other: { |
||
| 206 | files: [ |
||
| 207 | { // extensions.json. |
||
| 208 | expand: true, |
||
| 209 | cwd: 'src/', |
||
| 210 | src: [ |
||
| 211 | 'extensions.json' |
||
| 212 | ], |
||
| 213 | dest: 'other/' |
||
| 214 | } |
||
| 215 | ] |
||
| 216 | } |
||
| 217 | }, |
||
| 218 | |||
| 219 | // SASS. |
||
| 220 | sass: { |
||
| 221 | options: { |
||
| 222 | style: 'expanded' |
||
| 223 | }, |
||
| 224 | build: { |
||
| 225 | files: [ { |
||
| 226 | expand: true, |
||
| 227 | cwd: 'src/sass', |
||
| 228 | src: '*.scss', |
||
| 229 | dest: 'src/css', |
||
| 230 | ext: '.css' |
||
| 231 | } ] |
||
| 232 | } |
||
| 233 | }, |
||
| 234 | |||
| 235 | // PostCSS. |
||
| 236 | postcss: { |
||
| 237 | options: { |
||
| 238 | map: false |
||
| 239 | }, |
||
| 240 | prefix: { |
||
| 241 | options: { |
||
| 242 | processors: [ |
||
| 243 | require( 'autoprefixer' )(), |
||
| 244 | require( 'postcss-eol' )() |
||
| 245 | ] |
||
| 246 | }, |
||
| 247 | files: [ { |
||
| 248 | expand: true, |
||
| 249 | cwd: 'src/css/', |
||
| 250 | src: '*.css', |
||
| 251 | dest: 'css/' |
||
| 252 | } ] |
||
| 253 | }, |
||
| 254 | min: { |
||
| 255 | options: { |
||
| 256 | processors: [ |
||
| 257 | require( 'cssnano' )(), |
||
| 258 | require( 'postcss-eol' )() |
||
| 259 | ] |
||
| 260 | }, |
||
| 261 | files: [ { |
||
| 262 | expand: true, |
||
| 263 | cwd: 'css/', |
||
| 264 | src: [ |
||
| 265 | '*.css', |
||
| 266 | '!*.min.css' |
||
| 267 | ], |
||
| 268 | dest: 'css/', |
||
| 269 | ext: '.min.css' |
||
| 270 | } ] |
||
| 271 | } |
||
| 272 | }, |
||
| 273 | |||
| 274 | // Uglify. |
||
| 275 | uglify: { |
||
| 276 | scripts: { |
||
| 277 | files: { |
||
| 278 | // Pronamic Pay. |
||
| 279 | 'js/admin.min.js': 'src/js/admin.js', |
||
| 280 | 'js/admin-reports.min.js': 'src/js/admin-reports.js', |
||
| 281 | 'js/admin-tour.min.js': 'src/js/admin-tour.js', |
||
| 282 | // Accounting. |
||
| 283 | 'assets/accounting/accounting.min.js': 'assets/accounting/accounting.js', |
||
| 284 | // Flot. |
||
| 285 | 'assets/flot/jquery.flot.min.js': 'assets/flot/jquery.flot.js', |
||
| 286 | 'assets/flot/jquery.flot.resize.min.js': 'assets/flot/jquery.flot.resize.js', |
||
| 287 | 'assets/flot/jquery.flot.time.min.js': 'assets/flot/jquery.flot.time.js', |
||
| 288 | // Tippy.js. |
||
| 289 | 'assets/tippy.js/tippy.all.min.js': 'assets/tippy.js/tippy.all.js' |
||
| 290 | } |
||
| 291 | } |
||
| 292 | }, |
||
| 293 | |||
| 294 | // Clean. |
||
| 295 | clean: { |
||
| 296 | assets: { |
||
| 297 | src: [ |
||
| 298 | 'assets', |
||
| 299 | 'css', |
||
| 300 | 'images', |
||
| 301 | 'js' |
||
| 302 | ] |
||
| 303 | } |
||
| 304 | }, |
||
| 305 | |||
| 306 | // Webfont. |
||
| 307 | webfont: { |
||
| 308 | icons: { |
||
| 309 | src: 'src/fonts/images/*.svg', |
||
| 310 | dest: 'fonts', |
||
| 311 | options: { |
||
| 312 | font: 'pronamic-pay-icons', |
||
| 313 | fontFamilyName: 'Pronamic Pay Icons', |
||
| 314 | normalize: true, |
||
| 315 | stylesheets: [ 'css' ], |
||
| 316 | templateOptions: { |
||
| 317 | baseClass: 'pronamic-pay-icon', |
||
| 318 | classPrefix: 'pronamic-pay-icon-' |
||
| 319 | }, |
||
| 320 | types: [ 'eot', 'woff2', 'woff', 'ttf', 'svg' ], |
||
| 321 | fontHeight: 768, |
||
| 322 | customOutputs: [ { |
||
| 323 | template: 'src/fonts/templates/variables.scss', |
||
| 324 | dest: 'src/fonts/_variables.scss' |
||
| 325 | } ] |
||
| 326 | } |
||
| 327 | } |
||
| 328 | } |
||
| 329 | } ); |
||
|
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.
Loading history...
|
|||
| 330 | |||
| 331 | // Default task(s). |
||
| 332 | grunt.registerTask( 'default', [ 'jshint', 'phplint', 'phpcs', 'phpunit' ] ); |
||
| 333 | grunt.registerTask( 'assets', [ 'sasslint', 'sass', 'postcss', 'copy:scripts', 'copy:assets', 'copy:other' ] ); |
||
| 334 | grunt.registerTask( 'min', [ 'uglify', 'imagemin' ] ); |
||
| 335 | grunt.registerTask( 'plantuml', [ 'shell:plantuml' ] ); |
||
| 336 | grunt.registerTask( 'pot', [ 'checktextdomain', 'shell:makepot', 'shell:msgmerge' ] ); |
||
| 337 | |||
| 338 | grunt.registerTask( 'build_docs', [ |
||
|
0 ignored issues
–
show
|
|||
| 339 | 'shell:readme_txt', |
||
| 340 | 'shell:readme_md', |
||
| 341 | 'shell:changelog_md' |
||
| 342 | ] ); |
||
|
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.
Loading history...
|
|||
| 343 | |||
| 344 | grunt.registerTask( 'build_assets', [ |
||
|
0 ignored issues
–
show
|
|||
| 345 | 'clean:assets', |
||
| 346 | 'assets', |
||
| 347 | 'min' |
||
| 348 | ] ); |
||
|
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.
Loading history...
|
|||
| 349 | |||
| 350 | grunt.registerTask( 'build', [ |
||
|
0 ignored issues
–
show
|
|||
| 351 | 'default', |
||
| 352 | 'build_docs', |
||
| 353 | 'build_assets', |
||
| 354 | 'pot' |
||
| 355 | ] ); |
||
|
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.
Loading history...
|
|||
| 356 | }; |
||
| 357 |