From c3522fea85349c2486e730dda931729a44c41f02 Mon Sep 17 00:00:00 2001 From: tkQubo Date: Thu, 20 Aug 2015 22:06:21 +0900 Subject: [PATCH] Add gulp-help --- gulp-help/gulp-help-tests.ts | 47 ++++++++++++++ gulp-help/gulp-help.d.ts | 119 +++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 gulp-help/gulp-help-tests.ts create mode 100644 gulp-help/gulp-help.d.ts diff --git a/gulp-help/gulp-help-tests.ts b/gulp-help/gulp-help-tests.ts new file mode 100644 index 0000000000..26abdf06ab --- /dev/null +++ b/gulp-help/gulp-help-tests.ts @@ -0,0 +1,47 @@ +/// +/// +/// + +'use strict'; + +import gulpHelp = require('gulp-help'); + +var gulp = gulpHelp(require('gulp')); + +gulp.task('lint', 'Lints all server side js', function () { + var jshint: () => NodeJS.ReadWriteStream; + + gulp.src('./lib/**/*.js') + .pipe(jshint()); +}); + +gulp.task('task-hidden-from-help', false, function () { + // ... +}); + +gulp.task('version', 'prints the version.', [], function() { + // ... +}, { + aliases: ['v', 'V'] +}); + +gulp.task('version', 'prints the version.', [], function () { + // ... +}, { + options: { + 'env=prod': 'description of env, perhaps with available values', + 'key=val': 'description of key & val', + 'key': 'description of key' + } +}); + +var gulp2 = require('gulp'); +gulpHelp(gulp2, { + description: 'Desc', + aliases: ['h'], + hideEmpty: true, + hideDepsMessage: false, + afterPrintCallback(): any { + console.log('done'); + } +}); diff --git a/gulp-help/gulp-help.d.ts b/gulp-help/gulp-help.d.ts new file mode 100644 index 0000000000..dd47ed0f68 --- /dev/null +++ b/gulp-help/gulp-help.d.ts @@ -0,0 +1,119 @@ +// Type definitions for gulp-help +// Project: https://github.com/chmontgomery/gulp-help +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// +/// +/// + + +declare module "gulp-help" { + import Orchestrator = require('orchestrator'); + import gulp = require('gulp'); + type HelpOption = string|boolean; + + namespace gulpHelp { + interface TaskMethod { + /** + * Define a task. + * + * @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them. + * @param help Custom help message as a string. If you want to hide the task from the help menu, supply false + * @param deps an array of tasks to be executed and completed before your task will run. + * @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()). + * @param option task options + */ + (name: string, help: HelpOption, deps: string[], fn?: gulp.TaskCallback, option?: TaskOptions): any; + /** + * Define a task. + * + * @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them. + * @param help Custom help message as a string. If you want to hide the task from the help menu, supply false + * @param deps an array of tasks to be executed and completed before your task will run. + */ + (name: string, help: HelpOption, deps: string[]): any; + /** + * Define a task. + * + * @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them. + * @param help Custom help message as a string. If you want to hide the task from the help menu, supply false + * @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()). + * @param option task options + */ + (name: string, help: HelpOption, fn?: gulp.TaskCallback, option?: TaskOptions): any; + /** + * Define a task. + * + * @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them. + * @param help Custom help message as a string. If you want to hide the task from the help menu, supply false + */ + (name: string, help: HelpOption): any; + /** + * Define a task. + * + * @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them. + * @param deps an array of tasks to be executed and completed before your task will run. + * @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()). + * @param option task options + */ + (name: string, deps: string[], fn?: gulp.TaskCallback, option?: TaskOptions): any; + /** + * Define a task. + * + * @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them. + * @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()). + * @param option task options + */ + (name: string, fn?: gulp.TaskCallback, option?: TaskOptions): any; + } + + interface GulpHelp extends Orchestrator { + task: TaskMethod; + src: gulp.SrcMethod; + dest: gulp.DestMethod; + watch: gulp.WatchMethod; + } + + interface TaskOptions { + /** + * List of aliases for this task + */ + aliases?: string[]; + /** + * Object documenting options which can be passed to your task + */ + options?: { [key: string]: string }; + } + + interface GulpHelpOptions { + /** + * Modifies the default help message + */ + description?: string; + /** + * Adds aliases to the default help task + */ + aliases?: string[]; + /** + * Hide all tasks with no help message defined. Useful when including 3rd party tasks + */ + hideEmpty?: boolean; + /** + * Hide all task dependencies + */ + hideDepsMessage?: boolean; + /** + * A function to run after the default help task runs + */ + afterPrintCallback?: Function; + } + + } + + function gulpHelp(gulp: gulp.Gulp, options?: gulpHelp.GulpHelpOptions): gulpHelp.GulpHelp; + + export = gulpHelp; +} +