<commit_before>var browserify = require('gulp-browserify');
var chai = require('chai');
var gulp = require('gulp');
var minify = require('gulp-uglify');
var mocha = require('gulp-mocha');
var rename = require('gulp-rename');

gulp.task('package', function() {
  return gulp.src('./src/validate.js')
    .pipe(browserify())
    .pipe(rename('js-validate.js'))
    .pipe(gulp.dest('./dist'));
});
gulp.task('package-min', ['package'], function() {
  return gulp.src('./dist/js-validate.js')
    .pipe(minify({}))
    .pipe(rename('js-validate.min.js'))
    .pipe(gulp.dest('./dist'));
});
gulp.task('test', function() {
  global.expect = chai.expect;
  global.RULES = require('./src/defaults/rules');

  return gulp.src(['!./tests/**/*_xtest*', './tests/**/*_test*.js'])
    .pipe(mocha());
});

gulp.task('default', ['test', 'package-min']);
<commit_msg>New testing tasks and version bump<commit_after>var browserify = require('gulp-browserify');
var chai = require('chai');
var gulp = require('gulp');
var minify = require('gulp-uglify');
var mocha = require('gulp-mocha');
var rename = require('gulp-rename');
var bump = require('gulp-bump');

gulp.task('package', function() {
  return gulp.src('./src/validate.js')
    .pipe(browserify())
    .pipe(rename('js-validate.js'))
    .pipe(gulp.dest('./dist'));
});

gulp.task('package-min', ['package'], function() {
  return gulp.src('./dist/js-validate.js')
    .pipe(minify({}))
    .pipe(rename('js-validate.min.js'))
    .pipe(gulp.dest('./dist'));
});

gulp.task('test', function() {
  global.expect = chai.expect;
  global.RULES = require('./src/defaults/rules');

  return gulp.src(['!./tests/**/*_xtest*', './tests/**/*_test*.js'])
    .pipe(mocha());
});

gulp.task('test-watch', function() {
  gulp.watch([
    '!./tests/**/*_xtest*',
    './tests/**/*_test*.js',
    './src/**/*.js'
  ], ['test']);
});

gulp.task('patch', function() {
  return gulp.src(['./bower.json', './package.json'])
    .pipe(bump())
    .pipe(gulp.dest('./'));

});

gulp.task('minor', function() {
  return gulp.src(['./bower.json', './package.json'])
    .pipe(bump({ type: 'minor' }))
    .pipe(gulp.dest('./'));
});

gulp.task('major', function() {
  return gulp.src(['./bower.json', './package.json'])
    .pipe(bump({ type: 'major' }))
    .pipe(gulp.dest('./'));
});

gulp.task('default', ['test', 'package-min']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var sass = require('gulp-sass');
var renames = require('gulp-rename');
var concats = require('gulp-concat');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var watch = require('gulp-watch');

gulp.task('default',['sass','js']);

gulp.task('sass',function(){
    gulp.src('src/sass/**/*.scss')
        .pipe(sourcemaps.init())
        .pipe(sass({outputStyle:'compressed'}))
        .pipe(renames('rola.min.css'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/css'));
});

gulp.task('js',function(){
    gulp.src(['src/libs/js/**/*.js','src/js/**/*.js'])
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(concats('all.js'))
        .pipe(renames('rola.min.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/js'));
});

gulp.task('watch:sass',function(){
    return gulp.watch('src/sass/**/*.scss',['sass'])
});
<commit_msg>sass compile-only task<commit_after>var gulp = require('gulp');
var sass = require('gulp-sass');
var renames = require('gulp-rename');
var concats = require('gulp-concat');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var watch = require('gulp-watch');

gulp.task('default',['sass','js']);

gulp.task('sass',function(){
    gulp.src('src/sass/**/*.scss')
        .pipe(sourcemaps.init())
        .pipe(sass({outputStyle:'compressed'}))
        .pipe(renames('rola.min.css'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/css'));
});

// This task only compile SASS
gulp.task('sass:compile',function(){
    gulp.src('src/sass/**/*.scss')
        .pipe(sass())
        .pipe(renames('rola.min.css'))
        .pipe(gulp.dest('./dist/css'));
});

gulp.task('js',function(){
    gulp.src(['src/libs/js/**/*.js','src/js/**/*.js'])
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(concats('all.js'))
        .pipe(renames('rola.min.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/js'));
});

gulp.task('watch:sass',function(){
    return gulp.watch('src/sass/**/*.scss',['sass'])
});
<|endoftext|>


<commit_before>var gutil = require('gulp-util');
var gulp  = require('gulp');
var fs    = require('fs-extra');

gulp.task('clean', function () {
    fs.removeSync(__dirname + '/build');
});

gulp.task('build:lib', function () {
    var traceur = require('gulp-traceur');

    return gulp.src('lib/*.js')
        .pipe(traceur())
        .pipe(gulp.dest('build/lib'));
});

gulp.task('build:docs', function () {
    var ignore = require('fs').readFileSync('.npmignore').toString()
        .trim().split(/\n+/)
        .concat(['.npmignore', 'index.js', 'index.build.js'])
        .map(function (i) { return '!' + i; });

    return gulp.src(['*'].concat(ignore))
        .pipe(gulp.dest('build'));
});

gulp.task('build:index', function (done) {
    fs.copy('index.build.js', 'build/index.js', done);
});

gulp.task('build', ['clean', 'build:lib', 'build:docs', 'build:index']);

gulp.task('lint:test', function () {
    var jshint = require('gulp-jshint');

    return gulp.src('test/*.js')
        .pipe(jshint({ esnext: true, expr: true }))
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(jshint.reporter('fail'));
});

gulp.task('lint:lib', function () {
    var jshint = require('gulp-jshint');

    return gulp.src(['lib/*.js', 'index.js', 'index.build.js', 'gulpfile.js'])
        .pipe(jshint({ esnext: true }))
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(jshint.reporter('fail'));
});

gulp.task('lint', ['lint:test', 'lint:lib']);

var zlib, request;
var get = function (url, callback) {
    if ( !zlib ) {
        zlib    = require('zlib');
        request = require('request');
    }

    request.get({ url: url, headers: { 'accept-encoding': 'gzip,deflate' } })
        .on('response', function (res) {
            var chunks = [];
            res.on('data', function (i) {
                chunks.push(i);
            });
            res.on('end', function () {
                var buffer = Buffer.concat(chunks);

                if ( res.headers['content-encoding'] == 'gzip' ) {
                    zlib.gunzip(buffer, function (err, decoded) {
                        callback(decoded.toString());
                    });

                } else if ( res.headers['content-encoding'] == 'deflate' ) {
                    zlib.inflate(buffer, function (err, decoded) {
                        callback(decoded.toString());
                    });

                } else {
                    callback(buffer.toString());
                }
            });
        });
};

var styles = function (url, callback) {
    get(url, function (html) {
        var styles = html.match(/[^"]+\.css("|')/g);
        if ( !styles ) throw "Can't find CSS links at " + url;
        styles = styles.map(function(path) {
            path = path.slice(0, -1);
            if ( path.match(/^https?:/) ) {
                return path;
            } else {
                return path.replace(/^\.?\.?\/?/, url);
            }
        });
        callback(styles);
    });
};

gulp.task('bench', ['build'], function (done) {
    var indent = function (max, current) {
        var diff = max.toString().length - current.toString().length;
        for ( var i = 0; i < diff; i++ ) {
            process.stdout.write(' ');
        }
    };

    var times = { };
    var bench = function (title, callback) {
        process.stdout.write(title + ': ');
        indent('Gonzales PE', title);

        var start = new Date();

        for ( var i = 0; i < 10; i++ ) callback();

        time = (new Date()) - start;
        time = Math.round(time / 10);
        process.stdout.write(time + " ms");

        if ( times.PostCSS ) {
            var slower = time / times.PostCSS;
            if ( time < 100 ) process.stdout.write(' ');

            var result;
            if ( slower < 1 ) {
                result = ' (' + (1 / slower).toFixed(1) + ' times faster)';
            } else {
                result = ' (' + slower.toFixed(1) + ' times slower)';
            }
            process.stdout.write(result);
        }
        times[title] = time;
        process.stdout.write("\n");
    };

    styles('https://github.com/', function (styles) {
        gutil.log('Load Github style');
        get(styles[0], function (css) {
            process.stdout.write("\n");

            var postcss = require(__dirname + '/build');
            bench('PostCSS', function () {
                return postcss().process(css).css;
            });

            var CSSOM = require('cssom');
            bench('CSSOM', function () {
                return CSSOM.parse(css).toString();
            });

            var rework = require('rework');
            bench('Rework', function () {
                return rework(css).toString();
            });

            var gonzales = require('gonzales');
            bench('Gonzales', function () {
                return gonzales.csspToSrc( gonzales.srcToCSSP(css) );
            });

            var gonzalesPe = require('gonzales-pe');
            bench('Gonzales PE', function () {
                return gonzalesPe.astToSrc({
                    ast: gonzalesPe.srcToAST({ src: css })
                });
            });

            process.stdout.write("\n");
            done();
        });
    });
});

gulp.task('integration', ['build'], function (done) {
    var postcss = require('./build/');
    var test = function (css) {
        var processed;
        try {
            processed = postcss().process(css, {
                map: { annotation: false }
            }).css;
        } catch (e) {
            return 'Parsing error: ' + e.message + "\n\n" + e.stack;
        }

        if ( processed != css ) {
            return 'Output is not equal input';
        }
    };

    var links = [];
    var nextLink = function () {
        if ( links.length === 0 ) {
            nextSite();
            return;
        }

        var url = links.shift();
        get(url, function (css) {
            var error = test(css);
            if ( error ) {
                done(new gutil.PluginError('integration', {
                    showStack: false,
                    message:   "\nFile " + url + "\n\n" + error
                }));
            } else {
                nextLink();
            }
        });
    };

    var sites = [{ name: 'GitHub',       url: 'https://github.com/' },
                 { name: 'Twitter',      url: 'https://twitter.com/' },
                 { name: 'Bootstrap',    url: 'http://getbootstrap.com/' },
                 { name: 'Habrahabr',    url: 'http://habrahabr.ru/' },
                 { name: 'Browserhacks', url: 'http://browserhacks.com/' }];
    var nextSite = function () {
        if ( sites.length === 0 ) {
            done();
            return;
        }
        var site = sites.shift();

        gutil.log('Test ' + site.name + ' styles');
        styles(site.url, function (styles) {
            links = styles;
            nextLink();
        });
    };

    nextSite();
});

gulp.task('test', function () {
    require('./');
    var mocha = require('gulp-mocha');

    return gulp.src('test/*.js', { read: false })
        .pipe(mocha())
        .on('error', process.exit.bind(process, 1));
});

gulp.task('default', ['lint', 'test', 'integration']);
<commit_msg>Better PostCSS benchmark<commit_after>var gutil = require('gulp-util');
var gulp  = require('gulp');
var fs    = require('fs-extra');

gulp.task('clean', function () {
    fs.removeSync(__dirname + '/build');
});

gulp.task('build:lib', function () {
    var traceur = require('gulp-traceur');

    return gulp.src('lib/*.js')
        .pipe(traceur())
        .pipe(gulp.dest('build/lib'));
});

gulp.task('build:docs', function () {
    var ignore = require('fs').readFileSync('.npmignore').toString()
        .trim().split(/\n+/)
        .concat(['.npmignore', 'index.js', 'index.build.js'])
        .map(function (i) { return '!' + i; });

    return gulp.src(['*'].concat(ignore))
        .pipe(gulp.dest('build'));
});

gulp.task('build:index', function (done) {
    fs.copy('index.build.js', 'build/index.js', done);
});

gulp.task('build', ['clean', 'build:lib', 'build:docs', 'build:index']);

gulp.task('lint:test', function () {
    var jshint = require('gulp-jshint');

    return gulp.src('test/*.js')
        .pipe(jshint({ esnext: true, expr: true }))
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(jshint.reporter('fail'));
});

gulp.task('lint:lib', function () {
    var jshint = require('gulp-jshint');

    return gulp.src(['lib/*.js', 'index.js', 'index.build.js', 'gulpfile.js'])
        .pipe(jshint({ esnext: true }))
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(jshint.reporter('fail'));
});

gulp.task('lint', ['lint:test', 'lint:lib']);

var zlib, request;
var get = function (url, callback) {
    if ( !zlib ) {
        zlib    = require('zlib');
        request = require('request');
    }

    request.get({ url: url, headers: { 'accept-encoding': 'gzip,deflate' } })
        .on('response', function (res) {
            var chunks = [];
            res.on('data', function (i) {
                chunks.push(i);
            });
            res.on('end', function () {
                var buffer = Buffer.concat(chunks);

                if ( res.headers['content-encoding'] == 'gzip' ) {
                    zlib.gunzip(buffer, function (err, decoded) {
                        callback(decoded.toString());
                    });

                } else if ( res.headers['content-encoding'] == 'deflate' ) {
                    zlib.inflate(buffer, function (err, decoded) {
                        callback(decoded.toString());
                    });

                } else {
                    callback(buffer.toString());
                }
            });
        });
};

var styles = function (url, callback) {
    get(url, function (html) {
        var styles = html.match(/[^"]+\.css("|')/g);
        if ( !styles ) throw "Can't find CSS links at " + url;
        styles = styles.map(function(path) {
            path = path.slice(0, -1);
            if ( path.match(/^https?:/) ) {
                return path;
            } else {
                return path.replace(/^\.?\.?\/?/, url);
            }
        });
        callback(styles);
    });
};

gulp.task('bench', ['build'], function (done) {
    var indent = function (max, current) {
        var diff = max.toString().length - current.toString().length;
        for ( var i = 0; i < diff; i++ ) {
            process.stdout.write(' ');
        }
    };

    var times = { };
    var bench = function (title, callback) {
        process.stdout.write(title + ': ');
        indent('Gonzales PE', title);

        var start = new Date();

        for ( var i = 0; i < 10; i++ ) callback();

        time = (new Date()) - start;
        time = Math.round(time / 10);
        process.stdout.write(time + " ms");

        if ( times.PostCSS ) {
            var slower = time / times.PostCSS;
            if ( time < 100 ) process.stdout.write(' ');

            var result;
            if ( slower < 1 ) {
                result = ' (' + (1 / slower).toFixed(1) + ' times faster)';
            } else {
                result = ' (' + slower.toFixed(1) + ' times slower)';
            }
            process.stdout.write(result);
        }
        times[title] = time;
        process.stdout.write("\n");
    };

    styles('https://github.com/', function (styles) {
        gutil.log('Load Github style');
        get(styles[0], function (css) {
            process.stdout.write("\n");

            var processor = require(__dirname + '/build')();
            bench('PostCSS', function () {
                return processor.process(css).css;
            });

            var CSSOM = require('cssom');
            bench('CSSOM', function () {
                return CSSOM.parse(css).toString();
            });

            var rework = require('rework');
            bench('Rework', function () {
                return rework(css).toString();
            });

            var gonzales = require('gonzales');
            bench('Gonzales', function () {
                return gonzales.csspToSrc( gonzales.srcToCSSP(css) );
            });

            var gonzalesPe = require('gonzales-pe');
            bench('Gonzales PE', function () {
                return gonzalesPe.astToSrc({
                    ast: gonzalesPe.srcToAST({ src: css })
                });
            });

            process.stdout.write("\n");
            done();
        });
    });
});

gulp.task('integration', ['build'], function (done) {
    var postcss = require('./build/');
    var test = function (css) {
        var processed;
        try {
            processed = postcss().process(css, {
                map: { annotation: false }
            }).css;
        } catch (e) {
            return 'Parsing error: ' + e.message + "\n\n" + e.stack;
        }

        if ( processed != css ) {
            return 'Output is not equal input';
        }
    };

    var links = [];
    var nextLink = function () {
        if ( links.length === 0 ) {
            nextSite();
            return;
        }

        var url = links.shift();
        get(url, function (css) {
            var error = test(css);
            if ( error ) {
                done(new gutil.PluginError('integration', {
                    showStack: false,
                    message:   "\nFile " + url + "\n\n" + error
                }));
            } else {
                nextLink();
            }
        });
    };

    var sites = [{ name: 'GitHub',       url: 'https://github.com/' },
                 { name: 'Twitter',      url: 'https://twitter.com/' },
                 { name: 'Bootstrap',    url: 'http://getbootstrap.com/' },
                 { name: 'Habrahabr',    url: 'http://habrahabr.ru/' },
                 { name: 'Browserhacks', url: 'http://browserhacks.com/' }];
    var nextSite = function () {
        if ( sites.length === 0 ) {
            done();
            return;
        }
        var site = sites.shift();

        gutil.log('Test ' + site.name + ' styles');
        styles(site.url, function (styles) {
            links = styles;
            nextLink();
        });
    };

    nextSite();
});

gulp.task('test', function () {
    require('./');
    var mocha = require('gulp-mocha');

    return gulp.src('test/*.js', { read: false })
        .pipe(mocha())
        .on('error', process.exit.bind(process, 1));
});

gulp.task('default', ['lint', 'test', 'integration']);
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    watch = require('gulp-watch'),
    livereload = require('gulp-livereload');

gulp.task('css', require('./tasks/css'));
gulp.task('js', require('./tasks/js'));
gulp.task('i18n', require('./tasks/i18n'));
gulp.task('cssPage', require('./tasks/cssPage'));
gulp.task('jade-ru', require('./tasks/jade').ru);
gulp.task('jade-en', require('./tasks/jade').en);
gulp.task('gzip', require('./tasks/gzip'));

gulp.task('watch', function () {
    livereload.listen();

    gulp.watch('src/sass/*.scss', ['css']).on('change', function (file) {
        livereload.changed(file)
    });

    gulp.watch('src/js/**/*.js', ['js']).on('change', function (file) {
        livereload.changed(file)
    });

    gulp.watch('docs/sass/*.scss', ['cssPage']).on('change', function (file) {
        livereload.changed(file)
    });

    gulp.watch('docs/jade/**/*.jade', ['jade-ru', 'jade-en']).on('change', function (file) {
        livereload.changed(file)
    });
});

gulp.task('dev', ['css','js','i18n', 'cssPage', 'jade-ru', 'jade-en', 'watch']);
gulp.task('build', ['css','js','i18n', 'jade-ru',' jade-en']);

<commit_msg>fixed gulpfile<commit_after>var gulp = require('gulp'),
    watch = require('gulp-watch'),
    livereload = require('gulp-livereload');

gulp.task('css', require('./tasks/css'));
gulp.task('js', require('./tasks/js'));
gulp.task('i18n', require('./tasks/i18n'));
gulp.task('cssPage', require('./tasks/cssPage'));
gulp.task('jade-ru', require('./tasks/jade').ru);
gulp.task('jade-en', require('./tasks/jade').en);
gulp.task('gzip', require('./tasks/gzip'));

gulp.task('watch', function () {
    livereload.listen();

    gulp.watch('src/sass/*.scss', ['css']).on('change', function (file) {
        livereload.changed(file)
    });

    gulp.watch('src/js/**/*.js', ['js']).on('change', function (file) {
        livereload.changed(file)
    });

    gulp.watch('docs/sass/*.scss', ['cssPage']).on('change', function (file) {
        livereload.changed(file)
    });

    gulp.watch('docs/jade/**/*.jade', ['jade-ru', 'jade-en']).on('change', function (file) {
        livereload.changed(file)
    });
});

gulp.task('dev', ['css','js','i18n', 'cssPage', 'jade-ru', 'jade-en', 'watch']);
gulp.task('build', ['css','js','i18n', 'jade-ru', 'jade-en']);

<|endoftext|>


<commit_before>/* ==========================================================
 * gulpfile.js
 * List of Gulp.js task to build and run the project
 *
 * Author: Yann Gouffon, yann@antistatique.net
 * Date:   2014-04-29 17:53:14
 *
 * Copyright 2014 Federal Chancellery of Switzerland
 * Licensed under MIT
 *
 * Last Modified by:   Toni Fisler
 * Last Modified time: 2014-04-30 14:33:12
 ========================================================== */

 var gulp = require('gulp'),
    gutil = require('gulp-util'),
    notify = require('gulp-notify'),
    jshint = require('gulp-jshint'),
    sass = require('gulp-ruby-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    minifycss = require('gulp-minify-css'),
    browserSync = require('browser-sync'),
    rename = require('gulp-rename'),
    uglify = require('gulp-uglify'),
    concat = require('gulp-concat'),
    shell = require('gulp-shell'),
    stylish = require('jshint-stylish'),
    clean = require('gulp-clean');

// JS task
gulp.task('scripts', function() {
  gulp.src('./assets/js/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(concat('main.js'))
    .pipe(gulp.dest('./build/js'))
    .pipe(rename({ suffix: '.min' }))
    .pipe(uglify())
    .pipe(gulp.dest('build/js'));
});

// JS vendors concat and minify
gulp.task('js-vendors', function() {
  gulp.src([
      './bower_components/jquery/jquery.js',
      './bower_components/jquery.tablesorter/js/jquery.tablesorter.js',
      './bower_components/chosen_v1.1.0/chosen.jquery.min.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/affix.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/alert.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/button.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/carousel.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/collapse.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/dropdown.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/modal.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/tooltip.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/popover.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/scrollspy.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/tab.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/transition.js'
    ])
    .pipe(concat('vendors.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('build/js'));
});

// SASS compile, autoprefix and minify task
gulp.task('styles', function() {
  return gulp.src('assets/sass/admin.scss')
    .pipe(sass())
      .on('error', gutil.beep)
      .on('error', notify.onError("Error: <%= error.message %>"))
    .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
    .pipe(minifycss())
    .pipe(gulp.dest('build/css'));
});

// CSS vendors concat and minify
gulp.task('css-vendors', function() {
  gulp.src([
      './bower_components/yamm3/yamm/yamm.css'
    ])
    .pipe(concat('vendors.css'))
    .pipe(minifycss())
    .pipe(gulp.dest('./build/css'));
});

gulp.task('browser-sync', function() {
    browserSync.init(['./styleguide/**/*.html'], {
      proxy: 'localhost',
      open: false,
      debounce: 400
    });
});

gulp.task('hologram', function () {
  gulp.src('./build')
    .pipe(shell('LC_ALL="en_US.UTF-8" hologram'));
});

gulp.task('build-images', function() {
  return gulp.src(['assets/img/**'])
          .pipe(gulp.dest('build/img'));
});

gulp.task('build-fonts', function() {
  return gulp.src(['assets/fonts/**'])
          .pipe(gulp.dest('build/fonts'));
});

gulp.task('default', ['styles', 'watch', 'css-vendors', 'browser-sync', 'scripts', 'build-images', 'build-fonts', 'js-vendors']);
gulp.task('build', ['styles', 'scripts', 'css-vendors', 'build-images', 'build-fonts', 'js-vendors']);

gulp.task('watch', function() {
  gulp.watch('assets/sass/**/*.scss', ['styles']);
  gulp.watch('assets/js/*.js', ['scripts']);
  gulp.watch('build/**/*.{js,css}', ['hologram']);
  gulp.watch('assets/**/*.md', ['hologram']);
  gulp.watch(['assets/img/**/*.{jpg,png,gif,svg}'], ['build-images']);
  gulp.watch(['assets/fonts/**/*.{eot,svg,woff,ttf}'], ['build-fonts']);
});<commit_msg>build vendors JS and CSS in the same task<commit_after>/* ==========================================================
 * gulpfile.js
 * List of Gulp.js task to build and run the project
 *
 * Author: Yann Gouffon, yann@antistatique.net
 * Date:   2014-04-29 17:53:14
 *
 * Copyright 2014 Federal Chancellery of Switzerland
 * Licensed under MIT
 *
 * Last Modified by:   Toni Fisler
 * Last Modified time: 2014-04-30 14:33:12
 ========================================================== */

 var gulp = require('gulp'),
    gutil = require('gulp-util'),
    notify = require('gulp-notify'),
    jshint = require('gulp-jshint'),
    sass = require('gulp-ruby-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    minifycss = require('gulp-minify-css'),
    browserSync = require('browser-sync'),
    rename = require('gulp-rename'),
    uglify = require('gulp-uglify'),
    concat = require('gulp-concat'),
    shell = require('gulp-shell'),
    stylish = require('jshint-stylish'),
    clean = require('gulp-clean');

// JS task
gulp.task('scripts', function() {
  gulp.src('./assets/js/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(concat('main.js'))
    .pipe(gulp.dest('./build/js'))
    .pipe(rename({ suffix: '.min' }))
    .pipe(uglify())
    .pipe(gulp.dest('build/js'));
});

// Build vendors
gulp.task('vendors', function() {

  gulp.src([
          './bower_components/yamm3/yamm/yamm.css'
      ])
      .pipe(concat('vendors.css'))
      .pipe(minifycss())
      .pipe(gulp.dest('./build/css'));

  gulp.src([
      './bower_components/jquery/jquery.js',
      './bower_components/jquery.tablesorter/js/jquery.tablesorter.js',
      './bower_components/chosen_v1.1.0/chosen.jquery.min.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/affix.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/alert.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/button.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/carousel.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/collapse.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/dropdown.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/modal.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/tooltip.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/popover.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/scrollspy.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/tab.js',
      './bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/transition.js'
    ])
    .pipe(concat('vendors.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('build/js'));
});

// SASS compile, autoprefix and minify task
gulp.task('styles', function() {
  return gulp.src('assets/sass/admin.scss')
    .pipe(sass())
      .on('error', gutil.beep)
      .on('error', notify.onError("Error: <%= error.message %>"))
    .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
    .pipe(minifycss())
    .pipe(gulp.dest('build/css'));
});

gulp.task('browser-sync', function() {
    browserSync.init(['./styleguide/**/*.html'], {
      proxy: 'localhost',
      open: false,
      debounce: 400
    });
});

gulp.task('hologram', function () {
  gulp.src('./build')
    .pipe(shell('LC_ALL="en_US.UTF-8" hologram'));
});

gulp.task('build-images', function() {
  return gulp.src(['assets/img/**'])
          .pipe(gulp.dest('build/img'));
});

gulp.task('build-fonts', function() {
  return gulp.src(['assets/fonts/**'])
          .pipe(gulp.dest('build/fonts'));
});

gulp.task('default', ['styles', 'watch', 'vendors', 'browser-sync', 'scripts', 'build-images', 'build-fonts']);
gulp.task('build', ['styles', 'scripts', 'vendors', 'build-images', 'build-fonts']);

gulp.task('watch', function() {
  gulp.watch('assets/sass/**/*.scss', ['styles']);
  gulp.watch('assets/js/*.js', ['scripts']);
  gulp.watch('build/**/*.{js,css}', ['hologram']);
  gulp.watch('assets/**/*.md', ['hologram']);
  gulp.watch(['assets/img/**/*.{jpg,png,gif,svg}'], ['build-images']);
  gulp.watch(['assets/fonts/**/*.{eot,svg,woff,ttf}'], ['build-fonts']);
});<|endoftext|>


<commit_before>var gulp = require('gulp');
var mocha = require('gulp-mocha');
var rename = require('gulp-rename');
var license = require('gulp-license');
var concat = require('gulp-concat');
var bump = require('gulp-bump');
var clean = require('gulp-clean');
var eslint = require('gulp-eslint');
var istanbul = require('gulp-istanbul');

gulp.task('lint', ['lint-src', 'lint-test']);

gulp.task('lint-src', function() {
    return gulp.src('src/**/*.js').
        pipe(eslint({
            globals: {
                'require': false,
                'module': false
            },
            reset: true, // dz: remove me after linting is finished, else i can't do one at the time
            useEslintrc: true,
        })).
        pipe(eslint.format());
});

gulp.task('lint-test', function() {
    return gulp.src('test/**/*.js').
        pipe(eslint({
            globals: {
                'require': false,
                'module': false,
                'it': false,
                'xit': false,
                'describe': false
            },
            reset: true, // dz: remove me after linting is finished, else i can't do one at the time
            rules: {
                'max-len': [2, 200],
                'no-unused-expressions': 0
            },
            useEslintrc: true,
        })).
        pipe(eslint.format());
});

gulp.task('bump', function() {
    return gulp.
        src('package.json').
        pipe(bump({type: 'patch'})).
        pipe(gulp.dest('./'));
});

gulp.task('test-coverage', function (cb) {
    gulp.src(['./src/**/*.js']).
        pipe(istanbul()).
        pipe(istanbul.hookRequire()).
        on('finish', function () {
            gulp.src(['./test/index.js']).
                pipe(mocha()).
                pipe(istanbul.writeReports()).
                on('end', cb);
        });
});

gulp.task('test', function (cb) {
  gulp.src(['./test/index.js'])
    .pipe(mocha())
    .on('end', cb);
});

gulp.task('dist', ['lint', 'test-coverage']);
<commit_msg>Add root files to gulp lint task<commit_after>var gulp = require('gulp');
var mocha = require('gulp-mocha');
var rename = require('gulp-rename');
var license = require('gulp-license');
var concat = require('gulp-concat');
var bump = require('gulp-bump');
var clean = require('gulp-clean');
var eslint = require('gulp-eslint');
var istanbul = require('gulp-istanbul');

gulp.task('lint', ['lint-src', 'lint-test', 'lint-root']);

gulp.task('lint-src', function() {
    return gulp.src('src/**/*.js').
        pipe(eslint({
            globals: {
                'require': false,
                'module': false
            },
            reset: true, // dz: remove me after linting is finished, else i can't do one at the time
            useEslintrc: true,
        })).
        pipe(eslint.format());
});

gulp.task('lint-test', function() {
    return gulp.src('test/**/*.js').
        pipe(eslint({
            globals: {
                'require': false,
                'module': false,
                'it': false,
                'xit': false,
                'describe': false
            },
            reset: true, // dz: remove me after linting is finished, else i can't do one at the time
            rules: {
                'max-len': [2, 200],
                'no-unused-expressions': 0
            },
            useEslintrc: true,
        })).
        pipe(eslint.format());
});

gulp.task('lint-root', function() {
    return gulp.src('*.js').
        pipe(eslint({
            globals: {
                'require': false,
                'module': false
            },
            reset: true, // dz: remove me after linting is finished, else i can't do one at the time
            useEslintrc: true,
        })).
        pipe(eslint.format());
});

gulp.task('bump', function() {
    return gulp.
        src('package.json').
        pipe(bump({type: 'patch'})).
        pipe(gulp.dest('./'));
});

gulp.task('test-coverage', function (cb) {
    gulp.src(['./src/**/*.js']).
        pipe(istanbul()).
        pipe(istanbul.hookRequire()).
        on('finish', function () {
            gulp.src(['./test/index.js']).
                pipe(mocha()).
                pipe(istanbul.writeReports()).
                on('end', cb);
        });
});

gulp.task('test', function (cb) {
  gulp.src(['./test/index.js'])
    .pipe(mocha())
    .on('end', cb);
});

gulp.task('dist', ['lint', 'test-coverage']);
<|endoftext|>


<commit_before>var gulp  = require("gulp");
var sourcemaps = require("gulp-sourcemaps");
var concat = require("gulp-concat");
var sass  = require("gulp-sass");
var babel = require("gulp-babel");

var buildDir = "./build";

gulp.task("styles", function() {
	gulp.src("sass/**/*.scss")
		.pipe(sass().on("error", sass.logError))
		.pipe(gulp.dest(buildDir + "/css/"));
});

gulp.task("scripts", function() {
	return gulp.src("src/**/*.js")
		.pipe(sourcemaps.init())
		.pipe(babel())
		.pipe(concat("src.js"))
		.pipe(sourcemaps.write("."))
		.pipe(gulp.dest(buildDir + "/scripts/"));
});

gulp.task("default", function() {
	gulp.watch("src/**/*.js", ["scripts"]);
	gulp.watch("sass/**/*.scss", ["styles"]);
});
<commit_msg>Fixed the gulpfile<commit_after>var gulp  = require("gulp");
var sourcemaps = require("gulp-sourcemaps");
var concat = require("gulp-concat");
var sass  = require("gulp-sass");
var babel = require("gulp-babel");

var buildDir = "./build";

gulp.task("styles", function() {
	gulp.src("sass/**/*.scss")
		.pipe(sass().on("error", sass.logError))
		.pipe(gulp.dest(buildDir + "/css/"));
});

gulp.task("scripts", function() {
	return gulp.src("src/**/*.js")
		.pipe(sourcemaps.init())
		.pipe(babel())
		.pipe(gulp.dest(buildDir + "/scripts/"));
});

gulp.task("default", function() {
	gulp.watch("src/**/*.js", ["scripts"]);
	gulp.watch("sass/**/*.scss", ["styles"]);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
var uglify = require('gulp-uglify');
var mincss = require('gulp-cssmin');
var concat = require('gulp-concat');
var ignore = require('gulp-ignore');
var rimraf = require('rimraf');

var project = require('./project.json');
var lib = project.webroot + '/lib';
var content = project.webroot + '/content';

/* LIMPIO LA CARPETA DE DESTINO */
gulp.task('clean',function(done){
	rimraf(lib, done);
});
/* MINIFICO TODOS LOS PAQUETES */
gulp.task('minifyJs', ['clean'], function () {
    return gulp.src(mainBowerFiles())
        .pipe(ignore.exclude([ "**/*.css" ]))
      .pipe(uglify())
      .pipe(gulp.dest(lib+'/js'));
});

/* MINIFICO JS PARTICULARES CREADOS POR MI */
gulp.task('minifyJsContent', ['minifyJs'], function () {
    return gulp.src(content+'/js/*.js')
      .pipe(uglify())
      .pipe(gulp.dest(lib+'/js'));
});

/* MINIFICO CSS PARTICULARES CREADOS POR MI */
gulp.task('minifyCssContent', ['minifyJsContent'], function () {
    return gulp.src(content+'/css/site.css')
        .pipe(concat('front.css'))
      .pipe(mincss())
      .pipe(gulp.dest(lib+'/css/bundle/'));
});

/* BUNDLE PARA FRONT */
gulp.task('bundleFront', ['minifyCssContent'], function () {
    return gulp.src([lib+'/js/layzr.js',lib+'/js/material.min.js',lib+'/js/layout.js'])
      .pipe(concat('front.js'))
      .pipe(gulp.dest(lib+'/js/bundle/'));
});

gulp.task('default', ['bundleFront'], function () {
    return;
});<commit_msg>fixed gulp<commit_after>var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
var uglify = require('gulp-uglify');
var mincss = require('gulp-cssmin');
var concat = require('gulp-concat');
var ignore = require('gulp-ignore');
var rimraf = require('rimraf');

var lib = 'lib';
var content = 'content';

/* LIMPIO LA CARPETA DE DESTINO */
gulp.task('clean',function(done){
	rimraf(lib, done);
});
/* MINIFICO TODOS LOS PAQUETES */
gulp.task('minifyJs', ['clean'], function () {
    return gulp.src(mainBowerFiles())
        .pipe(ignore.exclude([ "**/*.css" ]))
      .pipe(uglify())
      .pipe(gulp.dest(lib+'/js'));
});

/* MINIFICO JS PARTICULARES CREADOS POR MI */
gulp.task('minifyJsContent', ['minifyJs'], function () {
    return gulp.src(content+'/js/*.js')
      .pipe(uglify())
      .pipe(gulp.dest(lib+'/js'));
});

/* MINIFICO CSS PARTICULARES CREADOS POR MI */
gulp.task('minifyCssContent', ['minifyJsContent'], function () {
    return gulp.src([content+'/css/site.css',content+'/css/TimeCircles.css'])
        .pipe(concat('front.css'))
      .pipe(mincss())
      .pipe(gulp.dest(lib+'/css/bundle/'));
});

/* BUNDLE PARA FRONT */
gulp.task('bundleFront', ['minifyCssContent'], function () {
    return gulp.src([lib+'/js/layzr.js',lib+'/js/material.min.js',lib+'/js/layout.js',lib+'/js/TimeCircles.js'])
      .pipe(concat('front.js'))
      .pipe(gulp.dest(lib+'/js/bundle/'));
});

gulp.task('default', ['bundleFront'], function () {
    return;
});<|endoftext|>


<commit_before>var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var autoprefixer = require('gulp-autoprefixer');
var minifycss = require('gulp-minify-css');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var rename = require('gulp-rename');
var del = require('del');
var stripDebug = require('gulp-strip-debug');
var args = require('yargs').argv;
var gulpif = require('gulp-if');
var gzip = require('gulp-gzip');
var fileInclude = require('gulp-file-include');
var markdown = require('gulp-markdown');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var frontMatter = require('gulp-front-matter');
var concat = require('gulp-concat');
var es = require('event-stream');
var mustache = require('mustache');
var fs = require('fs');
var sort = require('sort-stream');
var moment = require('moment');
var config = require('./config').config;

var destination = config.buildDest;

// command line params
// for instance: $ gulp --type production
var isProduction = args.type === 'production';

// blog page pipeline
gulp.task('blog', ['blog-posts-list'], function () {
  // taking the blog post list from the 'blog-posts-list' step
  // and including it into the blog.html template
  return gulp.src('src/blog/blog.html')
    .pipe(es.map(function (file, cb) {
      // first inject the build destination so include knows where to go
      var html = mustache.render(
        String(file.contents), {
          buildDest: config.buildDest
        });
      file.contents = new Buffer(html);
      cb(null, file);
    }))
    // then actually include the headers, navs, blogposts, footer and tail
    .pipe(fileInclude())
    // then set the title
    .pipe(es.map(function (file, cb) {
      var html = mustache.render(
        String(file.contents), {
          title: 'Blog'
        });
      file.contents = new Buffer(html);
      cb(null, file);
    }))
    // now we have /blog tada
    .pipe(rename('blog/index.html'))
    .pipe(gulp.dest(destination));
});

function capitalize (string) {
  return string[0].toUpperCase() + string.substr(1);
}

// blog post list for blog page
gulp.task('blog-posts-list', ['blog-posts-html'], function () {
  var postlist = String(fs.readFileSync('src/blog/blogposts.html'));

  return gulp.src('src/blog/markdown/**/*.md')
    // extract the frontmatter from the .md add to file attributes
    .pipe(frontMatter({
      property: 'frontMatter',
      remove: true
    }))
    // use the frontmatter to populate a blog post list
    .pipe(es.map(function (file, cb) {
      var html = mustache.render(postlist, {
        post: file.frontMatter,
        date: moment(file.frontMatter.date).format('MMMM D, YYYY'),
        authors: file.frontMatter.authors.map(function(a){return {
          lowercase: a,
          capital: capitalize(a)
        };})
      });
      file.contents = new Buffer(html);
      cb(null, file);
    }))
    // sort the list newest-first
    .pipe(sort(function (a, b) {
      if (a.frontMatter.date > b.frontMatter.date) return -1;
      if (a.frontMatter.date < b.frontMatter.date) return 1;
      return 0;
    }))
    // concat the list into a single html
    .pipe(concat('blogposts.html'))
    .pipe(gulp.dest(destination));
});

// fill out the blog post templates
gulp.task('blog-posts-html', function () {
  var post = String(fs.readFileSync('src/blog/post.html'));
  var dir = '';
  return gulp.src('src/blog/markdown/**/*.md')
    // extract frontmatter from markdown, append to file attributes
    .pipe(frontMatter({
      property: 'frontMatter',
      remove: true
    }))
    // render the partial
    .pipe(markdown())
    // insert frontmatter and partial as mustache vars into post template
    .pipe(es.map(function (file, cb) {
      var html = mustache.render(post, {
        buildDest: config.buildDest,
        include: file.frontMatter.readfullarticle,
        date: moment(file.frontMatter.date).format('MMMM D, YYYY'),
        authors: file.frontMatter.authors,
        rendered: file.contents
      });
      file.contents = new Buffer(html);
      cb(null, file);
    }))
    // include stuff
    .pipe(fileInclude())
    // get the blog post directory name from the .md file name
    .pipe(es.map(function (file, cb) {
      dir = file.path.split('/');
      dir = dir[dir.length - 1].replace('.md', '');
      cb(null, file);
    }))
    // insert handlebars values from frontmatter into head template
    .pipe(es.map(function (file, cb) {
      file.contents = new Buffer(
        mustache.render(
          String(file.contents), {
            title: file.frontMatter.title,
            base: config.baseURL,
            include: file.frontMatter.readfullarticle,
            summary: file.frontMatter.summary
          }));
      cb(null, file);
    }))
    // rename the destination path for the file (avoiding .html)
    .pipe(rename(function (path) {
      path.dirname = dir.split('.')[0];
      path.basename = "index";
      path.extname = ".html";
    }))
    .pipe(gulp.dest(destination + '/blog'));
});

// html
gulp.task('html', ['blog'], function () {
  var dir = '';
  return gulp.src('src/html/**/*.html')
    .pipe(frontMatter({
      property: 'frontMatter',
      remove: true
    }))
    .pipe(fileInclude())
    .pipe(es.map(function (file, cb) {
      var html = mustache.render(
        String(file.contents), {
          title: file.frontMatter.title
        });
      file.contents = new Buffer(html);
      cb(null, file);
    }))
    .pipe(gulpif(isProduction, gzip()))
    // get the page directory name from the file name
    .pipe(es.map(function (file, cb) {
      dir = file.path.split('/');
      dir = dir[dir.length - 1].replace('.html', '');
      cb(null, file);
    }))
    // rename the destination path for the file (avoiding .html)
    // unless it is index.html in which case just ignore it
    .pipe(rename(function (path) {
      if (path.basename !== 'index') {
        path.dirname = path.dirname + '/' + dir;
        path.basename = "index";
        path.extname = ".html";
      }
    }))
    .pipe(gulp.dest(destination));
});

// copy some fonts over
gulp.task('fonts', function () {
  gulp.src('src/fonts/**/*.*', { base: './src/fonts/' })
    .pipe(gulp.dest(destination + '/assets/fonts'));
});

// sass
gulp.task('styles', ['fonts'], function() {
  return gulp.src('src/styles/**/*.scss')
    .pipe(sass({ style: 'expanded', container: './tmp' }))
    .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
    .pipe(gulpif(isProduction, rename({suffix: '.min'})))
    .pipe(gulpif(isProduction, minifycss()))
    .pipe(gulpif(isProduction, gzip()))
    .pipe(gulp.dest(destination + '/assets/css'));
});

// browserify
gulp.task('browserify', ['jshint'], function () {
  return browserify('./src/scripts/main.js')
    .bundle()
    //Pass desired output filename to vinyl-source-stream
    .pipe(source('bundle.js'))
    // Start piping stream to tasks!
    .pipe(gulp.dest(destination + '/assets/js'));
});

// jshint
gulp.task('jshint', function() {
  return gulp.src('src/scripts/**/*.js')
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter('default'));
});

// js
gulp.task('scripts', ['browserify'], function() {
  return gulp.src(destination + '/assets/js/bundle.js')
    .pipe(gulpif(isProduction, rename({suffix: '.min'})))
    .pipe(gulpif(isProduction, uglify()))
    .pipe(gulpif(isProduction, stripDebug()))
    .pipe(gulpif(isProduction, gzip()))
    .pipe(gulp.dest(destination + '/assets/js'));
});

// images
gulp.task('images', function() {
  return gulp.src(['src/images/**/*.png', 'src/images/**/*.jpg', 'src/images/**/*.svg', 'src/images/**/*.gif', 'src/images/**/*.ico'])
    .pipe(
      gulpif(
        isProduction,
        imagemin(
          {
            optimizationLevel: 5,
            progressive: true,
            interlaced: true
          }
        )
      )
    )
    .pipe(gulp.dest(destination + '/assets/img'));
});

gulp.task('clean', function(cb) {
  del([destination + '/*', destination + '/assets/css', destination + '/assets/fonts', destination + '/assets/js', destination + '/assets/img', destination + '/prototype', '!'+destination+'/editor'], {force:true}, cb);
});

// default build task
gulp.task('default', ['clean'], function() {
  // clean first, then these
  gulp.start('html', 'styles', 'scripts', 'images');
});

// watch
gulp.task('watch', ['default'], function() {
  // if anything changes, rebuild
  gulp.watch('src/markdown/**/*.md', ['html']);
  gulp.watch('src/templates/**/*.tpl', ['html']);
  gulp.watch('src/html/**/*.html', ['html']);
  gulp.watch('src/blog/**/*.md', ['html']);
  gulp.watch('src/styles/**/*.scss', ['styles']);
  gulp.watch('src/fonts/**/*.*', ['fonts']);
  gulp.watch('src/scripts/**/*.js', ['scripts']);
  gulp.watch('src/images/**/*', ['images']);
});<commit_msg>copying over xml files<commit_after>var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var autoprefixer = require('gulp-autoprefixer');
var minifycss = require('gulp-minify-css');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var rename = require('gulp-rename');
var del = require('del');
var stripDebug = require('gulp-strip-debug');
var args = require('yargs').argv;
var gulpif = require('gulp-if');
var gzip = require('gulp-gzip');
var fileInclude = require('gulp-file-include');
var markdown = require('gulp-markdown');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var frontMatter = require('gulp-front-matter');
var concat = require('gulp-concat');
var es = require('event-stream');
var mustache = require('mustache');
var fs = require('fs');
var sort = require('sort-stream');
var moment = require('moment');
var config = require('./config').config;

var destination = config.buildDest;

// command line params
// for instance: $ gulp --type production
var isProduction = args.type === 'production';

// blog page pipeline
gulp.task('blog', ['blog-posts-list'], function () {
  // taking the blog post list from the 'blog-posts-list' step
  // and including it into the blog.html template
  return gulp.src('src/blog/blog.html')
    .pipe(es.map(function (file, cb) {
      // first inject the build destination so include knows where to go
      var html = mustache.render(
        String(file.contents), {
          buildDest: config.buildDest
        });
      file.contents = new Buffer(html);
      cb(null, file);
    }))
    // then actually include the headers, navs, blogposts, footer and tail
    .pipe(fileInclude())
    // then set the title
    .pipe(es.map(function (file, cb) {
      var html = mustache.render(
        String(file.contents), {
          title: 'Blog'
        });
      file.contents = new Buffer(html);
      cb(null, file);
    }))
    // now we have /blog tada
    .pipe(rename('blog/index.html'))
    .pipe(gulp.dest(destination));
});

function capitalize (string) {
  return string[0].toUpperCase() + string.substr(1);
}

// blog post list for blog page
gulp.task('blog-posts-list', ['blog-posts-html'], function () {
  var postlist = String(fs.readFileSync('src/blog/blogposts.html'));

  return gulp.src('src/blog/markdown/**/*.md')
    // extract the frontmatter from the .md add to file attributes
    .pipe(frontMatter({
      property: 'frontMatter',
      remove: true
    }))
    // use the frontmatter to populate a blog post list
    .pipe(es.map(function (file, cb) {
      var html = mustache.render(postlist, {
        post: file.frontMatter,
        date: moment(file.frontMatter.date).format('MMMM D, YYYY'),
        authors: file.frontMatter.authors.map(function(a){return {
          lowercase: a,
          capital: capitalize(a)
        };})
      });
      file.contents = new Buffer(html);
      cb(null, file);
    }))
    // sort the list newest-first
    .pipe(sort(function (a, b) {
      if (a.frontMatter.date > b.frontMatter.date) return -1;
      if (a.frontMatter.date < b.frontMatter.date) return 1;
      return 0;
    }))
    // concat the list into a single html
    .pipe(concat('blogposts.html'))
    .pipe(gulp.dest(destination));
});

// fill out the blog post templates
gulp.task('blog-posts-html', function () {
  var post = String(fs.readFileSync('src/blog/post.html'));
  var dir = '';
  return gulp.src('src/blog/markdown/**/*.md')
    // extract frontmatter from markdown, append to file attributes
    .pipe(frontMatter({
      property: 'frontMatter',
      remove: true
    }))
    // render the partial
    .pipe(markdown())
    // insert frontmatter and partial as mustache vars into post template
    .pipe(es.map(function (file, cb) {
      var html = mustache.render(post, {
        buildDest: config.buildDest,
        include: file.frontMatter.readfullarticle,
        date: moment(file.frontMatter.date).format('MMMM D, YYYY'),
        authors: file.frontMatter.authors,
        rendered: file.contents
      });
      file.contents = new Buffer(html);
      cb(null, file);
    }))
    // include stuff
    .pipe(fileInclude())
    // get the blog post directory name from the .md file name
    .pipe(es.map(function (file, cb) {
      dir = file.path.split('/');
      dir = dir[dir.length - 1].replace('.md', '');
      cb(null, file);
    }))
    // insert handlebars values from frontmatter into head template
    .pipe(es.map(function (file, cb) {
      file.contents = new Buffer(
        mustache.render(
          String(file.contents), {
            title: file.frontMatter.title,
            base: config.baseURL,
            include: file.frontMatter.readfullarticle,
            summary: file.frontMatter.summary
          }));
      cb(null, file);
    }))
    // rename the destination path for the file (avoiding .html)
    .pipe(rename(function (path) {
      path.dirname = dir.split('.')[0];
      path.basename = "index";
      path.extname = ".html";
    }))
    .pipe(gulp.dest(destination + '/blog'));
});

// html
gulp.task('html', ['blog'], function () {
  var dir = '';
  return gulp.src('src/html/**/*.html')
    .pipe(frontMatter({
      property: 'frontMatter',
      remove: true
    }))
    .pipe(fileInclude())
    .pipe(es.map(function (file, cb) {
      var html = mustache.render(
        String(file.contents), {
          title: file.frontMatter.title
        });
      file.contents = new Buffer(html);
      cb(null, file);
    }))
    .pipe(gulpif(isProduction, gzip()))
    // get the page directory name from the file name
    .pipe(es.map(function (file, cb) {
      dir = file.path.split('/');
      dir = dir[dir.length - 1].replace('.html', '');
      cb(null, file);
    }))
    // rename the destination path for the file (avoiding .html)
    // unless it is index.html in which case just ignore it
    .pipe(rename(function (path) {
      if (path.basename !== 'index') {
        path.dirname = path.dirname + '/' + dir;
        path.basename = "index";
        path.extname = ".html";
      }
    }))
    .pipe(gulp.dest(destination));
});

// copy some fonts over
gulp.task('fonts', function () {
  gulp.src('src/fonts/**/*.*', { base: './src/fonts/' })
    .pipe(gulp.dest(destination + '/assets/fonts'));
});

// sass
gulp.task('styles', ['fonts'], function() {
  return gulp.src('src/styles/**/*.scss')
    .pipe(sass({ style: 'expanded', container: './tmp' }))
    .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
    .pipe(gulpif(isProduction, rename({suffix: '.min'})))
    .pipe(gulpif(isProduction, minifycss()))
    .pipe(gulpif(isProduction, gzip()))
    .pipe(gulp.dest(destination + '/assets/css'));
});

// browserify
gulp.task('browserify', ['jshint'], function () {
  return browserify('./src/scripts/main.js')
    .bundle()
    //Pass desired output filename to vinyl-source-stream
    .pipe(source('bundle.js'))
    // Start piping stream to tasks!
    .pipe(gulp.dest(destination + '/assets/js'));
});

// jshint
gulp.task('jshint', function() {
  return gulp.src('src/scripts/**/*.js')
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter('default'));
});

// js
gulp.task('scripts', ['browserify'], function() {
  return gulp.src(destination + '/assets/js/bundle.js')
    .pipe(gulpif(isProduction, rename({suffix: '.min'})))
    .pipe(gulpif(isProduction, uglify()))
    .pipe(gulpif(isProduction, stripDebug()))
    .pipe(gulpif(isProduction, gzip()))
    .pipe(gulp.dest(destination + '/assets/js'));
});

// images
gulp.task('images', function() {
  return gulp.src(['src/images/**/*.png', 'src/images/**/*.jpg', 'src/images/**/*.svg', 'src/images/**/*.gif', 'src/images/**/*.ico'])
    .pipe(
      gulpif(
        isProduction,
        imagemin(
          {
            optimizationLevel: 5,
            progressive: true,
            interlaced: true
          }
        )
      )
    )
    .pipe(gulp.dest(destination + '/assets/img'));
});

// copy xml
gulp.task('xml', function () {
  gulp.src('src/**/*.xml')
    .pipe(gulp.dest(destination));
});

gulp.task('clean', function(cb) {
  del([destination + '/*', destination + '/assets/css', destination + '/assets/fonts', destination + '/assets/js', destination + '/assets/img', destination + '/prototype', '!'+destination+'/editor'], {force:true}, cb);
});

// default build task
gulp.task('default', ['clean'], function() {
  // clean first, then these
  gulp.start('html', 'xml', 'styles', 'scripts', 'images');
});

// watch
gulp.task('watch', ['default'], function() {
  // if anything changes, rebuild
  gulp.watch('src/markdown/**/*.md', ['html']);
  gulp.watch('src/templates/**/*.tpl', ['html']);
  gulp.watch('src/html/**/*.html', ['html']);
  gulp.watch('src/blog/**/*.md', ['html']);
  gulp.watch('src/styles/**/*.scss', ['styles']);
  gulp.watch('src/fonts/**/*.*', ['fonts']);
  gulp.watch('src/scripts/**/*.js', ['scripts']);
  gulp.watch('src/images/**/*', ['images']);
});<|endoftext|>


<commit_before>// Gulp
var gulp = require('gulp');

// Tools
var complexity = require('gulp-complexity');
var complexityOpts = {
	errorsOnly      : false,
	cyclomatic      : 3,
	halstead        : 10,
	maintainability : 90,
	trycatch        : true
};

var bump = require('gulp-bump');

// Validation
var jshint = require('gulp-jshint');
var jshintOpts = {
	options : {
		strict : true
	}
};

var stylish = require('jshint-stylish');
var jscs = require('gulp-jscs');

// Testing
var mocha = require('gulp-mocha');

// Reports
var istanbul = require('gulp-istanbul');
var plato = require('gulp-plato');
var platoOpts = {
	jshint     : jshintOpts,
	complexity : complexityOpts
};
// Target Files
var sources = ['gulpfile.js', './lib/*.js', './test/specs/*.js'];
var pkg = './package.json';
var tests = './test/specs/*.js';

// Tasks
gulp.task('bump:patch', function () {
	'use strict';

	gulp.src('./package.json')
		.pipe(bump())
		.pipe(gulp.dest('./'));
});

gulp.task('bump:minor', function () {
	'use strict';

	gulp.src(pkg)
		.pipe(bump({type : 'minor'}))
		.pipe(gulp.dest('./'));
});

gulp.task('bump:major', function () {
	'use strict';

	gulp.src(pkg)
		.pipe(bump({type : 'major'}))
		.pipe(gulp.dest('./'));
});

gulp.task('format', function () {
	'use strict';

	gulp.src(sources)
		.pipe(jscs());
});

gulp.task('lint', function () {
	'use strict';

	gulp.src(sources)
		.pipe(jshint())
		.pipe(jshint.reporter(stylish));
});

gulp.task('plato', function () {
	'use strict';

	gulp.src(sources)
		.pipe(plato('./metrics/report', platoOpts));
});

/*
	@errorsOnly - show only maintainabilty errors
	@cycolmatic - typical acceptance is a value of 4 (lower is better)
	@halstead - typcial acceptance is 10, (lower is better)
	@maintainability - typical acceptance is ~70. Higher is better, 171 max
*/
gulp.task('complexity', function () {
	'use strict';

	gulp.src(sources)
		.pipe(complexity(complexityOpts));
});

gulp.task('test', function (cb) {
	'use strict';

	gulp.src(['./lib/**/*.js'])
		.pipe(istanbul()) // Covering files
		.on('finish', function () {
			gulp.src(tests)
				.pipe(mocha({reporter : 'nyan'}))
				.pipe(istanbul.writeReports({
					reporters : ['text-summary']
				}))
				.on('end', cb);
		});
});

gulp.task('coverage', function (cb) {
	'use strict';

	gulp.src(['./lib/**/*.js'])
		.pipe(istanbul()) // Covering files
		.on('finish', function () {
			gulp.src(tests)
				.pipe(mocha({reporter : 'nyan'}))
				.pipe(istanbul.writeReports('./metrics/coverage'))
				.on('end', cb);
		});
});

// Grouped Tasks
gulp.task('default', ['format', 'lint', 'complexity', 'test']);
gulp.task('report', ['plato', 'coverage']);
<commit_msg>added watch task to gulpfile<commit_after>// Gulp
var gulp = require('gulp');

// Tools
var complexity = require('gulp-complexity');
var complexityOpts = {
	errorsOnly      : false,
	cyclomatic      : 3,
	halstead        : 10,
	maintainability : 90,
	trycatch        : true
};

var bump = require('gulp-bump');

// Validation
var jshint = require('gulp-jshint');
var jshintOpts = {
	options : {
		strict : true
	}
};

var stylish = require('jshint-stylish');
var jscs = require('gulp-jscs');

// Testing
var mocha = require('gulp-mocha');

// Reports
var istanbul = require('gulp-istanbul');
var plato = require('gulp-plato');
var platoOpts = {
	jshint     : jshintOpts,
	complexity : complexityOpts
};
// Target Files
var sources = ['gulpfile.js', './lib/*.js', './test/specs/*.js'];
var pkg = './package.json';
var tests = './test/specs/*.js';

// Tasks
gulp.task('bump:patch', function () {
	'use strict';

	gulp.src('./package.json')
		.pipe(bump())
		.pipe(gulp.dest('./'));
});

gulp.task('bump:minor', function () {
	'use strict';

	gulp.src(pkg)
		.pipe(bump({type : 'minor'}))
		.pipe(gulp.dest('./'));
});

gulp.task('bump:major', function () {
	'use strict';

	gulp.src(pkg)
		.pipe(bump({type : 'major'}))
		.pipe(gulp.dest('./'));
});

gulp.task('format', function () {
	'use strict';

	gulp.src(sources)
		.pipe(jscs());
});

gulp.task('lint', function () {
	'use strict';

	gulp.src(sources)
		.pipe(jshint())
		.pipe(jshint.reporter(stylish));
});

gulp.task('plato', function () {
	'use strict';

	gulp.src(sources)
		.pipe(plato('./metrics/report', platoOpts));
});

/*
	@errorsOnly - show only maintainabilty errors
	@cycolmatic - typical acceptance is a value of 4 (lower is better)
	@halstead - typcial acceptance is 10, (lower is better)
	@maintainability - typical acceptance is ~70. Higher is better, 171 max
*/
gulp.task('complexity', function () {
	'use strict';

	gulp.src(sources)
		.pipe(complexity(complexityOpts));
});

gulp.task('test', function (cb) {
	'use strict';

	gulp.src(['./lib/**/*.js'])
		.pipe(istanbul()) // Covering files
		.on('finish', function () {
			gulp.src(tests)
				.pipe(mocha({reporter : 'nyan'}))
				.pipe(istanbul.writeReports({
					reporters : ['text-summary']
				}))
				.on('end', cb);
		});
});

gulp.task('coverage', function (cb) {
	'use strict';

	gulp.src(['./lib/**/*.js'])
		.pipe(istanbul()) // Covering files
		.on('finish', function () {
			gulp.src(tests)
				.pipe(mocha({reporter : 'nyan'}))
				.pipe(istanbul.writeReports('./metrics/coverage'))
				.on('end', cb);
		});
});

gulp.task('watch', function () {
	'use strict';

	gulp.watch(sources[1], ['default']);
});

// Grouped Tasks
gulp.task('default', ['format', 'lint', 'complexity', 'test']);
gulp.task('report', ['plato', 'coverage']);
<|endoftext|>


<commit_before>/**
 * @name            Gulpfile for Gulp v4
 * @author          J. D. Riviere
 * @desc            This is the gulpfile.js that uses the Gulp v4 constalities = .
 */

/* ==================================== */
/* MODULES
/* ==================================== */
const gulp = require('gulp');
const rename = require('gulp-rename');
const sass = require('gulp-sass');
const postcss = require('gulp-postcss');
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('autoprefixer');
const header = require('postcss-header');
const cssnano = require('cssnano');
const del = require('del');

/* ==================================== */
/* GLOBAL VARIABLES
/* ==================================== */
const pkg = require('./package.json');

const paths = {
  styles: {
    src: 'src/sass/sparkle.sass',
    dest: 'dist/css/'
  }
};

const banner = `
/*!
  * @name         ${pkg.name}
  * @author       ${pkg.author}
  * @version      ${pkg.version} - released on XX/XX/2019
  * @website      ${pkg.homepage}
  * @license      ${pkg.license}
  * Welcome and thank you for using Sparkle, a lightweight, open-source CSS framework
  * to help you create simple, responsive website templates. It was developed by J. Djimitry Riviere
  * in late 2016, and continues to be improved upon by its developer to bring more creative features.
  * The major key to this framework lies within its ease of us to deliver superb results
  * when creating a website.
  * Thank you for using Sparkle! Happy Designing!
  */
`;

const options = [
  header({
    header: banner
  }),
  autoprefixer({
    browsers: [
      'last 3 versions',
      "IE >= 10"
    ]
  })
];

const shrinkOptions = [cssnano()];

/* ==================================== */
/* TASKS
/* ==================================== */
//--- Clean ---//
const clean = () => {
  console.log('Deleting files in \'dist\' folder...\n');
  return del(['dist/css/sparkle.*']);
}; // End of Clean

//--- Sassify ---//
const sassify = () => {
  console.log('Building expanded CSS file...\n');
  return gulp.src(paths.styles.src)
    .pipe(sourcemaps.init())
    .pipe(sass({ outputStyle: 'expanded' }).on('error', sass.logError))
    .pipe(postcss(options))
    .pipe(rename('sparkle.css'))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(paths.styles.dest));
}; // End of Sassify

//--- Minify ---//
const minify = () => {
  console.log('Building minified CSS files...\n');
  return gulp.src(paths.styles.src)
    .pipe(sourcemaps.init())
    .pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
    .pipe(postcss(options))
    .pipe(postcss(shrinkOptions))
    .pipe(rename({
      base: 'sparkle',
      suffix: '.min'
    }))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(paths.styles.dest));
}; // End of Minify

//--- Watch ---//
const watch = () => {
  console.log('Watching SASS files for changes...\n');
  gulp.watch(paths.styles.src, sassify);
}; // End of Watch

/* ==================================== */
/* SERIES AND PARALLELS
/* ==================================== */
const build = gulp.series(clean, gulp.parallel(sassify, minify));

/* ==================================== */
/* DESCRIPTIONS
/* ==================================== */
build.description = 'Builds the expanded CSS file in production mode.';
clean.description = 'Deletes all files within the \'dist\' folder. A private command.';
minify.description = 'Builds the minified CSS file in production mode.';
sassify.description = 'Builds the CSS file in development mode.';
watch.description = 'Watches all the CSS files (mainly the \'sparkle.sass\' file) for changes.';

/* ==================================== */
/* EXPORT TASKS
/* ==================================== */
exports.sassify = sassify;
exports.minify = minify;
exports.watch = watch;

/* ==================================== */
/* DEFAULT TASK RUNNER
/* ==================================== */
exports.default = build;<commit_msg>chore(gulpfile.js): Minor changes and fixes on names, descriptions, and commands.<commit_after>/**
 * @name            Sparkle.css Gulpfile (Gulp v4)
 * @author          J. D. Riviere
 * @desc            A series of commands that can be used in a terminal or command line, if
 *                  Gulp (version 4.0.x) is installed.
 */

/* ==================================== */
/* MODULES
/* ==================================== */
const gulp = require('gulp');
const rename = require('gulp-rename');
const sass = require('gulp-sass');
const postcss = require('gulp-postcss');
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('autoprefixer');
const header = require('postcss-header');
const cssnano = require('cssnano');
const del = require('del');

/* ==================================== */
/* GLOBAL VARIABLES
/* ==================================== */
const pkg = require('./package.json');

const paths = {
  styles: {
    src: 'src/sass/sparkle.sass',
    dest: 'dist/css/'
  }
};

const banner = `
/*!
  * @name         ${pkg.name}
  * @author       ${pkg.author}
  * @version      ${pkg.version} - released on XX/XX/2019
  * @website      ${pkg.homepage}
  * @license      ${pkg.license}
  * Welcome and thank you for using Sparkle, a lightweight, open-source CSS framework
  * to help you create simple, responsive website templates. It was developed by J. Djimitry Riviere
  * in late 2016, and continues to be improved upon by its developer to bring more creative features.
  * The major key to this framework lies within its ease of us to deliver superb results
  * when creating a website.
  * Thank you for using Sparkle! Happy Designing!
  */
`;

const options = [
  header({
    header: banner
  }),
  autoprefixer({
    browsers: [
      'last 3 versions',
      "IE >= 10"
    ]
  })
];

const shrinkOptions = [cssnano()];

/* ==================================== */
/* TASKS
/* ==================================== */
//--- Clean ---//
const clean = () => {
  console.log('Deleting files in \'dist\' folder...\n');
  return del(['dist/css/sparkle.*']);
}; // End of Clean

//--- Sassify ---//
const sassify = () => {
  console.log('Building expanded CSS file...\n');
  return gulp.src(paths.styles.src)
    .pipe(sourcemaps.init())
    .pipe(sass({ outputStyle: 'expanded' }).on('error', sass.logError))
    .pipe(postcss(options))
    .pipe(rename('sparkle.css'))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(paths.styles.dest));
}; // End of Sassify

//--- Minify ---//
const minify = () => {
  console.log('Building minified CSS files...\n');
  return gulp.src(paths.styles.src)
    .pipe(sourcemaps.init())
    .pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
    .pipe(postcss(options))
    .pipe(postcss(shrinkOptions))
    .pipe(rename({
      base: 'sparkle',
      suffix: '.min'
    }))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(paths.styles.dest));
}; // End of Minify

//--- Watch ---//
const watch = () => {
  console.log('Watching SASS files for changes...\n');
  gulp.watch(paths.styles.src, sassify);
}; // End of Watch

/* ==================================== */
/* SERIES AND PARALLELS
/* ==================================== */
const build = gulp.series(clean, gulp.parallel(sassify, minify));

/* ==================================== */
/* DESCRIPTIONS
/* ==================================== */
build.description = 'Builds the expanded and minified CSS files in production mode.';
clean.description = 'Deletes all files within the \'dist\' folder. A private command.';
minify.description = 'Builds the minified CSS file.';
sassify.description = 'Builds the expanded CSS file.';
watch.description = 'Watches all the CSS files (mainly the \'sparkle.sass\' file) for changes.';

/* ==================================== */
/* EXPORT TASKS
/* ==================================== */
exports.sassify = sassify;
exports.minify = minify;
exports.watch = watch;

/* ==================================== */
/* DEFAULT TASK RUNNER
/* ==================================== */
exports.default = build;<|endoftext|>


<commit_before>var gulp = require('gulp'),
    jshint = require('gulp-jshint'),
    prefix = require('gulp-autoprefixer'),
    sass = require('gulp-sass'),
    scsslint = require('gulp-scss-lint'),
    concat = require('gulp-concat'),
    minifycss = require('gulp-minify-css'),
    uglify = require('gulp-uglify'),
    imagemin = require('gulp-imagemin'),
    plumber = require('gulp-plumber'),
    header = require('gulp-header'),
    gutil = require('gulp-util'),
    sourcemaps = require('gulp-sourcemaps'),
    svg2png    = require('gulp-svg2png'),
    svgSymbols = require('gulp-svg-symbols'),
    browserSync = require('browser-sync'),
    reload      = browserSync.reload,

    paths = {
        scripts: [
            'src/js/vendor/*.js',
            'src/js/*.js'
        ],
        images: [
            'img/*'
        ],
        icons: [
            'img/icons/**/*.svg'
        ],
        sass: [
            'src/scss/*.scss',
            'src/scss/helpers/*.scss',
            'src/scss/base/*.scss',
            'src/scss/important/*.scss',
            'src/scss/layout/*.scss',
            'src/scss/modules/*.scss',
            'src/scss/state/*.scss',
            'src/scss/*.scss'
        ],
    },

    theme = require('./theme.json'),
        themeBanner = [
            '/*',
            'Theme Name: <%= theme.name %>',
            'Theme URI: <%= theme.uri %>',
            'Author: <%= theme.author %>',
            'Description: <%= theme.description %>',
            'Version: <%= theme.version %>',
            'License: <%= theme.license %>',
            '*/',
            '',
            '',
        ].join('\n');

/**
 * Error handling
 */
onError = function (err) {
    gutil.beep();
    console.log(err);
};

/**
 * Sass
 */
gulp.task('sass', function(){
    return gulp.src(paths.sass)
        .pipe(sourcemaps.init())
        .pipe(plumber({ errorHandler: onError }))
        //.pipe(scsslint({
            //'config': '.scss-lint.yml'
        //}))
        .pipe(sass.sync({errLogToConsole: true}))
        .pipe(prefix({
            browsers: ['last 4 version', 'ie 8', 'ie 7'],
            cascade: true
        }))
        .pipe(minifycss({
            compatibility: 'ie8'
        }))
        .pipe(header(themeBanner, { theme : theme } ))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./'))
});

/**
 * JavaScript
 */
gulp.task('js', function () {
    return gulp.src(paths.scripts)
        .pipe(jshint())
        .pipe(plumber({ errorHandler: onError }))
        .pipe(uglify({mangle: true}))
        .pipe(concat('base.min.js'))
        .pipe(gulp.dest('js'));
});

/**
 * Image Minify
 */
gulp.task('img', function () {
    return gulp.src(paths.images)
        .pipe(imagemin({ progressive: true, }))
        .pipe(gulp.dest('img'))
});

/**
 * SVG PNG fallback task
 */
gulp.task('svg2png', function () {
    return gulp.src(paths.icons)
    .pipe(plumber({ errorHandler: onError }))
        .pipe(svg2png())
        .pipe(gulp.dest('img/icons/'))
});

/**
 * Sprites task
 */
gulp.task('sprites', ['svg2png'], function () {
    return gulp.src(paths.icons)
    .pipe(plumber({ errorHandler: onError }))
        .pipe(
            svgSymbols({
                title: false,
                templates: ['default-svg']
            })
        )
        .pipe( gulp.dest( 'img/icons/' ) )
});

/**
 * Browser Sync
 */
gulp.task('browser-sync', function() {
    browserSync.init({
        server: {
            baseDir: "./"
        }
    });
});

/**
 * Watch Files
 */
gulp.task('watch', function () {
    gulp.watch(paths.sass, ['sass']).on("change", reload);
    gulp.watch(paths.scripts, ['js']).on("change", reload);
    gulp.watch(paths.images, ['img']).on("change", reload);
    gulp.watch("*.html").on("change", reload);
});

/**
 * Default
 */
gulp.task('default', ['sass', 'js', 'img', 'watch', 'browser-sync']);
<commit_msg>Added Linting Task<commit_after>var gulp = require('gulp'),
    jshint = require('gulp-jshint'),
    prefix = require('gulp-autoprefixer'),
    sass = require('gulp-sass'),
    concat = require('gulp-concat'),
    minifycss = require('gulp-minify-css'),
    uglify = require('gulp-uglify'),
    imagemin = require('gulp-imagemin'),
    plumber = require('gulp-plumber'),
    header = require('gulp-header'),
    gutil = require('gulp-util'),
    sourcemaps = require('gulp-sourcemaps'),
    sassLint = require('gulp-sass-lint'),
    svg2png    = require('gulp-svg2png'),
    svgSymbols = require('gulp-svg-symbols'),
    browserSync = require('browser-sync'),
    reload      = browserSync.reload,

    paths = {
        scripts: [
            'src/js/vendor/*.js',
            'src/js/*.js'
        ],
        images: [
            'img/*'
        ],
        icons: [
            'img/icons/**/*.svg'
        ],
        sass: [
            'src/scss/*.scss',
            'src/scss/helpers/*.scss',
            'src/scss/base/*.scss',
            'src/scss/important/*.scss',
            'src/scss/layout/*.scss',
            'src/scss/modules/*.scss',
            'src/scss/state/*.scss',
            'src/scss/*.scss'
        ],
    },

    theme = require('./theme.json'),
        themeBanner = [
            '/*',
            'Theme Name: <%= theme.name %>',
            'Theme URI: <%= theme.uri %>',
            'Author: <%= theme.author %>',
            'Description: <%= theme.description %>',
            'Version: <%= theme.version %>',
            'License: <%= theme.license %>',
            '*/',
            '',
            '',
        ].join('\n');

/**
 * Error handling
 */
onError = function (err) {
    gutil.beep();
    console.log(err);
};

/**
 * Sass
 */
gulp.task('sass', function(){
    return gulp.src(paths.sass)
        .pipe(sourcemaps.init())
        .pipe(plumber({ errorHandler: onError }))
        .pipe(sass.sync({errLogToConsole: true}))
        .pipe(sassLint())
        .pipe(sassLint.format())
        .pipe(sassLint.failOnError())
        .pipe(prefix({
            browsers: ['last 4 version', 'ie 8', 'ie 7'],
            cascade: true
        }))
        .pipe(minifycss({
            compatibility: 'ie8'
        }))
        .pipe(header(themeBanner, { theme : theme } ))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./'))
});

/**
 * JavaScript
 */
gulp.task('js', function () {
    return gulp.src(paths.scripts)
        .pipe(jshint())
        .pipe(plumber({ errorHandler: onError }))
        .pipe(uglify({mangle: true}))
        .pipe(concat('base.min.js'))
        .pipe(gulp.dest('js'));
});

/**
 * Image Minify
 */
gulp.task('img', function () {
    return gulp.src(paths.images)
        .pipe(imagemin({ progressive: true, }))
        .pipe(gulp.dest('img'))
});

/**
 * SVG PNG fallback task
 */
gulp.task('svg2png', function () {
    return gulp.src(paths.icons)
    .pipe(plumber({ errorHandler: onError }))
        .pipe(svg2png())
        .pipe(gulp.dest('img/icons/'))
});

/**
 * Sprites task
 */
gulp.task('sprites', ['svg2png'], function () {
    return gulp.src(paths.icons)
    .pipe(plumber({ errorHandler: onError }))
        .pipe(
            svgSymbols({
                title: false,
                templates: ['default-svg']
            })
        )
        .pipe( gulp.dest( 'img/icons/' ) )
});

/**
 * Browser Sync
 */
gulp.task('browser-sync', function() {
    browserSync.init({
        server: {
            baseDir: "./"
        }
    });
});

/**
 * Watch Files
 */
gulp.task('watch', function () {
    gulp.watch(paths.sass, ['sass']).on("change", reload);
    gulp.watch(paths.scripts, ['js']).on("change", reload);
    gulp.watch(paths.images, ['img']).on("change", reload);
    gulp.watch("*.html").on("change", reload);
});

/**
 * Default
 */
gulp.task('default', ['sass', 'js', 'img', 'watch', 'browser-sync']);
<|endoftext|>


<commit_before>"use strict";

var gulp = require("gulp");
var browserify = require("browserify");
var vinylSource = require("vinyl-source-stream");
var ts = require("gulp-typescript");
var merge = require("merge2");
var watchedFiles = ["src/**/*.ts", "spec/**/*.ts"];
var destFolder = "./dist";
var batch = require("gulp-batch");
var spawn = require("child_process").spawnSync;

/**
 * Watch files for changes
 * batch calls its callback only once, after all chaged events have fired.
 * So even if 2 or more files are changed, callback is only called once.
 */
gulp.task("watch", function () {
  var watcher = gulp.watch(watchedFiles, batch(function(events, done) {
      gulp.start("test");
      // call done to signal this task is finished
      done();
  }));

  watcher.on("change", function(event) {
    console.log("File " + event.path + " was " + event.type + ", running tasks...");
  });
});

/**
 * delete the  dist/ folder
 */
gulp.task("clean", function () {
  spawn ("rm", ["-rf", destFolder], {
    stdio: "inherit"
  });
});

/**
 * Compile the typescript project into dist/ to generate the .js and .d.ts files
 */
gulp.task("typescript", ["clean"], function() {
    var tsProject = ts.createProject("tsconfig.json", {
        declaration: true,
        typescript: require("typescript")
    });
    var tsResult = tsProject.src()
    .pipe(ts(tsProject));
    return merge([
        tsResult.dts.pipe(gulp.dest("dist")),
        tsResult.js.pipe(gulp.dest("dist"))
    ]);
});

/**
 * Generate a browserify bundle in dist/
 */
gulp.task("bundle", ["typescript"], function () {
    // run browserify passing the entry point
    var b = browserify("dist/main.js");

    // generate a named external require
    b.require("./dist/main.js", {expose: "main"});

    // and output bundle names preamble-ts.js to ./dist
    return b.bundle()
    .pipe(vinylSource("preamble-ts.js"))
    .pipe(gulp.dest("./dist/"));
});

/**
 * run the sanity test
 */
gulp.task("test", ["bundle"], function () {
  spawn ("preamble", ["-s", "./dist/test/sanitycheck.js"], {
    stdio: "inherit"
  });
});

/**
 * npm link this package
 */
gulp.task("link", function () {
  spawn ("npm", ["link"], {
    stdio: "inherit"
  });
});

/**
 * npm unlink this package
 */
gulp.task("unlink", function () {
  spawn ("npm", ["unlink"], {
    stdio: "inherit"
  });
});

/**
 * default task i.e. $ gulp
 */
gulp.task("default", ["watch"]);
<commit_msg>Sanity cYadaheck report now named "SanityYada Check Suite".<commit_after>"use strict";

var gulp = require("gulp");
var browserify = require("browserify");
var vinylSource = require("vinyl-source-stream");
var ts = require("gulp-typescript");
var merge = require("merge2");
var watchedFiles = ["src/**/*.ts", "spec/**/*.ts"];
var destFolder = "./dist";
var batch = require("gulp-batch");
var spawn = require("child_process").spawnSync;

/**
 * Watch files for changes
 * batch calls its callback only once, after all chaged events have fired.
 * So even if 2 or more files are changed, callback is only called once.
 */
gulp.task("watch", function () {
  var watcher = gulp.watch(watchedFiles, batch(function(events, done) {
      gulp.start("test");
      // call done to signal this task is finished
      done();
  }));

  watcher.on("change", function(event) {
    console.log("File " + event.path + " was " + event.type + ", running tasks...");
  });
});

/**
 * delete the  dist/ folder
 */
gulp.task("clean", function () {
  spawn ("rm", ["-rf", destFolder], {
    stdio: "inherit"
  });
});

/**
 * Compile the typescript project into dist/ to generate the .js and .d.ts files
 */
gulp.task("typescript", ["clean"], function() {
    var tsProject = ts.createProject("tsconfig.json", {
        declaration: true,
        typescript: require("typescript")
    });
    var tsResult = tsProject.src()
    .pipe(ts(tsProject));
    return merge([
        tsResult.dts.pipe(gulp.dest("dist")),
        tsResult.js.pipe(gulp.dest("dist"))
    ]);
});

/**
 * Generate a browserify bundle in dist/
 */
gulp.task("bundle", ["typescript"], function () {
    // run browserify passing the entry point
    var b = browserify("dist/main.js");

    // generate a named external require
    b.require("./dist/main.js", {expose: "main"});

    // and output bundle names preamble-ts.js to ./dist
    return b.bundle()
    .pipe(vinylSource("preamble-ts.js"))
    .pipe(gulp.dest("./dist/"));
});

/**
 * run the sanity test
 */
gulp.task("test", ["bundle"], function () {
  spawn ("preamble", ["-s", "./dist/test/sanitycheck.js", "-n", "Sanity Check Suite"], {
    stdio: "inherit"
  });
});

/**
 * npm link this package
 */
gulp.task("link", function () {
  spawn ("npm", ["link"], {
    stdio: "inherit"
  });
});

/**
 * npm unlink this package
 */
gulp.task("unlink", function () {
  spawn ("npm", ["unlink"], {
    stdio: "inherit"
  });
});

/**
 * default task i.e. $ gulp
 */
gulp.task("default", ["watch"]);
<|endoftext|>


<commit_before>'use strict';

//-------------------------------------------------------------------
// VARS
//-------------------------------------------------------------------

// plugins
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var pagespeed = require('psi');

//-------------------------------------------------------------------
// SETUP
//-------------------------------------------------------------------

// environments
var app = 'app';
var dev = '.tmp';
var prod = 'dist';

//folders
var styles = 'assets/styles';
var scripts = 'assets/scripts';
var images = 'assets/images';
var fonts = 'assets/fonts';
var template = 'template';

var AUTOPREFIXER_BROWSERS = [
  'ie >= 9',
  'ie_mob >= 10',
  'ff >= 30',
  'chrome >= 34',
  'safari >= 7',
  'opera >= 23',
  'ios >= 7',
  'android >= 4.4',
  'bb >= 10'
];

//-------------------------------------------------------------------
// TASKS
//-------------------------------------------------------------------

gulp.task('styles',function() {
	return gulp.src( app + '/' + styles + '/**/*.scss')
		.pipe(plugins.plumber())

        //if you want genarate only the changed file
		//.pipe(plugins.changed(app + '/' + styles, {extension: '.scss'}))

		.pipe(plugins.rubySass({
			style: 'expanded',
			precision: 10,
			loadPath: [app]
		}))
		.pipe(plugins.autoprefixer(AUTOPREFIXER_BROWSERS))
		.pipe(gulp.dest( dev + '/' + styles))
        .pipe(plugins.size({title: 'styles'}));
});

gulp.task('scripts', function() {
	return gulp.src(app + '/' + scripts + '/**/*.js')
		.pipe(plugins.plumber())
	    .pipe(plugins.jshint())
	    .pipe(plugins.jshint.reporter('jshint-stylish'))
	    .pipe(plugins.if(!browserSync.active, plugins.jshint.reporter('fail')));
});

gulp.task('templates', function() {
	var YOUR_LOCALS = {};
	return gulp.src([ app+ '/' + template + '/**/*.jade', '!' +app + '/' + template + '/**/_*.jade'])
		.pipe(plugins.plumber())
		.pipe(plugins.jade({
			locals: YOUR_LOCALS,
			pretty: true,
			basedir: app+ '/' + template
		}))
		.pipe(gulp.dest(dev + '/'))
		.pipe(plugins.size({title: 'template'}));
});

gulp.task('images', function() {
	return gulp.src(app + '/' + images + '/**/*')
		.pipe(plugins.plumber())
		.pipe(plugins.cache(plugins.imagemin({
			optimizationLevel: 3,
			progressive: true,
			interlaced: true
		})))
		.pipe(gulp.dest(prod + '/' + images))
		.pipe(plugins.size());
});

gulp.task('html',function() {
	var assets = plugins.useref.assets({searchPath: '{' + dev + ',' + app + '}' });
	return gulp.src([dev + '/**/*.html'])
		.pipe(plugins.plumber())
		.pipe(assets)
		.pipe(plugins.if('*.js', plugins.uglify()))
		.pipe(plugins.if('*.css', plugins.csso()))
		.pipe(assets.restore())
    	.pipe(plugins.useref())
        .pipe(plugins.if('*.html', plugins.minifyHtml()))
		.pipe(gulp.dest(prod + '/'))
		.pipe(plugins.size({title: 'html'}));
});

//-------------------------------------------------------------------
// WATCH
//-------------------------------------------------------------------

gulp.task('clean:dev', del.bind(null, [dev]));
gulp.task('serve:dev', function () {

	browserSync({
		logFileChanges:true,
        notify: true,
        // Customize the BrowserSync console logging prefix
        logPrefix: 'Frontendler',
		server: {
			baseDir: [dev,app]
		}
	});

	gulp.watch( [app + '/' + template + '/**/*.jade'], ['templates',reload]);
	gulp.watch( [app + '/' + scripts + '/**/*.js'], ['scripts',reload]);
    gulp.watch( [app + '/' + styles + '/**/*.scss'], ['styles',reload]);
    gulp.watch( [app + '/' + fonts + '**/*'], ['fonts',reload]);
	gulp.watch( [app + '/' + images + '/**/*'], [reload]);

});

gulp.task('watch',['clean:dev'],function(cb) {
	runSequence(['styles','templates'],'serve:dev',cb);
});

//-------------------------------------------------------------------
// BUILD
//-------------------------------------------------------------------

gulp.task('clean:prod', del.bind(null, [prod]));
gulp.task('copy:prod', function() {
    gulp.src([app + '/' + fonts + '/**/*.{eot,svg,ttf,woff}'])
        .pipe(gulp.dest(prod + '/' + fonts));
    gulp.src([app + '/*.*','node_modules/apache-server-configs/dist/.htaccess'],{ dot: true })
        .pipe(gulp.dest(prod));
});

gulp.task('build',['clean:prod'],function(cb){
	runSequence(['styles','scripts','templates','images','copy:prod'],'html', cb);
});

// Run PageSpeed Insights
// Update `url` below to the public URL for your site
gulp.task('pagespeed', pagespeed.bind(null, {
  // By default, we use the PageSpeed Insights
  // free (no API key) tier. You can use a Google
  // Developer API key if you have one. See
  // http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
  url: 'http://www.frontendler.com.br',
  strategy: 'mobile'
}));
<commit_msg>adjust gulp watch image task<commit_after>'use strict';

//-------------------------------------------------------------------
// VARS
//-------------------------------------------------------------------

// plugins
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var pagespeed = require('psi');

//-------------------------------------------------------------------
// SETUP
//-------------------------------------------------------------------

// environments
var app = 'app';
var dev = '.tmp';
var prod = 'dist';

//folders
var styles = 'assets/styles';
var scripts = 'assets/scripts';
var images = 'assets/images';
var fonts = 'assets/fonts';
var template = 'template';

var AUTOPREFIXER_BROWSERS = [
  'ie >= 9',
  'ie_mob >= 10',
  'ff >= 30',
  'chrome >= 34',
  'safari >= 7',
  'opera >= 23',
  'ios >= 7',
  'android >= 4.4',
  'bb >= 10'
];

//-------------------------------------------------------------------
// TASKS
//-------------------------------------------------------------------

gulp.task('styles',function() {
	return gulp.src( app + '/' + styles + '/**/*.scss')
		.pipe(plugins.plumber())

        //if you want genarate only the changed file
		//.pipe(plugins.changed(app + '/' + styles, {extension: '.scss'}))

		.pipe(plugins.rubySass({
			style: 'expanded',
			precision: 10,
			loadPath: [app]
		}))
		.pipe(plugins.autoprefixer(AUTOPREFIXER_BROWSERS))
		.pipe(gulp.dest( dev + '/' + styles))
        .pipe(plugins.size({title: 'styles'}));
});

gulp.task('scripts', function() {
	return gulp.src(app + '/' + scripts + '/**/*.js')
		.pipe(plugins.plumber())
	    .pipe(plugins.jshint())
	    .pipe(plugins.jshint.reporter('jshint-stylish'))
	    .pipe(plugins.if(!browserSync.active, plugins.jshint.reporter('fail')));
});

gulp.task('templates', function() {
	var YOUR_LOCALS = {};
	return gulp.src([ app+ '/' + template + '/**/*.jade', '!' +app + '/' + template + '/**/_*.jade'])
		.pipe(plugins.plumber())
		.pipe(plugins.jade({
			locals: YOUR_LOCALS,
			pretty: true,
			basedir: app+ '/' + template
		}))
		.pipe(gulp.dest(dev + '/'))
		.pipe(plugins.size({title: 'template'}));
});

gulp.task('images', function() {
	return gulp.src(app + '/' + images + '/**/*')
		.pipe(plugins.plumber())
		.pipe(plugins.cache(plugins.imagemin({
			optimizationLevel: 3,
			progressive: true,
			interlaced: true
		})))
		.pipe(gulp.dest(prod + '/' + images))
		.pipe(plugins.size());
});

gulp.task('html',function() {
	var assets = plugins.useref.assets({searchPath: '{' + dev + ',' + app + '}' });
	return gulp.src([dev + '/**/*.html'])
		.pipe(plugins.plumber())
		.pipe(assets)
		.pipe(plugins.if('*.js', plugins.uglify()))
		.pipe(plugins.if('*.css', plugins.csso()))
		.pipe(assets.restore())
    	.pipe(plugins.useref())
        .pipe(plugins.if('*.html', plugins.minifyHtml()))
		.pipe(gulp.dest(prod + '/'))
		.pipe(plugins.size({title: 'html'}));
});

//-------------------------------------------------------------------
// WATCH
//-------------------------------------------------------------------

gulp.task('clean:dev', del.bind(null, [dev]));
gulp.task('serve:dev', function () {

	browserSync({
		logFileChanges:true,
        notify: true,
        // Customize the BrowserSync console logging prefix
        logPrefix: 'Frontendler',
		server: {
			baseDir: [dev,app]
		}
	});

	gulp.watch( [app + '/' + template + '/**/*.jade'], ['templates',reload]);
	gulp.watch( [app + '/' + scripts + '/**/*.js'], ['scripts',reload]);
    gulp.watch( [app + '/' + styles + '/**/*.scss'], ['styles',reload]);
    gulp.watch( [app + '/' + fonts + '**/*'], ['fonts',reload]);
	gulp.watch( [app + '/' + images + '/**/*'], reload);

});

gulp.task('watch',['clean:dev'],function(cb) {
	runSequence(['styles','templates'],'serve:dev',cb);
});

//-------------------------------------------------------------------
// BUILD
//-------------------------------------------------------------------

gulp.task('clean:prod', del.bind(null, [prod]));
gulp.task('copy:prod', function() {
    gulp.src([app + '/' + fonts + '/**/*.{eot,svg,ttf,woff}'])
        .pipe(gulp.dest(prod + '/' + fonts));
    gulp.src([app + '/*.*','node_modules/apache-server-configs/dist/.htaccess'],{ dot: true })
        .pipe(gulp.dest(prod));
});

gulp.task('build',['clean:prod'],function(cb){
	runSequence(['styles','scripts','templates','images','copy:prod'],'html', cb);
});

// Run PageSpeed Insights
// Update `url` below to the public URL for your site
gulp.task('pagespeed', pagespeed.bind(null, {
  // By default, we use the PageSpeed Insights
  // free (no API key) tier. You can use a Google
  // Developer API key if you have one. See
  // http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
  url: 'http://www.frontendler.com.br',
  strategy: 'mobile'
}));
<|endoftext|>