From 24b467a1048ed7958832d709ce72af423d51e3b7 Mon Sep 17 00:00:00 2001 From: Grayside Date: Sun, 29 Mar 2015 11:37:12 -0700 Subject: [PATCH 1/5] Correct compile-theme help text --- tasks/theme.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/theme.js b/tasks/theme.js index d078d723..e8e60d30 100644 --- a/tasks/theme.js +++ b/tasks/theme.js @@ -86,7 +86,7 @@ module.exports = function(grunt) { Help.add({ task: 'compile-theme', group: 'Asset & Code Compilation', - description: 'Run compilers for the theme, such as Compass.' + description: 'Run compilers for all themes (such as Compass).' }); } From b81eb9221ddf3c8140b4fe5206e7166f4220bb3e Mon Sep 17 00:00:00 2001 From: Grayside Date: Sun, 29 Mar 2015 11:37:52 -0700 Subject: [PATCH 2/5] Attempt to suppress notify_hooks task logging. --- package.json | 1 + tasks/notify.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 1c64f390..5a07d76b 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "grunt-contrib-symlink": "0.3.0", "grunt-contrib-watch": "0.6.1", "grunt-drush": "0.0.6", + "grunt-log-headers": "^1.0.1", "grunt-mkdir": "0.1.2", "grunt-newer": "1.1.0", "grunt-notify": "git+https://github.com/grayside/grunt-notify.git#0.5.0", diff --git a/tasks/notify.js b/tasks/notify.js index df28983b..ad41f1c7 100644 --- a/tasks/notify.js +++ b/tasks/notify.js @@ -19,7 +19,9 @@ module.exports = function(grunt) { // configured notifyThreshold. success: true, threshold: grunt.config.get('config.notify.threshold') || 10, - duration: 5 + duration: 5, + // Supposed to suppress notify_hooks log header, but not working. + gruntLogHeader: false } }); From ad77d74d2dd9c786abcff93534079e7588564ea1 Mon Sep 17 00:00:00 2001 From: Grayside Date: Sun, 29 Mar 2015 11:38:55 -0700 Subject: [PATCH 3/5] Expand and reflow 'grunt help' for more completeness. --- bootstrap.js | 2 ++ tasks/help.js | 72 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 239155fc..3f57ccea 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -53,4 +53,6 @@ module.exports = function(grunt) { if (grunt.option('timer')) { require('time-grunt')(grunt); } + + require('grunt-log-headers')(grunt); }; diff --git a/tasks/help.js b/tasks/help.js index 6e038f2f..d32382b1 100644 --- a/tasks/help.js +++ b/tasks/help.js @@ -7,7 +7,6 @@ module.exports = function(grunt) { * Provides an overview of intended and useful grunt tasks. */ - grunt.loadNpmTasks('grunt-available-tasks'); var Help = require('../lib/help')(grunt); Help.add({ @@ -16,7 +15,76 @@ module.exports = function(grunt) { description: 'The default build process that executes when "grunt" runs, which includes verifying dependencies and assembling the build directory.' }); + // Specify that only configured help entries should be displayed. grunt.config('availabletasks.help.options.filter', 'include'); - grunt.registerTask('help', ['availabletasks:help']); + // Suppress task headings for help to keep it lean. + grunt.config('help.options.gruntLogHeader', false); + grunt.config('availabletasks.help.options.gruntLogHeader', false); + grunt.config('help-after.options.gruntLogHeader', false); + + grunt.registerTask('help', 'Output grunt-drupal-tasks specialized help.', function() { + var gdt = {}; + var gruntHelp = require('grunt/lib/grunt/help'); + var process = function(queue) { queue.forEach(function(cb) { cb(); }); }; + + gdt.cleanOptions = function() { + for (var i in gruntHelp._options) { + item = gruntHelp._options[i]; + if (item[0] == '--base' || item[0] == '--gruntfile' || item[0] == '--tasks' || item[0] == '--npm') delete gruntHelp._options[i]; + if (item[0] == '--help, -h') gruntHelp._options[i][1] = 'Display the default Grunt help text.'; + } + }; + + gdt.header = function() { + grunt.log.writeln('Used with Grunt Drupal Tasks (v' + require('../package.json').version + ')'); + grunt.log.writeln().writeln('To display this help, run `grunt help`'); + }; + + gdt.options = function() { + var options = [ + [ '--quiet', 'Suppress desktop notifications.' ], + [ '--timer', 'Output task execution timing info.' ], + [ '--concurrency', 'Override the dynamic concurrency parameter used by Drush Make.' ] + ]; + gruntHelp.table(options); + }; + + gdt.tasks = function() { + grunt.loadNpmTasks('grunt-available-tasks'); + grunt.task.run('availabletasks:help', 'help-after'); + }; + + gdt.footer = function() { + grunt.log.writeln('For help with Grunt Drupal Tasks, see ' + require('../package.json').homepage); + }; + + // Dispatch to grunt tasks is asynchronous, in order to display text after + // dispatching to availabletasks we need a dedicated task so grunt's internal + // task sequencing will ensure the proper order of execution. + grunt.registerTask('help-after', 'Generate a footer to follow primary help text.', function() { + var queue = [ + gruntHelp.footer, + gdt.footer + ]; + + process(queue); + }); + + var queue = [ + gruntHelp.initOptions, + gdt.cleanOptions, + gruntHelp.initTasks, + gruntHelp.initWidths, + gruntHelp.header, + gdt.header, + gruntHelp.usage, + gruntHelp.options, + gdt.options, + gruntHelp.optionsFooter, + gdt.tasks + ]; + + process(queue); + }); }; From dd40ad15753ea5f2365832a7c05099c618ee5189 Mon Sep 17 00:00:00 2001 From: Joe Turgeon Date: Sun, 5 Apr 2015 10:03:33 -0500 Subject: [PATCH 4/5] Adding 'grunt help' to the Travis test script. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 326b27e5..90c6c75f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ install: - npm install -g mocha script: - export PATH=$PATH:`pwd`/bin + - grunt help - grunt --timer - echo "Example fully built disk usage"; du -chs . - grunt drush:liteinstall --timer From 1bde28b50659fae59b411551830b6a4f07139bc6 Mon Sep 17 00:00:00 2001 From: Joe Turgeon Date: Sun, 5 Apr 2015 11:18:23 -0500 Subject: [PATCH 5/5] Removing gruntHelp.initTasks to prevent 'Maximum call stack size exceeded' errors. --- tasks/help.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tasks/help.js b/tasks/help.js index d32382b1..0f28e369 100644 --- a/tasks/help.js +++ b/tasks/help.js @@ -74,7 +74,6 @@ module.exports = function(grunt) { var queue = [ gruntHelp.initOptions, gdt.cleanOptions, - gruntHelp.initTasks, gruntHelp.initWidths, gruntHelp.header, gdt.header,