<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][8356] trunk: Grunt: add first pass at Grunt build script.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/8356">8356</a></dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2014-05-04 12:59:23 +0000 (Sun, 04 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Grunt: add first pass at Grunt build script.

This commit is part of a series that will re-organise BuddyPress trunk to use a Grunt build process. See <a href="http://buddypress.trac.wordpress.org/ticket/5160">#5160</a></pre>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkGruntfilejs">trunk/Gruntfile.js</a></li>
<li><a href="#trunkpackagejson">trunk/package.json</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkGruntfilejs"></a>
<div class="addfile"><h4>Added: trunk/Gruntfile.js (0 => 8356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Gruntfile.js                               (rev 0)
+++ trunk/Gruntfile.js  2014-05-04 12:59:23 UTC (rev 8356)
</span><span class="lines">@@ -0,0 +1,290 @@
</span><ins>+/* jshint node:true */
+/* global module */
+module.exports = function( grunt ) {
+       var path   = require( 'path' ),
+       SOURCE_DIR = 'src/',
+       BUILD_DIR  = 'build/',
+
+       BP_CSS = [
+               'bp-activity/admin/css/*.css',
+               'bp-core/admin/css/*.css',
+               'bp-core/css/*.css',
+               'bp-groups/admin/css/*.css',
+               'bp-members/admin/css/*.css',
+               'bp-messages/css/*.css',
+               'bp-templates/bp-legacy/css,*.css',
+               'bp-xprofile/admin/css/*.css',
+               '!**/*-rtl.css'  // Exclude RTL files
+       ],
+
+       BP_JS = [
+               'bp-activity/admin/js/*.js',
+               'bp-core/js/*.js',
+               'bp-friends/js/*.js',
+               'bp-groups/admin/js/*.js',
+               'bp-groups/js/*.js',
+               'bp-members/admin/js/*.js',
+               'bp-messages/js/*.js',
+               'bp-templates/bp-legacy/js/*.js',
+               'bp-xprofile/admin/js/*.js'
+       ];
+
+       require( 'matchdep' ).filterDev( 'grunt-*' ).forEach( grunt.loadNpmTasks );
+
+
+       grunt.initConfig( {
+               jshint: {
+                       options: grunt.file.readJSON( '.jshintrc' ),
+                       grunt: {
+                               src: ['Gruntfile.js']
+                       },
+                       core: {
+                               expand: true,
+                               cwd: SOURCE_DIR,
+                               src: BP_JS,
+
+                               /**
+                                * Limit JSHint's run to a single specified file: grunt jshint:core --file=filename.js
+                                *
+                                * @param {String} filepath
+                                * @returns {Bool}
+                                */
+                               filter: function( filepath ) {
+                                       var index, file = grunt.option( 'file' );
+
+                                       // Don't filter when no target file is specified
+                                       if ( ! file ) {
+                                               return true;
+                                       }
+
+                                       // Normalise filepath for Windows
+                                       filepath = filepath.replace( /\\/g, '/' );
+                                       index = filepath.lastIndexOf( '/' + file );
+
+                                       // Match only the filename passed from cli
+                                       if ( filepath === file || ( -1 !== index && index === filepath.length - ( file.length + 1 ) ) ) {
+                                               return true;
+                                       }
+
+                                       return false;
+                               }
+                       }
+               },
+               cssjanus: {
+                       core: {
+                               expand: true,
+                               cwd: SOURCE_DIR,
+                               dest: SOURCE_DIR,
+                               ext: '-rtl.css',
+                               src: BP_CSS,
+                               options: { generateExactDuplicates: true }
+                       },
+                       dynamic: {
+                               expand: true,
+                               cwd: SOURCE_DIR,
+                               dest: SOURCE_DIR,
+                               ext: '-rtl.css',
+                               src: [],
+                               options: { generateExactDuplicates: true }
+                       }
+               },
+
+               checktextdomain: {
+                       options: {
+                               correct_domain: false,
+                               text_domain: 'buddypress',
+                               keywords: [
+                                       '__:1,2d',
+                                       '_e:1,2d',
+                                       '_x:1,2c,3d',
+                                       '_n:1,2,4d',
+                                       '_ex:1,2c,3d',
+                                       '_nx:1,2,4c,5d',
+                                       'esc_attr__:1,2d',
+                                       'esc_attr_e:1,2d',
+                                       'esc_attr_x:1,2c,3d',
+                                       'esc_html__:1,2d',
+                                       'esc_html_e:1,2d',
+                                       'esc_html_x:1,2c,3d',
+                                       '_n_noop:1,2,3d',
+                                       '_nx_noop:1,2,3c,4d'
+                               ]
+                       },
+                       files: {
+                               src: SOURCE_DIR + '**/*.php',
+                               expand: true
+                       }
+               },
+               makepot: {
+                       target: {
+                               options: {
+                                       cwd: SOURCE_DIR,
+                                       domainPath: '.',
+                                       mainFile: 'bp-loader.php',
+                                       potFilename: 'bp-languages/buddypress.pot',
+                                       processPot: function( pot ) {
+                                               pot.headers['report-msgid-bugs-to'] = 'https://wordpress.org/support/plugin/buddypress';
+                                               return pot;
+                                       },
+                                       type: 'wp-plugin'
+                               }
+                       }
+               },
+               imagemin: {
+                       core: {
+                               expand: true,
+                               cwd: SOURCE_DIR,
+                               src: ['**/*.{gif,jpg,jpeg,png}'],
+                               dest: SOURCE_DIR
+                       }
+               },
+
+               clean: {
+                       all: [ BUILD_DIR ],
+                       dynamic: {
+                               cwd: BUILD_DIR,
+                               dot: true,
+                               expand: true,
+                               src: []
+                       }
+               },
+               copy: {
+                       files: {
+                               files: [
+                                       {
+                                               cwd: SOURCE_DIR,
+                                               dest: BUILD_DIR,
+                                               dot: true,
+                                               expand: true,
+                                               src: ['**', '!**/.{svn,git}/**']
+                                       }
+                               ]
+                       },
+                       dynamic: {
+                               cwd: SOURCE_DIR,
+                               dest: BUILD_DIR,
+                               dot: true,
+                               expand: true,
+                               src: []
+                       }
+               },
+               uglify: {
+                       core: {
+                               cwd: BUILD_DIR,
+                               dest: BUILD_DIR,
+                               expand: true,
+                               ext: '.min.js',
+                               src: BP_JS
+                       },
+                       options: { banner: '/*! https://wordpress.org/plugins/buddypress/ */' }
+               },
+               cssmin: {
+                       ltr: {
+                               cwd: BUILD_DIR,
+                               dest: BUILD_DIR,
+                               expand: true,
+                               ext: '.min.css',
+                               src: BP_CSS,
+                               options: { banner: '/*! https://wordpress.org/plugins/buddypress/ */' }
+                       },
+                       rtl: {
+                               cwd: BUILD_DIR,
+                               dest: BUILD_DIR,
+                               expand: true,
+                               ext: '.min.css',
+                               src: BP_CSS.map( function( filename ) {
+                                       return filename.replace( '.css', '-rtl.css' );
+                               }),
+                               options: { banner: '/*! https://wordpress.org/plugins/buddypress/ */' }
+                       }
+               },
+
+               phpunit: {
+                       'default': {
+                               cmd: 'phpunit',
+                               args: ['-c', 'phpunit.xml.dist']
+                       },
+                       'multisite': {
+                               cmd: 'phpunit',
+                               args: ['-c', 'tests/phpunit/multisite.xml']
+                       }
+               },
+               exec: {
+                       bbpress: {
+                               command: 'svn export https://bbpress.svn.wordpress.org/tags/1.2 bbpress',
+                               cwd: BUILD_DIR + 'bp-forums',
+                               stdout: false
+                       },
+                       bpdefault: {
+                               command: 'svn export https://themes.svn.wordpress.org/bp-default/1.9 bp-default',
+                               cwd: BUILD_DIR + 'bp-themes',
+                               stdout: false
+                       }
+               },
+
+               watch: {
+                       css: {
+                               files: BP_CSS,
+                               tasks: ['less:core'],
+                               options: {
+                                       spawn: false
+                               }
+                       }
+               },
+               patch: {
+                       options: {
+                               tracUrl: 'buddypress.trac.wordpress.org'
+                       }
+               }
+       });
+
+
+       /**
+        * Register tasks.
+        */
+
+       grunt.registerTask( 'build-dev',     ['jshint', 'cssjanus'] );
+       grunt.registerTask( 'build-commit',  ['build-dev', 'checktextdomain', 'makepot', 'imagemin'] );
+       grunt.registerTask( 'build-release', ['build-commit', 'clean:all', 'copy:files', 'uglify:core', 'cssmin:ltr', 'cssmin:rtl', 'exec:bbpress', /*'exec:bpdefault',*/ 'test'] );
+
+
+       // Testing tasks.
+       grunt.registerMultiTask( 'phpunit', 'Runs PHPUnit tests, including the ajax and multisite tests.', function() {
+               grunt.util.spawn( {
+                       args: this.data.args,
+                       cmd:  this.data.cmd,
+                       opts: { stdio: 'inherit' }
+               }, this.async() );
+       });
+       grunt.registerTask( 'test', 'Run all unit test tasks.', ['phpunit'] );
+       grunt.registerTask( 'travis', ['jshint', 'test'] );
+
+
+       // Patch task.
+       grunt.renameTask( 'patch_wordpress', 'patch' );
+
+
+       // Default task.
+       grunt.registerTask( 'default', ['build-dev'] );
+
+
+       /**
+        * Add a listener to the watch task.
+        *
+        * On `watch:all`, automatically updates the `copy:dynamic` and `clean:dynamic` configurations so that only the changed files are updated.
+        * On `watch:rtl`, automatically updates the `cssjanus:dynamic` configuration.
+        */
+       grunt.event.on( 'watch', function( action, filepath, target ) {
+               if ( target !== 'all' && target !== 'rtl' ) {
+                       return;
+               }
+
+               var relativePath = path.relative( SOURCE_DIR, filepath ),
+               cleanSrc = ( action === 'deleted' ) ? [ relativePath ] : [],
+               copySrc  = ( action === 'deleted' ) ? [] : [ relativePath ];
+
+               grunt.config( ['clean', 'dynamic', 'src'], cleanSrc );
+               grunt.config( ['copy', 'dynamic', 'src'], copySrc );
+               grunt.config( ['cssjanus', 'dynamic', 'src'], copySrc );
+       });
+};
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkpackagejson"></a>
<div class="addfile"><h4>Added: trunk/package.json (0 => 8356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/package.json                               (rev 0)
+++ trunk/package.json  2014-05-04 12:59:23 UTC (rev 8356)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+{
+       "author": "The BuddyPress Community",
+       "bugs": {
+               "url": "https://buddypress.trac.wordpress.org/"
+       },
+       "description": "Social networking in a box. Build a social network for your company, school, sports team, or niche community.",
+       "devDependencies": {
+               "grunt": "~0.4.4",
+               "grunt-checktextdomain": "~0.1.1",
+               "grunt-contrib-clean": "~0.5.0",
+               "grunt-contrib-copy": "~0.5.0",
+               "grunt-contrib-cssmin": "~0.9.0",
+               "grunt-contrib-imagemin": "~0.6.1",
+               "grunt-contrib-uglify": "~0.4.0",
+               "grunt-contrib-watch": "~0.6.1",
+               "grunt-contrib-jshint": "~0.10.0",
+               "grunt-cssjanus": "~0.2.2",
+               "grunt-contrib-less": "~0.11.0",
+               "grunt-exec": "~0.4.5",
+               "grunt-patch-wordpress": "~0.2.1",
+               "grunt-phpunit": "~0.3.3",
+               "grunt-wp-i18n": "~0.4.3",
+               "matchdep": "~0.3.0"
+       },
+       "keywords": [
+               "activity",
+               "community",
+               "forum",
+               "friends",
+               "groups",
+               "messaging",
+               "notifications",
+               "profiles",
+               "social network"
+       ],
+       "homepage": "https://buddypress.org",
+       "license": "GPL-2.0+",
+       "name": "buddypress",
+       "repository": {
+               "type": "svn",
+               "url": "https://buddypress.svn.wordpress.org/trunk/"
+       },
+       "version": "2.0.1"
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>