Skip to:
Content

BuddyPress.org

Changeset 8954


Ignore:
Timestamp:
08/21/2014 05:22:07 PM (10 years ago)
Author:
djpaul
Message:

Grunt: overhaul tasks config.

  • Removes legacy watch grunt tasks. The watch configuration was previously removed in r8550.
  • Add extDot: 'last' option to Grunt tasks cssjanus, uglify, and cssmin. Fixes support with files with dot filenames.
  • Consolidates the cssmin tasks into one.
  • Task build now correctly verifies JS in the src folder. Previously, it was only validating files inside build.
  • Fixes an issue where the RTL CSS of the file jquery.autocompletefb.css was created using the filename jquery-rtl.css.
  • Don't parse bp-legacy's JS with jshint until improvements are made.

Includes files changed as a result of this Grunt change.

Fixes #5821, props netweb.

Location:
trunk
Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r8768 r8954  
    22/* global module */
    33module.exports = function( grunt ) {
    4     var path   = require( 'path' ),
    5     SOURCE_DIR = 'src/',
    6     BUILD_DIR  = 'build/',
    7 
    8     BP_CSS = [
    9         '**/*.css',
    10         '!**/*-rtl.css'  // Exclude RTL files
    11     ],
    12 
    13     BP_JS = [
    14         '**/*.js',
    15 
    16         // Exclude third-party libraries.
    17         '!bp-core/js/jquery.atwho.js',
    18         '!bp-core/js/jquery.caret.js',
    19 
    20         // Exclude legacy templates.
    21         '!bp-templates/**/*.js',
    22 
    23         // Exclude anything in any deprecated folders.
    24         '!**/deprecated/**/*.js'
    25     ];
     4    var SOURCE_DIR = 'src/',
     5        BUILD_DIR  = 'build/',
     6
     7        // CSS
     8        BP_CSS = [
     9            '**/*.css'
     10        ],
     11
     12        // CSS exclusions, for excluding files from certain tasks, e.g. cssjanus
     13        BP_EXCLUDED_CSS = [
     14            '!**/*-rtl.css'
     15        ],
     16
     17        // JavaScript - Core
     18        BP_JS = [
     19            '**/*.js'
     20        ],
     21
     22        // JavaScript exclusions, for excluding from certain tasks e.g jshint
     23        BP_EXCLUDED_JS = [
     24            '!bp-core/deprecated/js/**/*.js', // Depracted
     25            '!bp-core/js/jquery.atwho.js',    // External 3rd party library
     26            '!bp-core/js/jquery.caret.js',    // External 3rd party library
     27            '!bp-core/js/jquery-cookie.js'    // External 3rd party library
     28        ];
    2629
    2730    require( 'matchdep' ).filterDev( ['grunt-*', '!grunt-legacy-util'] ).forEach( grunt.loadNpmTasks );
    2831    grunt.util = require( 'grunt-legacy-util' );
    2932
    30 
    3133    grunt.initConfig( {
    32         pkg: grunt.file.readJSON('package.json'),
     34        pkg: grunt.file.readJSON( 'package.json' ),
    3335        jshint: {
    3436            options: grunt.file.readJSON( '.jshintrc' ),
     
    3941                expand: true,
    4042                cwd: SOURCE_DIR,
    41                 src: BP_JS,
     43                src: BP_JS.concat( BP_EXCLUDED_JS ),
    4244
    4345                /**
    44                  * Limit JSHint's run to a single specified file: grunt jshint:core --file=filename.js
    45                  * Optionally, include the file path: grunt jshint:core --file=path/to/filename.js
     46                 * Limit JSHint's run to a single specified file:
     47                 *
     48                 * grunt jshint:core --file=filename.js
     49                 *
     50                 * Optionally, include the file path:
     51                 *
     52                 * grunt jshint:core --file=path/to/filename.js
    4653                 *
    4754                 * @param {String} filepath
     
    7481                cwd: SOURCE_DIR,
    7582                dest: SOURCE_DIR,
     83                extDot: 'last',
    7684                ext: '-rtl.css',
    77                 src: BP_CSS,
     85                src: BP_CSS.concat( BP_EXCLUDED_CSS ),
    7886                options: { generateExactDuplicates: true }
    79             },
    80             dynamic: {
    81                 expand: true,
    82                 cwd: SOURCE_DIR,
    83                 dest: SOURCE_DIR,
    84                 ext: '-rtl.css',
    85                 src: [],
    86                 options: { generateExactDuplicates: true }
    87             }
    88         },
    89 
     87            }
     88        },
    9089        checktextdomain: {
    9190            options: {
     
    139138            }
    140139        },
    141 
    142140        clean: {
    143             all: [ BUILD_DIR ],
    144             dynamic: {
    145                 cwd: BUILD_DIR,
    146                 dot: true,
    147                 expand: true,
    148                 src: []
    149             }
     141            all: [ BUILD_DIR ]
    150142        },
    151143        copy: {
     
    160152                    }
    161153                ]
    162             },
    163             dynamic: {
    164                 cwd: SOURCE_DIR,
    165                 dest: BUILD_DIR,
    166                 dot: true,
    167                 expand: true,
    168                 src: []
    169154            }
    170155        },
     
    173158                cwd: BUILD_DIR,
    174159                dest: BUILD_DIR,
     160                extDot: 'last',
    175161                expand: true,
    176162                ext: '.min.js',
     
    184170        },
    185171        cssmin: {
    186             ltr: {
     172            minify: {
    187173                cwd: BUILD_DIR,
    188174                dest: BUILD_DIR,
     175                extDot: 'last',
    189176                expand: true,
    190177                ext: '.min.css',
     
    195182                    'https://wordpress.org/plugins/buddypress/ */'
    196183                }
    197             },
    198             rtl: {
    199                 cwd: BUILD_DIR,
    200                 dest: BUILD_DIR,
    201                 expand: true,
    202                 ext: '.min.css',
    203                 src: BP_CSS.map( function( filename ) {
    204                     return filename.replace( '.css', '-rtl.css' );
    205                 }),
    206                 options: {
    207                     banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
    208                     '<%= grunt.template.today("UTC:yyyy-mm-dd h:MM:ss TT Z") %> - ' +
    209                     'https://wordpress.org/plugins/buddypress/ */'
    210                 }
    211             }
    212         },
    213 
     184            }
     185        },
    214186        phpunit: {
    215187            'default': {
     
    234206            }
    235207        },
    236 
    237208        jsvalidate:{
    238209            options:{
     
    243214            build: {
    244215                files: {
    245                     src: [BUILD_DIR + '/**/*.{min.js,js}' ]
    246                 }
    247             }
    248         },
    249 
     216                    src: [BUILD_DIR + '/**/*.js' ]
     217                }
     218            },
     219            src: {
     220                files: {
     221                    src: [SOURCE_DIR + '/**/*.js' ]
     222                }
     223            }
     224        },
    250225        patch: {
    251226            options: {
     
    259234     * Register tasks.
    260235     */
    261     grunt.registerTask( 'build',         ['jsvalidate:build', 'jshint', 'cssjanus:core'] );
     236    grunt.registerTask( 'build',         ['jsvalidate:src', 'jshint', 'cssjanus'] );
    262237    grunt.registerTask( 'build-commit',  ['build', 'checktextdomain', 'imagemin'] );
    263     grunt.registerTask( 'build-release', ['build-commit', 'clean:all', 'copy:files', 'uglify:core', 'cssmin:ltr', 'cssmin:rtl', 'makepot', 'exec:bbpress', 'exec:bpdefault', 'test'] );
     238    grunt.registerTask( 'build-release', ['build-commit', 'clean:all', 'copy:files', 'uglify', 'jsvalidate:build', 'cssmin', 'makepot', 'exec:bbpress', 'exec:bpdefault', 'test'] );
    264239
    265240    // Testing tasks.
     
    274249    grunt.registerTask( 'test', 'Run all unit test tasks.', ['phpunit'] );
    275250
    276     grunt.registerTask( 'jstest', 'Runs all javascript tasks.', [ 'jsvalidate', 'jshint' ] );
     251    grunt.registerTask( 'jstest', 'Runs all javascript tasks.', [ 'jsvalidate:src', 'jshint' ] );
    277252
    278253    // Travis CI Task
     
    284259    // Default task.
    285260    grunt.registerTask( 'default', ['build'] );
    286 
    287     /**
    288      * Add a listener to the watch task.
    289      *
    290      * On `watch:all`, automatically updates the `copy:dynamic` and `clean:dynamic` configurations so that only the changed files are updated.
    291      * On `watch:rtl`, automatically updates the `cssjanus:dynamic` configuration.
    292      */
    293     grunt.event.on( 'watch', function( action, filepath, target ) {
    294         if ( target !== 'all' && target !== 'rtl' ) {
    295             return;
    296         }
    297 
    298         var relativePath = path.relative( SOURCE_DIR, filepath ),
    299         cleanSrc = ( action === 'deleted' ) ? [ relativePath ] : [],
    300         copySrc  = ( action === 'deleted' ) ? [] : [ relativePath ];
    301 
    302         grunt.config( ['clean', 'dynamic', 'src'], cleanSrc );
    303         grunt.config( ['copy', 'dynamic', 'src'], copySrc );
    304         grunt.config( ['cssjanus', 'dynamic', 'src'], copySrc );
    305     });
    306261};
  • trunk/src/bp-core/deprecated/css/autocomplete/jquery.autocompletefb-rtl.css

    r8953 r8954  
    7979
    8080input#send-to-input { width: 275px; }
    81 
  • trunk/src/bp-templates/bp-legacy/js/buddypress.js

    r8931 r8954  
     1/* jshint undef: false, unused:false */
    12// AJAX Functions
    23var jq = jQuery;
     
    422423                'page': oldest_page,
    423424                'exclude_just_posted': just_posted.join(',')
    424             }
     425            };
    425426
    426427            load_more_search = bp_get_querystring('s');
  • trunk/src/bp-templates/bp-legacy/js/password-verify.js

    r8686 r8954  
     1/* jshint undef: false */
    12/* Password Verify */
    23( function( $ ){
Note: See TracChangeset for help on using the changeset viewer.