Skip to:
Content

bbPress.org

Changeset 5450


Ignore:
Timestamp:
07/30/2014 03:34:57 AM (12 years ago)
Author:
netweb
Message:
  • Alphabetize grunt tasks and tweak inline docs in Gruntfile.js
  • Automatically reload the grunt watch task when changes are made to Gruntfile.js
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r5402 r5450  
    6060    grunt.initConfig({
    6161        pkg: grunt.file.readJSON('package.json'),
    62         clean: {
    63             all: [ BUILD_DIR ],
    64             dynamic: {
    65                 cwd: BUILD_DIR,
    66                 dot: true,
    67                 expand: true,
    68                 src: []
    69             }
    70         },
    71         copy: {
    72             files: {
    73                 files: [
    74                     {
    75                         cwd: SOURCE_DIR,
    76                         dest: BUILD_DIR,
    77                         dot: true,
    78                         expand: true,
    79                         src: [ '!**/.{svn,git}/**', '**', [ BBP_EXCLUDED_FILES ] ]
    80                     }
    81                 ]
    82             },
    83             dynamic: {
    84                 cwd: SOURCE_DIR,
    85                 dest: BUILD_DIR,
    86                 dot: true,
    87                 expand: true,
    88                 src: []
    89             }
    90         },
    91         sass: {
    92             colors: {
    93                 expand: true,
    94                 cwd: SOURCE_DIR,
    95                 dest: BUILD_DIR,
    96                 ext: '.css',
    97                 src: ['includes/admin/styles/*/colors.scss'],
    98                 options: {
    99                     outputStyle: 'expanded'
    100                 }
    101             }
    102         },
    103         cssmin: {
    104             ltr: {
    105                 cwd: BUILD_DIR,
    106                 dest: BUILD_DIR,
    107                 expand: true,
    108                 ext: '.min.css',
    109                 src: BBP_LTR_CSS,
    110                 options: {
    111                     banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
    112                     '<%= grunt.template.today("UTC:yyyy-mm-dd h:MM:ss TT Z") %> - ' +
    113                     'https://wordpress.org/plugins/bbpress/ */'
    114                 }
    115             },
    116             rtl: {
    117                 cwd: BUILD_DIR,
    118                 dest: BUILD_DIR,
    119                 expand: true,
    120                 ext: '.min.css',
    121                 src: BBP_RTL_CSS,
    122                 options: {
    123                     banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
    124                     '<%= grunt.template.today("UTC:yyyy-mm-dd h:MM:ss TT Z") %> - ' +
    125                     'https://wordpress.org/plugins/bbpress/ */'
    126                 }
    127             }
    128         },
    129         cssjanus: {
    130             core: {
    131                 expand: true,
    132                 cwd: BUILD_DIR,
    133                 dest: BUILD_DIR,
    134                 ext: '-rtl.css',
    135                 src: BBP_LTR_CSS,
    136                 options: { generateExactDuplicates: true }
    137             },
    138             dynamic: {
    139                 expand: true,
    140                 cwd: BUILD_DIR,
    141                 dest: BUILD_DIR,
    142                 ext: '-rtl.css',
    143                 src: []
    144             }
    145         },
    146         jshint: {
    147             options: grunt.file.readJSON( '.jshintrc' ),
    148             grunt: {
    149                 src: [ 'Gruntfile.js' ]
    150             },
    151             core: {
    152                 expand: true,
    153                 cwd: SOURCE_DIR,
    154                 src: BBP_JS,
    155 
    156                 /**
    157                  * Limit JSHint's run to a single specified file: grunt jshint:core --file=filename.js
    158                  * Optionally, include the file path: grunt jshint:core --file=path/to/filename.js
    159                  *
    160                  * @param {String} filepath
    161                  * @returns {Bool}
    162                  */
    163                 filter: function( filepath ) {
    164                     var index, file = grunt.option( 'file' );
    165 
    166                     // Don't filter when no target file is specified
    167                     if ( ! file ) {
    168                         return true;
    169                     }
    170 
    171                     // Normalise filepath for Windows
    172                     filepath = filepath.replace( /\\/g, '/' );
    173                     index = filepath.lastIndexOf( '/' + file );
    174 
    175                     // Match only the filename passed from cli
    176                     if ( filepath === file || ( -1 !== index && index === filepath.length - ( file.length + 1 ) ) ) {
    177                         return true;
    178                     }
    179 
    180                     return false;
    181                 }
    182             }
    183         },
    184         uglify: {
    185             core: {
    186                 cwd: SOURCE_DIR,
    187                 dest: BUILD_DIR,
    188                 expand: true,
    189                 ext: '.min.js',
    190                 src: BBP_JS
    191             },
    192             dynamic: {
    193                 cwd: SOURCE_DIR,
    194                 dest: BUILD_DIR,
    195                 expand: true,
    196                 ext: '.min.js',
    197                 src: []
    198             },
    199             options: {
    200                 banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
    201                 '<%= grunt.template.today("UTC:yyyy-mm-dd h:MM:ss TT Z") %> - ' +
    202                 'https://wordpress.org/plugins/bbpress/ */\n'
    203             }
    204         },
    205         phpunit: {
    206             'default': {
    207                 cmd: 'phpunit',
    208                 args: ['-c', 'phpunit.xml.dist']
    209             },
    210             multisite: {
    211                 cmd: 'phpunit',
    212                 args: ['-c', 'tests/phpunit/multisite.xml']
    213             }
    214         },
    215         makepot: {
    216             target: {
    217                 options: {
    218                     cwd: BUILD_DIR,
    219                     domainPath: '.',
    220                     mainFile: 'bbpress.php',
    221                     potFilename: 'bbpress.pot',
    222                     processPot: function( pot ) {
    223                         pot.headers['report-msgid-bugs-to'] = 'https://bbpress.trac.wordpress.org';
    224                         pot.headers['last-translator'] = 'JOHN JAMES JACOBY <jjj@bbpress.org>';
    225                         pot.headers['language-team'] = 'ENGLISH <jjj@bbpress.org>';
    226                         return pot;
    227                     },
    228                     type: 'wp-plugin'
    229                 }
    230             }
    231         },
    232         patch: {
    233             options: {
    234                 tracUrl: 'bbpress.trac.wordpress.org'
    235             }
    236         },
    23762        checktextdomain: {
    23863            options: {
     
    26186            }
    26287        },
     88        clean: {
     89            all: [ BUILD_DIR ],
     90            dynamic: {
     91                cwd: BUILD_DIR,
     92                dot: true,
     93                expand: true,
     94                src: []
     95            }
     96        },
     97        copy: {
     98            files: {
     99                files: [
     100                    {
     101                        cwd: SOURCE_DIR,
     102                        dest: BUILD_DIR,
     103                        dot: true,
     104                        expand: true,
     105                        src: [ '!**/.{svn,git}/**', '**', [ BBP_EXCLUDED_FILES ] ]
     106                    }
     107                ]
     108            },
     109            dynamic: {
     110                cwd: SOURCE_DIR,
     111                dest: BUILD_DIR,
     112                dot: true,
     113                expand: true,
     114                src: []
     115            }
     116        },
     117        cssjanus: {
     118            core: {
     119                expand: true,
     120                cwd: BUILD_DIR,
     121                dest: BUILD_DIR,
     122                ext: '-rtl.css',
     123                src: BBP_LTR_CSS,
     124                options: { generateExactDuplicates: true }
     125            },
     126            dynamic: {
     127                expand: true,
     128                cwd: BUILD_DIR,
     129                dest: BUILD_DIR,
     130                ext: '-rtl.css',
     131                src: []
     132            }
     133        },
     134        cssmin: {
     135            ltr: {
     136                cwd: BUILD_DIR,
     137                dest: BUILD_DIR,
     138                expand: true,
     139                ext: '.min.css',
     140                src: BBP_LTR_CSS,
     141                options: {
     142                    banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
     143                    '<%= grunt.template.today("UTC:yyyy-mm-dd h:MM:ss TT Z") %> - ' +
     144                    'https://wordpress.org/plugins/bbpress/ */'
     145                }
     146            },
     147            rtl: {
     148                cwd: BUILD_DIR,
     149                dest: BUILD_DIR,
     150                expand: true,
     151                ext: '.min.css',
     152                src: BBP_RTL_CSS,
     153                options: {
     154                    banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
     155                    '<%= grunt.template.today("UTC:yyyy-mm-dd h:MM:ss TT Z") %> - ' +
     156                    'https://wordpress.org/plugins/bbpress/ */'
     157                }
     158            }
     159        },
     160        jshint: {
     161            options: grunt.file.readJSON( '.jshintrc' ),
     162            grunt: {
     163                src: [ 'Gruntfile.js' ]
     164            },
     165            core: {
     166                expand: true,
     167                cwd: SOURCE_DIR,
     168                src: BBP_JS,
     169
     170                /**
     171                 * Limit JSHint's run to a single specified file: grunt jshint:core --file=filename.js
     172                 * Optionally, include the file path: grunt jshint:core --file=path/to/filename.js
     173                 *
     174                 * @param {String} filepath
     175                 * @returns {Bool}
     176                 */
     177                filter: function( filepath ) {
     178                    var index, file = grunt.option( 'file' );
     179
     180                    // Don't filter when no target file is specified
     181                    if ( ! file ) {
     182                        return true;
     183                    }
     184
     185                    // Normalise filepath for Windows
     186                    filepath = filepath.replace( /\\/g, '/' );
     187                    index = filepath.lastIndexOf( '/' + file );
     188
     189                    // Match only the filename passed from cli
     190                    if ( filepath === file || ( -1 !== index && index === filepath.length - ( file.length + 1 ) ) ) {
     191                        return true;
     192                    }
     193
     194                    return false;
     195                }
     196            }
     197        },
    263198        jsvalidate:{
    264199            options:{
     
    271206                    src: BUILD_DIR + '/**/*.js'
    272207                }
     208            }
     209        },
     210        makepot: {
     211            target: {
     212                options: {
     213                    cwd: BUILD_DIR,
     214                    domainPath: '.',
     215                    mainFile: 'bbpress.php',
     216                    potFilename: 'bbpress.pot',
     217                    processPot: function( pot ) {
     218                        pot.headers['report-msgid-bugs-to'] = 'https://bbpress.trac.wordpress.org';
     219                        pot.headers['last-translator'] = 'JOHN JAMES JACOBY <jjj@bbpress.org>';
     220                        pot.headers['language-team'] = 'ENGLISH <jjj@bbpress.org>';
     221                        return pot;
     222                    },
     223                    type: 'wp-plugin'
     224                }
     225            }
     226        },
     227        patch: {
     228            options: {
     229                tracUrl: 'bbpress.trac.wordpress.org'
     230            }
     231        },
     232        phpunit: {
     233            'default': {
     234                cmd: 'phpunit',
     235                args: ['-c', 'phpunit.xml.dist']
     236            },
     237            multisite: {
     238                cmd: 'phpunit',
     239                args: ['-c', 'tests/phpunit/multisite.xml']
     240            }
     241        },
     242        sass: {
     243            colors: {
     244                expand: true,
     245                cwd: SOURCE_DIR,
     246                dest: BUILD_DIR,
     247                ext: '.css',
     248                src: ['includes/admin/styles/*/colors.scss'],
     249                options: {
     250                    outputStyle: 'expanded'
     251                }
     252            }
     253        },
     254        uglify: {
     255            core: {
     256                cwd: SOURCE_DIR,
     257                dest: BUILD_DIR,
     258                expand: true,
     259                ext: '.min.js',
     260                src: BBP_JS
     261            },
     262            dynamic: {
     263                cwd: SOURCE_DIR,
     264                dest: BUILD_DIR,
     265                expand: true,
     266                ext: '.min.js',
     267                src: []
     268            },
     269            options: {
     270                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
     271                '<%= grunt.template.today("UTC:yyyy-mm-dd h:MM:ss TT Z") %> - ' +
     272                'https://wordpress.org/plugins/bbpress/ */\n'
    273273            }
    274274        },
     
    291291                tasks: ['sass:colors', 'cssjanus:core', 'cssmin:ltr', 'cssmin:rtl']
    292292            },
     293            config: {
     294                files: 'Gruntfile.js'
     295            },
     296            js: {
     297                files: BBP_JS.map( function( path ) {
     298                    return SOURCE_DIR + path;
     299                } ),
     300                tasks: [ 'uglify:dynamic' ],
     301                options: {
     302                    interval: 2000,
     303                    spawn: false
     304                }
     305            },
    293306            rtl: {
    294307                files: BBP_LTR_CSS.map( function( path ) {
     
    300313                    spawn: false
    301314                }
    302             },
    303             js: {
    304                 files: BBP_JS.map( function( path ) {
    305                     return SOURCE_DIR + path;
    306                 } ),
    307                 tasks: [ 'uglify:dynamic' ],
    308                 options: {
    309                     interval: 2000,
    310                     spawn: false
    311                 }
    312315            }
    313316        }
     
    323326    grunt.registerTask( 'build-release', [ 'clean:all', 'copy:files', 'colors', 'cssjanus:core', 'cssmin:ltr', 'cssmin:rtl', 'uglify:core', 'jsvalidate:build', 'checktextdomain', 'makepot', 'phpunit' ] );
    324327
    325     // Testing tasks.
     328    // PHPUnit test task.
    326329    grunt.registerMultiTask( 'phpunit', 'Runs PHPUnit tests, including the ajax and multisite tests.', function() {
    327330        grunt.util.spawn( {
     
    332335    } );
    333336
     337    // JavaScript test task.
    334338    grunt.registerTask( 'jstest', 'Runs all javascript tasks.', [ 'jsvalidate', 'jshint' ] );
    335339
    336     // Travis CI Task
     340    // Travis CI task.
    337341    grunt.registerTask( 'travis', ['jshint', 'phpunit'] );
    338342
Note: See TracChangeset for help on using the changeset viewer.