From: Gustavo Martin Morcuende Date: Mon, 17 Aug 2015 17:13:01 +0000 (+0200) Subject: showcase: new gulp tasks X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=613958c6e8dcb6bd948182c2559968be5a5fbedd;p=JavaScriptForFun showcase: new gulp tasks --- diff --git a/angularjs/showcase/gulp.config.js b/angularjs/showcase/gulp.config.js new file mode 100644 index 0000000..349bec4 --- /dev/null +++ b/angularjs/showcase/gulp.config.js @@ -0,0 +1,23 @@ +module.exports = function() { + + var config = { + javaScriptFiles: [ + './src/**/*.js', + './*.js' + ], + jshintConfigurationFile: '.jshintrc', + jscsConfigurationFile: '.jscsrc' + }; + + config.getWiredepDefaultOptions = function() { + var options = { + bowerJson: config.bower.json, + directory: config.bower.directory, + ignorePath: config.bower.ignorePath + }; + return options; + }; + + + return config; +}; diff --git a/angularjs/showcase/gulpfile.js b/angularjs/showcase/gulpfile.js new file mode 100644 index 0000000..d44c5c9 --- /dev/null +++ b/angularjs/showcase/gulpfile.js @@ -0,0 +1,57 @@ +var args = require('yargs').argv; +var config = require('./gulp.config')(); +var gulp = require('gulp'); +var plugins = require('gulp-load-plugins')({ + pattern: ['gulp-*', 'gulp.*'], // the glob(s) to search for + scope: ['dependencies', 'devDependencies', 'peerDependencies'], // which keys in the config to look within + replaceString: /^gulp(-|\.)/, // what to remove from the name of the module when adding it to the context + camelize: true, // if true, transforms hyphenated plugins names to camel case + lazy: true, // whether the plugins should be lazy loaded on demand + rename: {} // a mapping of plugins to rename +}); + +/** + * Arguments: + * + * --verbose : Various tasks will produce more output to the console. + */ + +gulp.task('help', plugins.taskListing); + +/** + * @description + * vet (evaluate) the code and create coverage report + * + * @return {Stream} + */ +gulp.task('vet', function() { + + plugins.util.log(plugins.util.colors.blue('Checking source with JSHint and JSCS')); + + return gulp.src(config.javaScriptFiles) + .pipe(plugins.if(args.verbose, plugins.print())) + .pipe(plugins.jshint(config.jshintConfigurationFile)) + .pipe(plugins.jshint.reporter('jshint-stylish', {verbose: true})) + .pipe(plugins.jshint.reporter('fail')) + .pipe(plugins.jscs({ + configPath: config.jscsConfigurationFile, + fix: false + })); +}); + +gulp.task('wiredep', function() { + + plugins.util.log('Wiring the bower dependencies into the html'); + + var wiredep = require('wiredep').stream; + var options = config.getWiredepDefaultOptions(); + + // Only include stubs if flag is enabled + var js = args.stubs ? [].concat(config.js, config.stubsjs) : config.js; + + return gulp + .src(config.index) + .pipe(wiredep(options)) + .pipe(inject(js, '', config.jsOrder)) + .pipe(gulp.dest(config.client)); +}); diff --git a/angularjs/showcase/package.json b/angularjs/showcase/package.json index f7640dc..9b765a9 100644 --- a/angularjs/showcase/package.json +++ b/angularjs/showcase/package.json @@ -6,13 +6,21 @@ "express": "~4.13.3", "express-http-proxy": "~0.6.0", "gulp": "~3.9.0", + "gulp-if": "~1.2.5", + "gulp-jscs": "~2.0.0", + "gulp-jshint": "~1.11.2", + "gulp-load-plugins": "~1.0.0-rc.1", + "gulp-print": "~1.1.0", + "gulp-task-listing": "~1.0.1", "gulp-useref": "~1.3.0", "gulp-util": "~3.0.6", + "jshint-stylish": "~2.0.1", "karma-coverage": "~0.5.0", "karma-jasmine": "~0.3.6", "karma-junit-reporter": "~0.3.3", "karma-phantomjs-launcher": "~0.2.1", - "wiredep": "~3.0.0-beta" + "wiredep": "~3.0.0-beta", + "yargs": "~3.19.0" }, "config": { "backend-port": "8080",