<commit_before>/**
 *
 *  Web Starter Kit
 *  Copyright 2014 Google Inc. All rights reserved.
 *
 */

'use strict';

//TODO: Optimize tasks

// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var pagespeed = require('psi');
var reload = browserSync.reload;
var debug = require('gulp-debug');
var inject = require('gulp-inject');
var ngannotate = require('gulp-ng-annotate')
var concat = require('gulp-concat');
var deploy = require('gulp-gh-pages');
var AUTOPREFIXER_BROWSERS = [
    'ie >= 10',
    'ie_mob >= 10',
    'ff >= 30',
    'chrome >= 34',
    'safari >= 7',
    'opera >= 23',
    'ios >= 7',
    'android >= 4.4',
    'bb >= 10'
];

/**
 * Push build to gh-pages
 */
gulp.task('pages', function () {
  return gulp.src("pages/**/*")
    .pipe(deploy())
});

// This will run in this order:
// * build-clean
// * build-scripts and build-styles in parallel
// * build-html
// * Finally call the callback function
gulp.task('deploy-pages', function(callback) {
  runSequence('clean',
              ['build-scripts', 'build-styles'],
              'inject', 'concat', 'fontsTemp', 'styles','pages',
              callback);
});

gulp.task('deploy-pages', function(done) {
    runSequence('default', 'pages', function() {
        done();
    });
});

// Build Production Files, the Default Task
gulp.task('deploy-src', ['clean'], function(cb) {
    runSequence(['concatSrc','stylesSrc', 'fontsSrc'], cb);
});

// Lint JavaScript
gulp.task('jshint', function() {
    return gulp.src(['app/main/**/*.js', '!app/main/bower_components/**'])
        .pipe(reload({
            stream: true,
            once: true
        }))
        .pipe($.jshint())
        .pipe($.jshint.reporter('jshint-stylish'))
        .pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
});

// Optimize Images
gulp.task('images', function() {
    return gulp.src('app/images/**/*')
        .pipe($.cache($.imagemin({
            progressive: true,
            interlaced: true
        })))
        .pipe(gulp.dest('pages/images'))
        .pipe($.size({
            title: 'images'
        }));
});

// Copy All Files At The Root Level (app)
gulp.task('copy', function() {
    return gulp.src([
            'app/*',
            '!app/*.html',
            'node_modules/apache-server-configs/pages/.htaccess'
        ], {
            dot: true
        }).pipe(gulp.dest('pages'))
        .pipe($.size({
            title: 'copy'
        }));
});

// Copy Web Fonts To dev
gulp.task('fontsTemp', function() {
    return gulp.src(['app/fonts/**'])
        .pipe(gulp.dest('dev/fonts'))
        .pipe($.size({
            title: 'fonts'
        }));
});

// Copy Web Fonts To src
gulp.task('fontsSrc', function() {
    return gulp.src(['app/fonts/**'])
        .pipe(gulp.dest('src/fonts'))
        .pipe($.size({
            title: 'fonts'
        }));
});

// Copy Web Fonts To pages
gulp.task('fonts', function() {
    return gulp.src(['app/fonts/**'])
        .pipe(gulp.dest('pages/fonts'))
        .pipe($.size({
            title: 'fonts'
        }));
});

gulp.task('concat', function() {
    var scssStream = gulp.src(['app/patternStyles/main.scss','app/main/styles/docs.scss'])
        .pipe(concat('zyncro-styleguide.scss'))
        .pipe(gulp.dest('app/patternStyles'));
    return scssStream;
});

gulp.task('concatSrc', function(concatSrc) {
    var scssStream = gulp.src(['app/patternStyles/main.scss'])
        .pipe(concat('zyncro-styleguide.scss'))
        .pipe(gulp.dest('app/patternStyles'));
    return scssStream;
});

// Compile and Automatically Prefix Stylesheets
gulp.task('styles', function() {
    // For best performance, don't add Sass partials to `gulp.src`
    return gulp.src([
            'app/patternStyles/zyncro-styleguide.scss'
        ])
        .pipe(debug())
        .pipe($.changed('styles', {
            extension: '.scss'
        }))
        .pipe($.rubySass({
                style: 'expanded',
                precision: 10
            })
            .on('error', console.error.bind(console))
        )
        .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
        .pipe(gulp.dest('dev/styles'))
        // Concatenate And Minify Styles
        .pipe($.if('*.css', $.csso()))
        .pipe(gulp.dest('pages/styles'))
        .pipe($.size({
            title: 'styles'
        }));
});

// Compile and Automatically Prefix Stylesheets
gulp.task('stylesSrc', function() {

    // For best performance, don't add Sass partials to `gulp.src`
    return gulp.src([
            'app/patternStyles/zyncro-styleguide.scss'
        ])
        .pipe(debug())
        .pipe($.changed('styles', {
            extension: '.scss'
        }))
        .pipe($.rubySass({
                style: 'expanded',
                precision: 10
            })
            .on('error', console.error.bind(console))
        )
        .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
        .pipe(gulp.dest('dev/styles'))
        // Concatenate And Minify Styles
        .pipe($.if('*.css', $.csso()))
        .pipe(gulp.dest('src/styles'))
        .pipe($.size({
            title: 'styles'
        }));
});

// Scan Your HTML For Assets & Optimize Them
gulp.task('html', function() {
    var assets = $.useref.assets({
        searchPath: '{dev,app}'
    });

    return gulp.src('app/**/*.html')
        .pipe(assets)
        // Concatenate And Minify JavaScript
        .pipe($.if('*.js', $.uglify(
        {
            preserveComments: 'some',
            mangle: false,
            compress: true
        }
        )))

        // Remove Any Unused CSS
        // Note: If not using the Style Guide, you can delete it from
        // the next line to only include styles your project uses.
        .pipe($.if('*.css', $.uncss({
            html: [
                'app/index.html',
                'app/styleguide.html'
            ],
            // CSS Selectors for UnCSS to ignore
            ignore: [
                /.navdrawer-container.open/,
                /.app-bar.open/
            ]
        })))
        // Concatenate And Minify Styles
        // In case you are still using useref build blocks
        .pipe($.if('*.css', $.csso()))
        .pipe(assets.restore())
        .pipe($.useref())
        // // Update Production Style Guide Paths
        // .pipe($.replace('components/components.css', 'components/main.min.css'))
        // Minify Any HTML
        .pipe($.if('*.html', $.minifyHtml()))
        // Output Files
        .pipe(gulp.dest('pages'))
        .pipe($.size({
            title: 'html'
        }));
});

gulp.task('inject', function() {
    gulp.src('app/main/styleguide/styleguide.html')
        .pipe(debug())
        .pipe(inject(gulp.src(['app/patternTemplates/{,*/}*.html']), {
            starttag: '<!-- inject:head:{{ext}} -->',
            transform: function(filePath, file) {
                // return file contents as string
                return file.contents.toString('utf8');
            }
        }))
        .pipe(gulp.dest('app/main/styleguide/'));

});

// Clean Output Directory
gulp.task('clean', del.bind(null, ['dev', 'pages', 'src', '.publish']));

// hjs to pages
gulp.task('hjs2pages', function() {
    return gulp.src(['app/main/bower_components/highlightjs/styles/paraiso.dark.css'])
        .pipe(gulp.dest('pages/main/bower_components/highlightjs/styles/'))
});

// Watch Files For Changes & Reload
gulp.task('serve', ['inject', 'concat', 'fontsTemp', 'styles'], function() {
    browserSync({
        notify: false,
        // Run as an https by uncommenting 'https: true'
        // Note: this uses an unsigned certificate which on first access
        //       will present a certificate warning in the browser.
        // https: true,
        server: ['dev', 'app']
    });

    gulp.watch(['app/**/*.html'], reload);
    gulp.watch(['app/**/**/*.html'], reload);
    //Include patterns in styleguide
    gulp.watch('app/patternTemplates/**/*.html').on('change', function() {
        gulp.src('app/main/styleguide/styleguide.html')
            .pipe(debug())
            .pipe(inject(gulp.src(['app/patternTemplates/{,*/}*.html']), {
                starttag: '<!-- inject:head:{{ext}} -->',
                transform: function(filePath, file) {
                    // return file contents as string
                    return file.contents.toString('utf8');
                }
            }))
            .pipe(gulp.dest('app/main/styleguide/'));
    });
    gulp.watch(['app/patternStyles/**/*.{scss,css}','app/main/styles/docs.scss'], ['concat', 'styles', reload]);
    gulp.watch(['app/main/**/*.js'], ['jshint']);
    gulp.watch(['app/images/**/*'], reload);
});

// Build Production Files, the Default Task
gulp.task('default', ['clean'], function(cb) {
    runSequence('styles', ['jshint','inject', 'concat', 'hjs2pages', 'html', 'images', 'fonts', 'copy' ], 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: 'https://example.com',
    strategy: 'mobile'
}));

// Load custom tasks from the `tasks` directory
try {
    require('require-dir')('tasks');
} catch (err) {}
<commit_msg>message<commit_after>/**
 *
 *  Web Starter Kit
 *  Copyright 2014 Google Inc. All rights reserved.
 *
 */

'use strict';

//TODO: Optimize tasks

// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var pagespeed = require('psi');
var reload = browserSync.reload;
var debug = require('gulp-debug');
var inject = require('gulp-inject');
var ngannotate = require('gulp-ng-annotate')
var concat = require('gulp-concat');
var deploy = require('gulp-gh-pages');
var AUTOPREFIXER_BROWSERS = [
    'ie >= 10',
    'ie_mob >= 10',
    'ff >= 30',
    'chrome >= 34',
    'safari >= 7',
    'opera >= 23',
    'ios >= 7',
    'android >= 4.4',
    'bb >= 10'
];

// Lint JavaScript
gulp.task('jshint', function() {
    return gulp.src(['app/main/**/*.js', '!app/main/bower_components/**'])
        .pipe(reload({
            stream: true,
            once: true
        }))
        .pipe($.jshint())
        .pipe($.jshint.reporter('jshint-stylish'))
        .pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
});

// Optimize Images
gulp.task('images', function() {
    return gulp.src('app/images/**/*')
        .pipe($.cache($.imagemin({
            progressive: true,
            interlaced: true
        })))
        .pipe(gulp.dest('pages/images'))
        .pipe($.size({
            title: 'images'
        }));
});

// Copy All Files At The Root Level (app)
gulp.task('copy', function() {
    return gulp.src([
            'app/*',
            '!app/*.html',
            'node_modules/apache-server-configs/pages/.htaccess'
        ], {
            dot: true
        }).pipe(gulp.dest('pages'))
        .pipe($.size({
            title: 'copy'
        }));
});

// Copy Web Fonts To dev
gulp.task('fontsTemp', function() {
    return gulp.src(['app/fonts/**'])
        .pipe(gulp.dest('dev/fonts'))
        .pipe($.size({
            title: 'fonts'
        }));
});

// Copy Web Fonts To src
gulp.task('fontsSrc', function() {
    return gulp.src(['app/fonts/**'])
        .pipe(gulp.dest('src/fonts'))
        .pipe($.size({
            title: 'fonts'
        }));
});

// Copy Web Fonts To pages
gulp.task('fonts', function() {
    return gulp.src(['app/fonts/**'])
        .pipe(gulp.dest('pages/fonts'))
        .pipe($.size({
            title: 'fonts'
        }));
});

gulp.task('concat', function() {
    var scssStream = gulp.src(['app/patternStyles/main.scss','app/main/styles/docs.scss'])
        .pipe(concat('zyncro-styleguide.scss'))
        .pipe(gulp.dest('app/patternStyles'));
    return scssStream;
});

gulp.task('concatSrc', function(concatSrc) {
    var scssStream = gulp.src(['app/patternStyles/main.scss'])
        .pipe(concat('zyncro-styleguide.scss'))
        .pipe(gulp.dest('app/patternStyles'));
    return scssStream;
});

// Compile and Automatically Prefix Stylesheets
gulp.task('styles', function() {
    // For best performance, don't add Sass partials to `gulp.src`
    return gulp.src([
            'app/patternStyles/zyncro-styleguide.scss'
        ])
        .pipe(debug())
        .pipe($.changed('styles', {
            extension: '.scss'
        }))
        .pipe($.rubySass({
                style: 'expanded',
                precision: 10
            })
            .on('error', console.error.bind(console))
        )
        .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
        .pipe(gulp.dest('dev/styles'))
        // Concatenate And Minify Styles
        .pipe($.if('*.css', $.csso()))
        .pipe(gulp.dest('pages/styles'))
        .pipe($.size({
            title: 'styles'
        }));
});

// Compile and Automatically Prefix Stylesheets
gulp.task('stylesSrc', function() {

    // For best performance, don't add Sass partials to `gulp.src`
    return gulp.src([
            'app/patternStyles/zyncro-styleguide.scss'
        ])
        .pipe(debug())
        .pipe($.changed('styles', {
            extension: '.scss'
        }))
        .pipe($.rubySass({
                style: 'expanded',
                precision: 10
            })
            .on('error', console.error.bind(console))
        )
        .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
        .pipe(gulp.dest('dev/styles'))
        // Concatenate And Minify Styles
        .pipe($.if('*.css', $.csso()))
        .pipe(gulp.dest('src/styles'))
        .pipe($.size({
            title: 'styles'
        }));
});

// Scan Your HTML For Assets & Optimize Them
gulp.task('html', function() {
    var assets = $.useref.assets({
        searchPath: '{dev,app}'
    });

    return gulp.src('app/**/*.html')
        .pipe(assets)
        // Concatenate And Minify JavaScript
        .pipe($.if('*.js', $.uglify(
        {
            preserveComments: 'some',
            mangle: false,
            compress: true
        }
        )))

        // Remove Any Unused CSS
        // Note: If not using the Style Guide, you can delete it from
        // the next line to only include styles your project uses.
        .pipe($.if('*.css', $.uncss({
            html: [
                'app/index.html',
                'app/styleguide.html'
            ],
            // CSS Selectors for UnCSS to ignore
            ignore: [
                /.navdrawer-container.open/,
                /.app-bar.open/
            ]
        })))
        // Concatenate And Minify Styles
        // In case you are still using useref build blocks
        .pipe($.if('*.css', $.csso()))
        .pipe(assets.restore())
        .pipe($.useref())
        // // Update Production Style Guide Paths
        // .pipe($.replace('components/components.css', 'components/main.min.css'))
        // Minify Any HTML
        .pipe($.if('*.html', $.minifyHtml()))
        // Output Files
        .pipe(gulp.dest('pages'))
        .pipe($.size({
            title: 'html'
        }));
});

gulp.task('inject', function() {
    gulp.src('app/main/styleguide/styleguide.html')
        .pipe(debug())
        .pipe(inject(gulp.src(['app/patternTemplates/{,*/}*.html']), {
            starttag: '<!-- inject:head:{{ext}} -->',
            transform: function(filePath, file) {
                // return file contents as string
                return file.contents.toString('utf8');
            }
        }))
        .pipe(gulp.dest('app/main/styleguide/'));

});

// Clean Output Directory
gulp.task('clean', del.bind(null, ['dev', 'pages', 'src', '.publish']));

// hjs to pages
gulp.task('hjs2pages', function() {
    return gulp.src(['app/main/bower_components/highlightjs/styles/paraiso.dark.css'])
        .pipe(gulp.dest('pages/main/bower_components/highlightjs/styles/'))
});

// Watch Files For Changes & Reload
gulp.task('serve', ['inject', 'concat', 'fontsTemp', 'styles'], function() {
    browserSync({
        notify: false,
        // Run as an https by uncommenting 'https: true'
        // Note: this uses an unsigned certificate which on first access
        //       will present a certificate warning in the browser.
        // https: true,
        server: ['dev', 'app']
    });

    gulp.watch(['app/**/*.html'], reload);
    gulp.watch(['app/**/**/*.html'], reload);
    //Include patterns in styleguide
    gulp.watch('app/patternTemplates/**/*.html').on('change', function() {
        gulp.src('app/main/styleguide/styleguide.html')
            .pipe(debug())
            .pipe(inject(gulp.src(['app/patternTemplates/{,*/}*.html']), {
                starttag: '<!-- inject:head:{{ext}} -->',
                transform: function(filePath, file) {
                    // return file contents as string
                    return file.contents.toString('utf8');
                }
            }))
            .pipe(gulp.dest('app/main/styleguide/'));
    });
    gulp.watch(['app/patternStyles/**/*.{scss,css}','app/main/styles/docs.scss'], ['concat', 'styles', reload]);
    gulp.watch(['app/main/**/*.js'], ['jshint']);
    gulp.watch(['app/images/**/*'], reload);
});

// Build Production Files, the Default Task
gulp.task('default', ['clean'], function(cb) {
    runSequence('styles', ['jshint','inject', 'concat', 'hjs2pages', 'html', 'images', 'fonts', 'copy' ], cb);
});

/**
 * Push build to gh-pages
 */
gulp.task('pages', function () {
  return gulp.src("pages/**/*")
    .pipe(deploy())
});

gulp.task('deploy-pages', function(cb) {
  runSequence('clean',
            'styles',
            'hjs2pages',
            'html',
            'images',
            'copy',
            'inject',
            'concat',
            'fontsTemp',
            'pages',
              cb);
});

// Build Production Files, the Default Task
gulp.task('deploy-src', ['clean'], function(cb) {
    runSequence(['concatSrc','stylesSrc', 'fontsSrc'], 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: 'https://example.com',
    strategy: 'mobile'
}));

// Load custom tasks from the `tasks` directory
try {
    require('require-dir')('tasks');
} catch (err) {}
<|endoftext|>


<commit_before>'use strict';

const gulp = require('gulp');
const del = require('del');
const browserSync = require('browser-sync');
const frontMatter = require('front-matter');
const reload = browserSync.reload;
const plugins = require('gulp-load-plugins')();
const _ = require('lodash');
const $ = require('gulp-load-plugins')({ pattern: ['gulp-*'] });
const getBundleName = function () {
  let version = require('./package.json').version;
  let name = require('./package.json').name;
  return version + '.' + name + '.' + 'min';
};
let pagesAttributes = {
  posts: []
}

gulp.task('browser-sync',  ['build'],  function() {
  browserSync({
    server: {
      baseDir: './',
      directory: false
    },
    files:['**/*.html','**/*.css'],
    open: false,
    notify: false
  });
});

function handleError(err) {
  console.error(err.toString());
  this.emit('end');
}

gulp.task('clean', function(cb) {
  del(['css','posts','js'], cb);
});

gulp.task('css', function () {
    return gulp.src('src/css/*.less')
        .pipe($.less())
        .on('error', handleError)
        .pipe($.autoprefixer({
            browsers: ['last 2 versions']
        }))
        .pipe($.csso())
        .pipe(gulp.dest('css'))
        .pipe(reload({stream:true}));
});

gulp.task('posts', function(){
    return gulp.src(['./src/posts/**/_*.jade'])
    .pipe($.data(function(file) {
      let content = frontMatter(String(file.contents));
      file.contents = new Buffer(content.body);
      content.attributes.path = file.relative.split('.jade').join('.html');
      pagesAttributes.posts.push(content.attributes);
      return content.attributes;
    }))
    .pipe($.jade())
    .pipe(gulp.dest('./posts'));
})

gulp.task('jade',['posts'], function () {
  pagesAttributes.posts = _.uniq(pagesAttributes.posts, function(post){
    return post.path;
  });

  return gulp.src(['./src/**/*.jade','!./src/layouts/**/*.jade','!./src/posts/**/_*.jade'])
    .pipe($.data(function(file) {
      let content = frontMatter(String(file.contents));
      file.contents = new Buffer(content.body);
      let attributes = _.assign({}, content.attributes, pagesAttributes);
      return attributes;
    }))
    .pipe($.jade({pretty:true}))
    .pipe(gulp.dest('./'))
    .pipe(reload({stream:true}));
});

gulp.task('build', ['css','jade']);

gulp.task('default', ['clean'], function () {
    gulp.start(['build', 'browser-sync']);
    gulp.watch('**/*.less', ['css']);
    gulp.watch('**/*.jade', ['jade']);
});<commit_msg>WIP need to sort archives by date descending<commit_after>'use strict';

const gulp = require('gulp');
const del = require('del');
const browserSync = require('browser-sync');
const frontMatter = require('front-matter');
const reload = browserSync.reload;
const plugins = require('gulp-load-plugins')();
const _ = require('lodash');
const $ = require('gulp-load-plugins')({ pattern: ['gulp-*'] });
const getBundleName = function () {
  let version = require('./package.json').version;
  let name = require('./package.json').name;
  return version + '.' + name + '.' + 'min';
};
let pagesAttributes = {
  posts: []
}

gulp.task('browser-sync',  ['build'],  function() {
  browserSync({
    server: {
      baseDir: './',
      directory: false
    },
    open: false,
    notify: false
  });
});

function handleError(err) {
  console.error(err.toString());
  this.emit('end');
}

gulp.task('clean', function(cb) {
  del(['css','posts','js'], cb);
});

gulp.task('css', function () {
    return gulp.src('src/css/*.less')
        .pipe($.less())
        .on('error', handleError)
        .pipe($.autoprefixer({
            browsers: ['last 2 versions']
        }))
        .pipe($.csso())
        .pipe(gulp.dest('css'))
        .pipe(reload({stream:true}));
});

gulp.task('posts', function(done){
    let stream = gulp.src(['./src/posts/**/_*.jade'])
    .pipe($.data(function(file) {
      let content = frontMatter(String(file.contents));
      file.contents = new Buffer(content.body);
      content.attributes.path = file.relative.split('.jade').join('.html');
      pagesAttributes.posts.push(content.attributes);
      return content.attributes;
    }))
    .pipe($.jade())
    .pipe(gulp.dest('./posts'));

    stream.on('end', function(){
        // pagesAttributes.posts = _.uniq(pagesAttributes.posts, function(post){
        //   return post.path;
        // });
      console.log(`start: ${JSON.stringify(pagesAttributes.posts)}`);
      pagesAttributes.posts = _.chain(pagesAttributes.posts)
      .uniq(function(post){
        return post.path;
      })
      .sortBy('date');
      console.log(`end: ${JSON.stringify(pagesAttributes.posts)}`);

      done();
    });

    stream.on('error', function(err){
      done(err);
    });
})

gulp.task('jade',['posts'], function () {
  return gulp.src(['./src/**/*.jade','!./src/layouts/**/*.jade','!./src/posts/**/_*.jade'])
    .pipe($.data(function(file) {
      let content = frontMatter(String(file.contents));
      file.contents = new Buffer(content.body);
      let attributes = _.assign({}, content.attributes, pagesAttributes);
      return attributes;
    }))
    .pipe($.jade({pretty:true}))
    .pipe(gulp.dest('./'))
    .pipe(reload({stream:true}));
});

gulp.task('build', ['css','jade']);

gulp.task('default', ['clean'], function () {
    gulp.start(['build', 'browser-sync']);
    gulp.watch('**/*.less', ['css']);
    gulp.watch('**/*.jade', ['jade']);
});<|endoftext|>


<commit_before>var gulp = require('gulp');
var del = require('del');
var source = require('vinyl-source-stream');
var vinylPaths = require('vinyl-paths');
var browserify = require('browserify');
var babelify = require('babelify');
var errorify = require('errorify');
var watchify = require('watchify');
var fs = require('fs');

var util = require('gulp-util');
var open = require('gulp-open');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var minifyCss = require('gulp-minify-css');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var jade = require('gulp-jade');
var sourcemaps = require('gulp-sourcemaps');
var connect = require('gulp-connect');
var gulpif = require('gulp-if');
var ghPages = require('gulp-gh-pages');
var bump = require('gulp-bump');
var tagVersion = require('gulp-tag-version');
var filter = require('gulp-filter');
var ngAnnotate = require('gulp-ng-annotate');
var uncss = require('gulp-uncss');
var eslint = require('gulp-eslint');
var autoprefixer = require('gulp-autoprefixer');
var changed = require('gulp-changed');

var watching = false;

var getPaths = function() {
  return JSON.parse(fs.readFileSync('./package.json')).gulp;
};

gulp.task('deploy', function() {
  var paths = getPaths();

  return gulp.src(paths.dist + '**/*')
    .pipe(ghPages());
});

gulp.task('clean', function() {
  var paths = getPaths();

  return gulp.src(paths.dist)
    .pipe(vinylPaths(del))
    .on('error', util.log);
});

gulp.task('copyfavicon', ['clean'], function() {
  var paths = getPaths();

  return gulp.src(paths.favicon)
    .pipe(gulp.dest(paths.dist))
    .on('error', util.log);
});

gulp.task('buildlibcss', ['clean', 'compilejade', 'compilesass'], function() {
  var paths = getPaths();

  return gulp.src(paths.libcss)
    .pipe(changed(paths.dist))
    .pipe(concat('lib.min.css'))
    .pipe(uncss({
      html: paths.dist + 'index.html'
    }))
    .pipe(minifyCss({
      keepSpecialComments: false,
      removeEmpty: true
    }))
    .pipe(gulp.dest(paths.dist + 'css'))
    .on('error', util.log);
});

gulp.task('buildlibjs', ['clean'], function() {
  var paths = getPaths();

  return gulp.src(paths.libjs)
    .pipe(changed(paths.dist))
    .pipe(gulpif(!watching, uglify({ outSourceMaps: false })))
    .pipe(concat('lib.min.js'))
    .pipe(gulp.dest(paths.dist + 'js'))
    .on('error', util.log);
});

gulp.task('compilejs', ['eslint', 'clean'], function() {
  var paths = getPaths();

  var bundler = browserify({
    cache: {}, packageCache: {}, fullPaths: true,
    entries: [paths.entry],
    debug: watching
  })
    .transform(babelify);

  if(watching) {
    bundler.plugin(errorify);
  }

  var bundlee = function() {
    return bundler
      .bundle()
      .pipe(source('js/main.min.js'))
      .pipe(gulpif(!watching, streamify(uglify({ outSourceMaps: false }))))
      .pipe(ngAnnotate())
      .pipe(gulp.dest(paths.dist))
      .on('error', util.log);
  };

  if (watching) {
    bundler = watchify(bundler);
    bundler.on('update', bundlee);
  }

  return bundlee();
});

gulp.task('eslint', function() {
  var paths = getPaths();

  return gulp.src(paths.js)
    .pipe(changed(paths.dist))
    .pipe(eslint({ useEslintrc: true }))
    .pipe(eslint.format())
    .pipe(eslint.failOnError());
});

gulp.task('compilesass', ['clean', 'compilejade'], function() {
  var paths = getPaths();

  return gulp.src(paths.sass)
    .pipe(sourcemaps.init())
    .pipe(sass().on('error', sass.logError))
    .pipe(concat('css/main.css'))
    .pipe(uncss({
      html: paths.dist + 'index.html'
    }))
    .pipe(autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(gulpif(!watching, minifyCss({
      keepSpecialComments: false,
      removeEmpty: true
    })))
    .pipe(rename({ suffix: '.min' }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest(paths.dist))
    .on('error', util.log);
});

gulp.task('compilejade', ['clean'], function() {
  var paths = getPaths();

  return gulp.src(paths.jade)
    .pipe(concat('index.html'))
    .pipe(jade({
      pretty: watching
    }))
    .pipe(gulp.dest(paths.dist))
    .on('error', util.log);
});

gulp.task('reload', ['build'], function() {
  return gulp.src('dist/*.html')
    .pipe(connect.reload())
    .on('error', util.log);
});

gulp.task('connect', function() {
  connect.server({
    root: ['./dist'],
    port: 8000,
    livereload: true
  });
});

gulp.task('open', ['build'], function() {
  gulp.src('./dist/index.html')
    .pipe(open({
      uri: 'http://127.0.0.1:8000'
    }));
});

gulp.task('watch', function() {
  var paths = getPaths();

  watching = true;
  return gulp.watch([paths.sass, paths.jade, paths.js, 'package.json'], ['reload']);
});

gulp.task('bump:patch', function() {
  gulp.src(['./bower.json', './package.json'])
    .pipe(bump({ type: 'patch' }))
    .pipe(gulp.dest('./'))
    .pipe(filter('package.json'))
    .pipe(tagVersion({ prefix: '' }));
});

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

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

gulp.task('default', ['build', 'connect', 'open', 'watch']);
gulp.task('build', ['clean', 'copyfavicon', 'buildlibjs', 'buildlibcss', 'compile']);
gulp.task('compile', ['compilejs', 'compilesass', 'compilejade']);
<commit_msg>renamespacing gulpfile<commit_after>var gulp = require('gulp');
var del = require('del');
var source = require('vinyl-source-stream');
var vinylPaths = require('vinyl-paths');
var browserify = require('browserify');
var babelify = require('babelify');
var errorify = require('errorify');
var watchify = require('watchify');
var fs = require('fs');

var util = require('gulp-util');
var open = require('gulp-open');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var minifyCss = require('gulp-minify-css');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var jade = require('gulp-jade');
var sourcemaps = require('gulp-sourcemaps');
var connect = require('gulp-connect');
var gulpif = require('gulp-if');
var ghPages = require('gulp-gh-pages');
var bump = require('gulp-bump');
var tagVersion = require('gulp-tag-version');
var filter = require('gulp-filter');
var ngAnnotate = require('gulp-ng-annotate');
var uncss = require('gulp-uncss');
var eslint = require('gulp-eslint');
var autoprefixer = require('gulp-autoprefixer');
var changed = require('gulp-changed');

var watching = false;

var getPaths = function() {
  return JSON.parse(fs.readFileSync('./package.json')).gulp;
};

gulp.task('deploy', function() {
  var paths = getPaths();

  return gulp.src(paths.dist + '**/*')
    .pipe(ghPages());
});

gulp.task('clean', function() {
  var paths = getPaths();

  return gulp.src(paths.dist)
    .pipe(vinylPaths(del))
    .on('error', util.log);
});

gulp.task('copy:favicon', ['clean'], function() {
  var paths = getPaths();

  return gulp.src(paths.favicon)
    .pipe(gulp.dest(paths.dist))
    .on('error', util.log);
});

gulp.task('build:libcss', ['clean', 'compile:jade', 'compile:sass'], function() {
  var paths = getPaths();

  return gulp.src(paths.libcss)
    .pipe(changed(paths.dist))
    .pipe(concat('lib.min.css'))
    .pipe(uncss({
      html: paths.dist + 'index.html'
    }))
    .pipe(minifyCss({
      keepSpecialComments: false,
      removeEmpty: true
    }))
    .pipe(gulp.dest(paths.dist + 'css'))
    .on('error', util.log);
});

gulp.task('build:libjs', ['clean'], function() {
  var paths = getPaths();

  return gulp.src(paths.libjs)
    .pipe(changed(paths.dist))
    .pipe(gulpif(!watching, uglify({ outSourceMaps: false })))
    .pipe(concat('lib.min.js'))
    .pipe(gulp.dest(paths.dist + 'js'))
    .on('error', util.log);
});

gulp.task('compile:js', ['eslint', 'clean'], function() {
  var paths = getPaths();

  var bundler = browserify({
    cache: {}, packageCache: {}, fullPaths: true,
    entries: [paths.entry],
    debug: watching
  })
    .transform(babelify);

  if(watching) {
    bundler.plugin(errorify);
  }

  var bundlee = function() {
    return bundler
      .bundle()
      .pipe(source('js/main.min.js'))
      .pipe(gulpif(!watching, streamify(uglify({ outSourceMaps: false }))))
      .pipe(ngAnnotate())
      .pipe(gulp.dest(paths.dist))
      .on('error', util.log);
  };

  if (watching) {
    bundler = watchify(bundler);
    bundler.on('update', bundlee);
  }

  return bundlee();
});

gulp.task('eslint', function() {
  var paths = getPaths();

  return gulp.src(paths.js)
    .pipe(changed(paths.dist))
    .pipe(eslint({ useEslintrc: true }))
    .pipe(eslint.format())
    .pipe(eslint.failOnError());
});

gulp.task('compile:sass', ['clean', 'compile:jade'], function() {
  var paths = getPaths();

  return gulp.src(paths.sass)
    .pipe(sourcemaps.init())
    .pipe(sass().on('error', sass.logError))
    .pipe(concat('css/main.css'))
    .pipe(uncss({
      html: paths.dist + 'index.html'
    }))
    .pipe(autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(gulpif(!watching, minifyCss({
      keepSpecialComments: false,
      removeEmpty: true
    })))
    .pipe(rename({ suffix: '.min' }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest(paths.dist))
    .on('error', util.log);
});

gulp.task('compile:jade', ['clean'], function() {
  var paths = getPaths();

  return gulp.src(paths.jade)
    .pipe(concat('index.html'))
    .pipe(jade({
      pretty: watching
    }))
    .pipe(gulp.dest(paths.dist))
    .on('error', util.log);
});

gulp.task('reload', ['build'], function() {
  return gulp.src('dist/*.html')
    .pipe(connect.reload())
    .on('error', util.log);
});

gulp.task('connect', function() {
  connect.server({
    root: ['./dist'],
    port: 8000,
    livereload: true
  });
});

gulp.task('open', ['build'], function() {
  gulp.src('./dist/index.html')
    .pipe(open({
      uri: 'http://127.0.0.1:8000'
    }));
});

gulp.task('watch', function() {
  var paths = getPaths();

  watching = true;
  return gulp.watch([paths.sass, paths.jade, paths.js, 'package.json'], ['reload']);
});

gulp.task('bump:patch', function() {
  gulp.src(['./bower.json', './package.json'])
    .pipe(bump({ type: 'patch' }))
    .pipe(gulp.dest('./'))
    .pipe(filter('package.json'))
    .pipe(tagVersion({ prefix: '' }));
});

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

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

gulp.task('default', ['build', 'connect', 'open', 'watch']);
gulp.task('build', ['clean', 'copy:favicon', 'build:libjs', 'build:libcss', 'compile']);
gulp.task('compile', ['compile:js', 'compile:sass', 'compile:jade']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var npdcGulp = require('npdc-gulp');
var config = npdcGulp.baseConfig;
config.COMMON_VERSION = '4.6';
npdcGulp.loadAppTasks(gulp, config);
<commit_msg>New common<commit_after>var gulp = require('gulp');
var npdcGulp = require('npdc-gulp');
var config = npdcGulp.baseConfig;
config.COMMON_VERSION = '4.7';
npdcGulp.loadAppTasks(gulp, config);
<|endoftext|>


<commit_before>var config = {
  sassLang: 'libsass',

  server: {
    base: '.',
    hostname: '0.0.0.0',
    keepalive: true,
    stdio: 'ignore',
  },

  browserSync: {
    proxy: '0.0.0.0:8000',
    open: true,
    notify: false
  },

  watch: {
    php: '**/*.php',
  },

  edit: {
    src: 'svg-original/**/*.svg',
    colors: ['#000', '#fff', 'currentColor'],
    dest: ['svg/black', 'svg/white', 'svg/currentColor'],
  },

  svgmin: {
    src: 'svg/**/*.svg',
    dest: 'svg-min/'
  },

  inject: {
    src: 'svg/currentColor/**/*.svg',
    target: './index.php',
    starttag: '',
    dest: './'
  },

  svg2png: {
    src: ['svg/**/*.svg'],
    dest: 'png',
    setting: {
      width: 60,
      height: 60
    }
  },

};

var gulp = require('gulp');
var php = require('gulp-connect-php');
var sass;
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var svgstore = require('gulp-svgstore');
var path = require('path');
var svgmin = require('gulp-svgmin');
var svg2png = require('gulp-svg2png');
var inject = require('gulp-inject');
var browserSync = require('browser-sync').create();
var rename = require('gulp-rename');
var colorize = require('gulp-colorize-svgs');
var mergeStream = require('merge-stream');

function errorlog (error) {
  console.error.bind(error);
  this.emit('end');
}

gulp.task("edit", function(){
  var tasks = [],
      colors = config.edit.colors;

  for (var i = 0; i < colors.length; i++) {
    tasks.push(
      gulp.src(config.edit.src)
          .pipe(colorize({
            colors: {
              default: {
                blue: colors[i]
              },
            },
            replaceColor: function(content, hex) {
              return content.replace(/stroke="#(.*?)"/g, 'stroke="' + hex + '"')
                .replace(/(\d*_fill)/, '')
                .replace(/\d+\s*<\/title>/, '</title>')
                .replace(/(\d*_)/, ' ')
                .replace(/><\/path>/g, ' vector-effect="non-scaling-stroke"></path>')
                .replace(/><\/circle>/g, ' vector-effect="non-scaling-stroke"></circle>')
                .replace(/><\/ellipse>/g, ' vector-effect="non-scaling-stroke"></ellipse>')
                .replace(/><\/polygon>/g, ' vector-effect="non-scaling-stroke"></polygon>')
                .replace(/><\/polyline>/g, ' vector-effect="non-scaling-stroke"></polyline>');
            },
            replacePath: function(path, colorKey) {
              return path.replace(/\.svg/, '.svg');
            }
          }))
          .pipe(gulp.dest(config.edit.dest[i]))
    );
  }

  return mergeStream(tasks)
      .pipe(browserSync.stream());
});

// Svg Task
gulp.task('min', ['edit'], function () {
  return gulp.src(config.svgmin.src)
    .pipe(svgmin())
    .pipe(gulp.dest(config.svgmin.dest))
    .pipe(browserSync.stream());
});

gulp.task('inject', ['edit'], function () {
  function fileContents (filepath, file) {
    if (filepath.slice(-4) === '.svg') {
      return '

' + filepath.slice(filepath.search(/([^/]*)$/), -4) + '

';
    }
  }

  return gulp.src(config.inject.target)
    .pipe(inject(gulp.src(config.inject.src), {
      starttag: config.inject.starttag,
      transform: fileContents
    }))
    .pipe(gulp.dest(config.inject.dest))
    .pipe(browserSync.stream());
});

// svg to png
gulp.task('svg2png', ['edit'], function () {
  gulp.src(config.svg2png.src)
    .pipe(svg2png(config.svg2png.setting))
    .pipe(imagemin())
    .pipe(gulp.dest(config.svg2png.dest));
});

// server
gulp.task('server', function () {
  php.server(config.server);
});
gulp.task('browser-sync', ['server'], function() {
  browserSync.init(config.browserSync);
});

gulp.task('watch', function () {
  gulp.watch(config.edit.src, ['edit', 'min', 'svg2png']);
  gulp.watch(config.watch.php).on('change', browserSync.reload);
  gulp.watch(config.watch.html).on('change', browserSync.reload);
});

// Default Task
gulp.task('default', [
  'min',
  'inject',
  'svg2png',
  'browser-sync',
  'watch',
]);  <commit_msg>update gulpfile<commit_after>var config = {
  sassLang: 'libsass',
  server: {
    base: '.',
    hostname: '0.0.0.0',
    keepalive: true,
    stdio: 'ignore',
  },
  browserSync: {
    proxy: '0.0.0.0:8000',
    open: true,
    notify: false
  },

  watch: {
    php: '**/*.php',
  },

  edit: {
    src: 'svg-original/**/*.svg',
    colors: ['#000', '#fff', 'currentColor'],
    dest: ['svg/black', 'svg/white', 'svg/currentColor'],
  },

  svgmin: {
    src: 'svg/**/*.svg',
    dest: 'svg-min/'
  },

  inject: {
    src: 'svg/currentColor/**/*.svg',
    target: './index.php',
    starttag: '',
    dest: './'
  },

  svg2png: {
    src: ['svg/**/*.svg'],
    dest: 'png',
    setting: {
      width: 60,
      height: 60
    }
  },

};

var gulp = require('gulp');
var php = require('gulp-connect-php');
var libsass = require('gulp-sass');
var rubysass = require('gulp-ruby-sass');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var svgstore = require('gulp-svgstore');
var path = require('path');
var svgmin = require('gulp-svgmin');
var svg2png = require('gulp-svg2png');
var inject = require('gulp-inject');
var browserSync = require('browser-sync').create();
var rename = require('gulp-rename');
var colorize = require('gulp-colorize-svgs');
var mergeStream = require('merge-stream');

function errorlog (error) {
  console.error.bind(error);
  this.emit('end');
}

gulp.task("edit", function(){
  var tasks = [],
      colors = config.edit.colors;

  for (var i = 0; i < colors.length; i++) {
    tasks.push(
      gulp.src(config.edit.src)
          .pipe(colorize({
            colors: {
              default: {
                blue: colors[i]
              },
            },
            replaceColor: function(content, hex) {
              return content.replace(/stroke="#(.*?)"/g, 'stroke="' + hex + '"')
                .replace(/(\d*_fill)/, '')
                .replace(/\d+\s*<\/title>/, '</title>')
                .replace(/(\d*_)/, ' ')
                .replace(/><\/path>/g, ' vector-effect="non-scaling-stroke"></path>')
                .replace(/><\/circle>/g, ' vector-effect="non-scaling-stroke"></circle>')
                .replace(/><\/ellipse>/g, ' vector-effect="non-scaling-stroke"></ellipse>')
                .replace(/><\/polygon>/g, ' vector-effect="non-scaling-stroke"></polygon>')
                .replace(/><\/polyline>/g, ' vector-effect="non-scaling-stroke"></polyline>');
            },
            replacePath: function(path, colorKey) {
              return path.replace(/\.svg/, '.svg');
            }
          }))
          .pipe(gulp.dest(config.edit.dest[i]))
    );
  }

  return mergeStream(tasks)
      .pipe(browserSync.stream());
});

// Svg Task
gulp.task('min', ['edit'], function () {
  return gulp.src(config.svgmin.src)
    .pipe(svgmin())
    .pipe(gulp.dest(config.svgmin.dest))
    .pipe(browserSync.stream());
});

gulp.task('inject', ['edit'], function () {
  function fileContents (filepath, file) {
    if (filepath.slice(-4) === '.svg') {
      return '

' + filepath.slice(filepath.search(/([^/]*)$/), -4) + '

';
    }
  }

  return gulp.src(config.inject.target)
    .pipe(inject(gulp.src(config.inject.src), {
      starttag: config.inject.starttag,
      transform: fileContents
    }))
    .pipe(gulp.dest(config.inject.dest))
    .pipe(browserSync.stream());
});

// svg to png
gulp.task('svg2png', ['edit'], function () {
  return gulp.src(config.svg2png.src)
    .pipe(svg2png(config.svg2png.setting))
    .pipe(imagemin())
    .pipe(gulp.dest(config.svg2png.dest));
});

// server
gulp.task('server', function () {
  php.server(config.server);
});
gulp.task('browser-sync', ['server'], function() {
  browserSync.init(config.browserSync);
});

gulp.task('watch', function () {
  gulp.watch(config.edit.src, ['edit', 'min', 'svg2png']);
  gulp.watch(config.watch.php).on('change', browserSync.reload);
  gulp.watch(config.watch.html).on('change', browserSync.reload);
});

// Default Task
gulp.task('default', [
  'min',
  'inject',
  'svg2png',
  'browser-sync',
  'watch',
]);  <|endoftext|>


<commit_before>/// <binding />
"use strict";
var gulp = require("gulp");
var concat = require("gulp-concat");
var sass = require("gulp-sass");
var rename = require("gulp-rename");
var uglify = require("gulp-uglify");
var bower = require("gulp-bower");
var cleanCSS = require("gulp-clean-css");
var clean = require("gulp-clean");
var ts = require("gulp-typescript");
var debug = require("gulp-debug");

// Set the global.Filename to override this
var OUTPUT_FILE_NAME = global.FileName || "site";

var BOWER_COMPONENTS = global.BowerComponents || "wwwroot/lib";

gulp.task("clean", ["clean:js", "clean:css"]);

gulp.task("clean:js", function () {
    return gulp.src("./wwwroot/js/*.js")
        .pipe(clean());
});

gulp.task("clean:css", function () {
    return gulp.src("./wwwroot/css/*.css")
        .pipe(clean());
});

gulp.task("clean:bower", function () {
    return gulp.src("./" + BOWER_COMPONENTS)
        .pipe(clean());
});

gulp.task("concat", ["concat:js", "concat:css"]);

gulp.task("concat:js", ["clean:js"], function () {
    return gulp.src([
            "./" + BOWER_COMPONENTS + "/jquery/dist/jquery.js",
            "./" + BOWER_COMPONENTS + "/jquery-validation/dist/jquery.validate.js",
            "./" + BOWER_COMPONENTS + "/jquery-validation/dist/additional-methods.js",
            "./" + BOWER_COMPONENTS + "/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js",
            "./" + BOWER_COMPONENTS + "/datatables.net/js/jquery.dataTables.js",
            "./" + BOWER_COMPONENTS + "/datatables.net-buttons/js/dataTables.buttons.js",
            "./" + BOWER_COMPONENTS + "/system.js/dist/system.js",
            "./" + BOWER_COMPONENTS + "/jquery.maskedinput/dist/jquery.maskedinput.js",
            "./" + BOWER_COMPONENTS + "/iUS.UX/scripts/dist/iusHelpers.js",
            "./" + BOWER_COMPONENTS + "/iUS.UX/scripts/dist/iusForm.js",
            "./" + BOWER_COMPONENTS + "/iUS.UX/scripts/dist/iusUX.js"
    ])
    .pipe(debug())
        .pipe(concat(OUTPUT_FILE_NAME + ".js"))
        .pipe(gulp.dest("./wwwroot/js/"));
});

gulp.task("concat:css", ["sass"], function () {
    return gulp.src([
            "./" + BOWER_COMPONENTS + "/pure/pure.css",
            "./" + BOWER_COMPONENTS + "/pure/grids-responsive.css",
            "./" + BOWER_COMPONENTS + "/air-datepicker/dist/css/datepicker.css",
            "./" + BOWER_COMPONENTS + "/datatables.net-dt/css/jquery.dataTables.css",
            "./" + BOWER_COMPONENTS + "/datatables.net-buttons-dt/css/buttons.dataTables.css",
            "./" + BOWER_COMPONENTS + "/iUS.UX/fonts/icomoon/style.css",
            "./wwwroot/css/*.css"
    ])
        .pipe(debug())
        .pipe(concat(OUTPUT_FILE_NAME + ".css"))
        .pipe(gulp.dest("./wwwroot/css/"));
});

gulp.task("minify:css", ["concat:css"], function () {
    return gulp.src(["./wwwroot/css/*.css", "!css/*.min.css"])
        .pipe(debug())
        .pipe(cleanCSS({ compatibility: "ie8" }))
        .pipe(rename({ suffix: ".min" }))
        .pipe(gulp.dest("./wwwroot/css"));
});

gulp.task("uglify:js", ["concat:js"], function () {
    return gulp.src(["./wwwroot/js/*.js", "!./wwwroot/js/*.min.js"])
        .pipe(debug())
        .pipe(uglify())
        .pipe(rename({ suffix: ".min" }))
        .pipe(gulp.dest("./wwwroot/js/"));
});

gulp.task("sass", ["sass:local-app"]);

gulp.task("sass:local-app", function () {
    return gulp.src("./wwwroot/css/" + OUTPUT_FILE_NAME + ".scss")
        .pipe(sass())
        .pipe(gulp.dest("./wwwroot/css"));
});

gulp.task("copyfonts", function () {
    return gulp.src(["./" + BOWER_COMPONENTS + "/iUS.UX/fonts/icomoon/fonts/**"])
      .pipe(debug())
      .pipe(gulp.dest("./wwwroot/css/fonts/"));
});

gulp.task("copyimages", function () {
    return gulp.src(["./" + BOWER_COMPONENTS + "/iUS.UX/images/**", "./" + BOWER_COMPONENTS + "/datatables.net-dt/images/**"])
      .pipe(debug())
      .pipe(gulp.dest("./wwwroot/images/"));
});

gulp.task("watch", function () {
    gulp.watch("./wwwroot/**/*.ts", ["typescript"]);
    gulp.watch("./wwwroot/**/*.scss", ["sass"]);
});<commit_msg>excluding imports from css min processing - trying to fix broken builds<commit_after>/// <binding />
"use strict";
var gulp = require("gulp");
var concat = require("gulp-concat");
var sass = require("gulp-sass");
var rename = require("gulp-rename");
var uglify = require("gulp-uglify");
var bower = require("gulp-bower");
var cleanCSS = require("gulp-clean-css");
var clean = require("gulp-clean");
var ts = require("gulp-typescript");
var debug = require("gulp-debug");

// Set the global.Filename to override this
var OUTPUT_FILE_NAME = global.FileName || "site";

var BOWER_COMPONENTS = global.BowerComponents || "wwwroot/lib";

gulp.task("clean", ["clean:js", "clean:css"]);

gulp.task("clean:js", function () {
    return gulp.src("./wwwroot/js/*.js")
        .pipe(clean());
});

gulp.task("clean:css", function () {
    return gulp.src("./wwwroot/css/*.css")
        .pipe(clean());
});

gulp.task("clean:bower", function () {
    return gulp.src("./" + BOWER_COMPONENTS)
        .pipe(clean());
});

gulp.task("concat", ["concat:js", "concat:css"]);

gulp.task("concat:js", ["clean:js"], function () {
    return gulp.src([
            "./" + BOWER_COMPONENTS + "/jquery/dist/jquery.js",
            "./" + BOWER_COMPONENTS + "/jquery-validation/dist/jquery.validate.js",
            "./" + BOWER_COMPONENTS + "/jquery-validation/dist/additional-methods.js",
            "./" + BOWER_COMPONENTS + "/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js",
            "./" + BOWER_COMPONENTS + "/datatables.net/js/jquery.dataTables.js",
            "./" + BOWER_COMPONENTS + "/datatables.net-buttons/js/dataTables.buttons.js",
            "./" + BOWER_COMPONENTS + "/system.js/dist/system.js",
            "./" + BOWER_COMPONENTS + "/jquery.maskedinput/dist/jquery.maskedinput.js",
            "./" + BOWER_COMPONENTS + "/iUS.UX/scripts/dist/iusHelpers.js",
            "./" + BOWER_COMPONENTS + "/iUS.UX/scripts/dist/iusForm.js",
            "./" + BOWER_COMPONENTS + "/iUS.UX/scripts/dist/iusUX.js"
    ])
    .pipe(debug())
        .pipe(concat(OUTPUT_FILE_NAME + ".js"))
        .pipe(gulp.dest("./wwwroot/js/"));
});

gulp.task("concat:css", ["sass"], function () {
    return gulp.src([
            "./" + BOWER_COMPONENTS + "/pure/pure.css",
            "./" + BOWER_COMPONENTS + "/pure/grids-responsive.css",
            "./" + BOWER_COMPONENTS + "/air-datepicker/dist/css/datepicker.css",
            "./" + BOWER_COMPONENTS + "/datatables.net-dt/css/jquery.dataTables.css",
            "./" + BOWER_COMPONENTS + "/datatables.net-buttons-dt/css/buttons.dataTables.css",
            "./" + BOWER_COMPONENTS + "/iUS.UX/fonts/icomoon/style.css",
            "./wwwroot/css/*.css"
    ])
        .pipe(debug())
        .pipe(concat(OUTPUT_FILE_NAME + ".css"))
        .pipe(gulp.dest("./wwwroot/css/"));
});

gulp.task("minify:css", ["concat:css"], function () {
    return gulp.src(["./wwwroot/css/*.css", "!css/*.min.css"])
        .pipe(debug())
        .pipe(cleanCSS({ compatibility: "ie8", processImport: false })) //importing google font is breaking this task...???
        .pipe(rename({ suffix: ".min" }))
        .pipe(gulp.dest("./wwwroot/css"));
});

gulp.task("uglify:js", ["concat:js"], function () {
    return gulp.src(["./wwwroot/js/*.js", "!./wwwroot/js/*.min.js"])
        .pipe(debug())
        .pipe(uglify())
        .pipe(rename({ suffix: ".min" }))
        .pipe(gulp.dest("./wwwroot/js/"));
});

gulp.task("sass", ["sass:local-app"]);

gulp.task("sass:local-app", function () {
    return gulp.src("./wwwroot/css/" + OUTPUT_FILE_NAME + ".scss")
        .pipe(sass())
        .pipe(gulp.dest("./wwwroot/css"));
});

gulp.task("copyfonts", function () {
    return gulp.src(["./" + BOWER_COMPONENTS + "/iUS.UX/fonts/icomoon/fonts/**"])
      .pipe(debug())
      .pipe(gulp.dest("./wwwroot/css/fonts/"));
});

gulp.task("copyimages", function () {
    return gulp.src(["./" + BOWER_COMPONENTS + "/iUS.UX/images/**", "./" + BOWER_COMPONENTS + "/datatables.net-dt/images/**"])
      .pipe(debug())
      .pipe(gulp.dest("./wwwroot/images/"));
});

gulp.task("watch", function () {
    gulp.watch("./wwwroot/**/*.ts", ["typescript"]);
    gulp.watch("./wwwroot/**/*.scss", ["sass"]);
});<|endoftext|>


<commit_before>var gulp = require('gulp');
var gulpTypescript = require('gulp-typescript');
var typescript = require('typescript');
var header = require('gulp-header');
var merge = require('merge2');
var pkg = require('./package.json');
var clean = require('gulp-clean');
var webpack = require('webpack');
var webpackStream = require('webpack-stream');
var path = require('path');
var replace = require('gulp-replace');

var headerTemplate = '// <%= pkg.name %> v<%= pkg.version %>\n';

var bundleTemplate = '// <%= pkg.name %> v<%= pkg.version %>\n';

gulp.task('default', ['watch']);
gulp.task('release', ['webpack-all']);

gulp.task('webpack-all', ['webpack','webpack-minify','webpack-noStyle','webpack-minify-noStyle'], tscTask);

gulp.task('webpack-minify-noStyle', ['tsc'], webpackTask.bind(null, true, false));
gulp.task('webpack-noStyle', ['tsc'], webpackTask.bind(null, false, false));
gulp.task('webpack-minify', ['tsc'], webpackTask.bind(null, true, true));
gulp.task('webpack', ['tsc'], webpackTask.bind(null, false, true));
gulp.task('webpack-dev', ['tsc-dev'], webpackTask.bind(null, false, true));

gulp.task('tsc', ['cleanDist'], tscTask);

gulp.task('tsc-dev', ['copy-from-ag-grid'], tscTask);

gulp.task('cleanDist', cleanDist);

gulp.task('watch', ['webpack-dev'], watchTask);

gulp.task('copy-from-ag-grid', copyFromAgGrid);

function cleanDist() {
    return gulp
        .src('dist', {read: false})
        .pipe(clean());
}

function tscTask(release_info) {
    var tsResult = gulp
        .src('src/**/*.ts')
        .pipe(replace('@RELEASE_INFO@', release_info))
        .pipe(gulpTypescript({
            typescript: typescript,
            module: 'commonjs',
            experimentalDecorators: true,
            emitDecoratorMetadata: true,
            declarationFiles: true,
            target: 'es5',
            noImplicitAny: true
        }));

    return merge([
        tsResult.dts
            .pipe(header(headerTemplate, { pkg : pkg }))
            .pipe(gulp.dest('dist/lib')),
        tsResult.js
            .pipe(header(headerTemplate, { pkg : pkg }))
            .pipe(gulp.dest('dist/lib'))
    ])
}

function webpackTask(minify, styles) {

    var plugins = [];
    if (minify) {
        plugins.push(new webpack.optimize.UglifyJsPlugin({compress: {warnings: false}}));
    }
    var mainFile = styles ? './webpack-with-styles.js' : './webpack.js';

    var fileName = 'ag-grid-enterprise';
    fileName += minify ? '.min' : '';
    fileName += styles ? '' : '.noStyle';
    fileName += '.js';

    return gulp.src('src/entry.js')
        .pipe(webpackStream({
            entry: {
                main: mainFile
            },
            output: {
                path: path.join(__dirname, "dist"),
                filename: fileName,
                library: ["agGrid"],
                libraryTarget: "umd"
            },
            //devtool: 'inline-source-map',
            module: {
                loaders: [
                    { test: /\.css$/, loader: "style-loader!css-loader" }
                ]
            },
            plugins: plugins
        }))
        .pipe(header(bundleTemplate, { pkg : pkg }))
        .pipe(gulp.dest('./dist/'));
}

function copyFromAgGrid() {
    return gulp.src(['../ag-grid/*', '../ag-grid/dist/**/*'], {base: '../ag-grid'})
        .pipe(gulp.dest('./node_modules/ag-grid'));
}

// 1. copy files -> webpack
// 2. webpack <- copy files

function watchTask() {
    gulp.watch([
        '../ag-grid/dist/ag-grid.js',
        './src/**/*'
    ], ['webpack-dev']);
}
<commit_msg>Licensing work<commit_after>var gulp = require('gulp-param')(require('gulp'), process.argv);
var gulpTypescript = require('gulp-typescript');
var typescript = require('typescript');
var header = require('gulp-header');
var merge = require('merge2');
var pkg = require('./package.json');
var clean = require('gulp-clean');
var webpack = require('webpack');
var webpackStream = require('webpack-stream');
var path = require('path');
var replace = require('gulp-replace');

var headerTemplate = '// <%= pkg.name %> v<%= pkg.version %>\n';

var bundleTemplate = '// <%= pkg.name %> v<%= pkg.version %>\n';

gulp.task('default', ['watch']);
gulp.task('release', ['webpack-all']);

gulp.task('webpack-all', ['webpack','webpack-minify','webpack-noStyle','webpack-minify-noStyle'], tscTask);

gulp.task('webpack-minify-noStyle', ['tsc'], webpackTask.bind(null, true, false));
gulp.task('webpack-noStyle', ['tsc'], webpackTask.bind(null, false, false));
gulp.task('webpack-minify', ['tsc'], webpackTask.bind(null, true, true));
gulp.task('webpack', ['tsc'], webpackTask.bind(null, false, true));
gulp.task('webpack-dev', ['tsc-dev'], webpackTask.bind(null, false, true));

gulp.task('tsc', ['cleanDist'], tscTask);

gulp.task('tsc-dev', ['copy-from-ag-grid'], tscTask);

gulp.task('cleanDist', cleanDist);

gulp.task('watch', ['webpack-dev'], watchTask);

gulp.task('copy-from-ag-grid', copyFromAgGrid);

function cleanDist() {
    return gulp
        .src('dist', {read: false})
        .pipe(clean());
}

function tscTask(release_info) {
    var tsResult = gulp
        .src('src/**/*.ts')
        .pipe(replace('@RELEASE_INFO@', release_info))
        .pipe(gulpTypescript({
            typescript: typescript,
            module: 'commonjs',
            experimentalDecorators: true,
            emitDecoratorMetadata: true,
            declarationFiles: true,
            target: 'es5',
            noImplicitAny: true
        }));

    return merge([
        tsResult.dts
            .pipe(header(headerTemplate, { pkg : pkg }))
            .pipe(gulp.dest('dist/lib')),
        tsResult.js
            .pipe(header(headerTemplate, { pkg : pkg }))
            .pipe(gulp.dest('dist/lib'))
    ])
}

function webpackTask(minify, styles) {

    var plugins = [];
    if (minify) {
        plugins.push(new webpack.optimize.UglifyJsPlugin({compress: {warnings: false}}));
    }
    var mainFile = styles ? './webpack-with-styles.js' : './webpack.js';

    var fileName = 'ag-grid-enterprise';
    fileName += minify ? '.min' : '';
    fileName += styles ? '' : '.noStyle';
    fileName += '.js';

    return gulp.src('src/entry.js')
        .pipe(webpackStream({
            entry: {
                main: mainFile
            },
            output: {
                path: path.join(__dirname, "dist"),
                filename: fileName,
                library: ["agGrid"],
                libraryTarget: "umd"
            },
            //devtool: 'inline-source-map',
            module: {
                loaders: [
                    { test: /\.css$/, loader: "style-loader!css-loader" }
                ]
            },
            plugins: plugins
        }))
        .pipe(header(bundleTemplate, { pkg : pkg }))
        .pipe(gulp.dest('./dist/'));
}

function copyFromAgGrid() {
    return gulp.src(['../ag-grid/*', '../ag-grid/dist/**/*'], {base: '../ag-grid'})
        .pipe(gulp.dest('./node_modules/ag-grid'));
}

// 1. copy files -> webpack
// 2. webpack <- copy files

function watchTask() {
    gulp.watch([
        '../ag-grid/dist/ag-grid.js',
        './src/**/*'
    ], ['webpack-dev']);
}
<|endoftext|>


<commit_before>/**
 * Copyright 2015 Mozilla
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

var connect = require('gulp-connect');
var gulp = require('gulp');
var oghliner = require('oghliner');
var handlebars = require('gulp-handlebars');
var wrap = require('gulp-wrap');
var concat = require('gulp-concat');
var declare = require('gulp-declare');
var eslint = require('gulp-eslint');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var mqpacker = require('css-mqpacker');
var csswring = require('csswring');
var path = require('path');
var debounce = require('lodash.debounce');
var mocha = require('gulp-mocha');

gulp.task('test', function () {
  return gulp.src('app/test/test.js', { read: false })
    // gulp-mocha needs filepaths so you can't have any plugins before it
    .pipe(mocha({reporter: 'nyan'}));
});

gulp.task('default', ['build', 'offline']);

gulp.task('build', ['templates', 'compress', 'css'], function(callback) {
  return gulp.src('app/**').pipe(gulp.dest('dist'));
});

gulp.task('configure', oghliner.configure);

gulp.task('deploy', function() {
  return oghliner.deploy({
    rootDir: 'dist',
  });
});

gulp.task('lint', function() {
  return gulp.src(['app/scripts/sightinglist.js', 'app/scripts/app.js']).pipe(eslint({
    'rules':{
        'quotes': [1, 'single'],
        'semi': [1, 'always'],
        'comma-dangle': [1, 'always-multiline'],
        'quote-props': [1, 'as-needed']
    }
  })).pipe(eslint.format());
});

gulp.task('templates', function(){
  return gulp.src('app/templates/*.html')
    .pipe(handlebars({
      handlebars: require('handlebars')
    }))
    .pipe(wrap('Handlebars.template(<%= contents %>)'))
    .pipe(declare({
      namespace: 'ebirdmybird',
      noRedeclare: true, // Avoid duplicate declarations
    }))
    .pipe(concat('handlebars-templates.js'))
    .pipe(gulp.dest('./app/scripts'));
});

gulp.task('compress', ['templates'], function(){
  return gulp.src([
    'app/scripts/d3.v3.js',
    'app/scripts/c3.min.js',
    'app/scripts/lunr.js',
    'app/scripts/papaparse.js',
    'app/scripts/handlebars-v4.0.4.js',
    'app/scripts/handlebars-templates.js',
    'app/scripts/sightinglist.js',
    'app/scripts/app.js',
  ])
    .pipe(sourcemaps.init())
    .pipe(concat('compressed.js'))
    .pipe(uglify())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('app/scripts'));
});

gulp.task('css', function() {
  var processors = [
    mqpacker,
    csswring,
  ];
  return gulp
    .src(['app/styles/*.css', '!app/styles/bundle.css'])
    .pipe(postcss(processors))
    .pipe(concat('bundle.css'))
    .pipe(gulp.dest('app/styles'));
});

gulp.task('offline', ['build'], function() {
  return oghliner.offline({
    rootDir: 'dist/',
    fileGlobs: [
      'images/**',
      'index.html',
      'scripts/compressed.js',
      'data/**',
      'styles/**',
    ],
  });
});

gulp.task('serve', ['offline'], function () {
  connect.server({
    root: 'dist',
  });
});

gulp.task('watch', ['offline'], function() {
  var browserSyncCreator = require('browser-sync');
  var browserSync = browserSyncCreator.create();
  browserSync.init({
    open: false,
    server: {
      baseDir: 'dist',
      ghostMode: false,
      notify: false,
    },
  });
  gulp.watch(['./app/styles/*.css'], ['css']);
  gulp.watch(['./app/scripts/*.js', '!./app/scripts/compressed.js'], ['compress']);
  gulp.watch(['./app/templates/*.html'], ['templates']);
  gulp.watch([
    path.join('app', '**/*.*'),
  ], debounce(function () { return gulp.src('app/**').pipe(gulp.dest('dist')); }, 200));
});

<commit_msg>run lint on test code, too<commit_after>/**
 * Copyright 2015 Mozilla
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

var connect = require('gulp-connect');
var gulp = require('gulp');
var oghliner = require('oghliner');
var handlebars = require('gulp-handlebars');
var wrap = require('gulp-wrap');
var concat = require('gulp-concat');
var declare = require('gulp-declare');
var eslint = require('gulp-eslint');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var mqpacker = require('css-mqpacker');
var csswring = require('csswring');
var path = require('path');
var debounce = require('lodash.debounce');
var mocha = require('gulp-mocha');

gulp.task('test', function () {
  return gulp.src('app/test/test.js', { read: false })
    // gulp-mocha needs filepaths so you can't have any plugins before it
    .pipe(mocha({reporter: 'nyan'}));
});

gulp.task('default', ['build', 'offline']);

gulp.task('build', ['templates', 'compress', 'css'], function(callback) {
  return gulp.src('app/**').pipe(gulp.dest('dist'));
});

gulp.task('configure', oghliner.configure);

gulp.task('deploy', function() {
  return oghliner.deploy({
    rootDir: 'dist',
  });
});

gulp.task('lint', function() {
  return gulp.src(['app/scripts/sightinglist.js', 'app/scripts/app.js', 'app/test/test.js']).pipe(eslint({
    'rules':{
        'quotes': [1, 'single'],
        'semi': [1, 'always'],
        'comma-dangle': [1, 'always-multiline'],
        'quote-props': [1, 'as-needed']
    }
  })).pipe(eslint.format());
});

gulp.task('templates', function(){
  return gulp.src('app/templates/*.html')
    .pipe(handlebars({
      handlebars: require('handlebars')
    }))
    .pipe(wrap('Handlebars.template(<%= contents %>)'))
    .pipe(declare({
      namespace: 'ebirdmybird',
      noRedeclare: true, // Avoid duplicate declarations
    }))
    .pipe(concat('handlebars-templates.js'))
    .pipe(gulp.dest('./app/scripts'));
});

gulp.task('compress', ['templates'], function(){
  return gulp.src([
    'app/scripts/d3.v3.js',
    'app/scripts/c3.min.js',
    'app/scripts/lunr.js',
    'app/scripts/papaparse.js',
    'app/scripts/handlebars-v4.0.4.js',
    'app/scripts/handlebars-templates.js',
    'app/scripts/sightinglist.js',
    'app/scripts/app.js',
  ])
    .pipe(sourcemaps.init())
    .pipe(concat('compressed.js'))
    .pipe(uglify())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('app/scripts'));
});

gulp.task('css', function() {
  var processors = [
    mqpacker,
    csswring,
  ];
  return gulp
    .src(['app/styles/*.css', '!app/styles/bundle.css'])
    .pipe(postcss(processors))
    .pipe(concat('bundle.css'))
    .pipe(gulp.dest('app/styles'));
});

gulp.task('offline', ['build'], function() {
  return oghliner.offline({
    rootDir: 'dist/',
    fileGlobs: [
      'images/**',
      'index.html',
      'scripts/compressed.js',
      'data/**',
      'styles/**',
    ],
  });
});

gulp.task('serve', ['offline'], function () {
  connect.server({
    root: 'dist',
  });
});

gulp.task('watch', ['offline'], function() {
  var browserSyncCreator = require('browser-sync');
  var browserSync = browserSyncCreator.create();
  browserSync.init({
    open: false,
    server: {
      baseDir: 'dist',
      ghostMode: false,
      notify: false,
    },
  });
  gulp.watch(['./app/styles/*.css'], ['css']);
  gulp.watch(['./app/scripts/*.js', '!./app/scripts/compressed.js'], ['compress']);
  gulp.watch(['./app/templates/*.html'], ['templates']);
  gulp.watch([
    path.join('app', '**/*.*'),
  ], debounce(function () { return gulp.src('app/**').pipe(gulp.dest('dist')); }, 200));
});

<|endoftext|>


<commit_before>var gulp            = require('gulp');
var sass            = require('gulp-sass');
var autoprefixer    = require('gulp-autoprefixer');
var minifyCSS       = require('gulp-minify-css');
var connect         = require('gulp-connect');
var openPage        = require("gulp-open");

/**
*  RELOAD
*
*  reload page
*/

gulp.task("reload", function() {
  var stream = gulp.src('*.html')
    .pipe(connect.reload());

  return stream;
});

/**
*  CSS PREPROCESSING
*
*  Sass, vender prefix, minify, move
*/

gulp.task('css', function() {
  var stream = gulp.src('scss/**/*.scss')
      .pipe(sass())
      .pipe(autoprefixer())
      .pipe(minifyCSS({ noAdvanced: true }))
      .pipe(gulp.dest('css'))
      .pipe(connect.reload());

  return stream;
});

/**
*  WATCH
*
*  Rerun process after any of these files are edited
*/

gulp.task('watch', function() {
  gulp.watch('scss/**/*.scss', ['css']);
  gulp.watch('js/**/*.js', ['reload']);
  gulp.watch('images/**/*.{jpg,png,gif}', ['reload']);
  gulp.watch('index.html', ['reload']);
});

/**
*  CONNECT SERVER
*
*  Loads the server locally and reloads when
*  connect.reload() is called.
*/
gulp.task('connect', function() {
  connect.server({
    root: '.',
    port: 8000,
    livereload: true
  });
});

/**
*  BUILD TASKS
*
*  Local and production build tasks
*/
gulp.task('default', ['css', 'watch', 'connect'], function() {
  //Now open in browser
  var stream = gulp.src("index.html")
      .pipe(openPage("", {
        app: "Mozilla Firefox",
        url: "http://localhost:8000"
      }));

  return stream;
});
<commit_msg>Update gulpfile.js<commit_after>var gulp            = require('gulp');
var sass            = require('gulp-sass');
var autoprefixer    = require('gulp-autoprefixer');
var minifyCSS       = require('gulp-minify-css');
var connect         = require('gulp-connect');
var openPage        = require("gulp-open");

/**
*  RELOAD
*
*  reload page
*/

gulp.task("reload", function() {
  var stream = gulp.src('*.html')
    .pipe(connect.reload());

  return stream;
});

/**
*  CSS PREPROCESSING
*
*  Sass, vender prefix, minify, move
*/

gulp.task('css', function() {
  var stream = gulp.src('scss/**/*.scss')
      .pipe(sass())
      .pipe(autoprefixer())
      .pipe(minifyCSS({ noAdvanced: true }))
      .pipe(gulp.dest('css'))
      .pipe(connect.reload());

  return stream;
});

/**
*  WATCH
*
*  Rerun process after any of these files are edited
*/

gulp.task('watch', function() {
  gulp.watch('scss/**/*.scss', ['css']);
  gulp.watch('js/**/*.js', ['reload']);
  gulp.watch('images/**/*.{jpg,png,gif}', ['reload']);
  gulp.watch('index.html', ['reload']);
});

/**
*  CONNECT SERVER
*
*  Loads the server locally and reloads when
*  connect.reload() is called.
*/
gulp.task('connect', function() {
  connect.server({
    root: '.',
    port: 8000,
    livereload: true
  });
});

/**
*  BUILD TASKS
*
*  Local and production build tasks
*/
gulp.task('default', ['css', 'watch', 'connect'], function() {
  //Now open in browser
  var stream = gulp.src("index.html")
      .pipe(openPage("", {
        app: "Google Chrome",
        url: "http://localhost:8000"
      }));

  return stream;
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var del = require('del');
var args = require('yargs').argv;
var $ = require('gulp-load-plugins')({lazy:true});
var browserSync = require('browser-sync');

var config = require('./gulp.config')();

var port = process.env.PORT || config.defaultPort;

gulp.task('help', $.taskListing);
gulp.task('default', ['help']);

gulp.task('vet', function() {
    log('vetting js now');
    return gulp
		.src(config.alljs)
		.pipe($.jscs())
		.pipe($.jshint())
		.pipe($.jshint.reporter('jshint-stylish', {verbose:true}))
        .pipe($.jshint.reporter('fail'));
});

gulp.task('clean-styles', function(done) {
    var files = config.temp + '**/*.css';
    clean(files, done);
});

gulp.task('clean-code', function(done) {
    var files = [].concat(
        config.temp + '**/*.js',
        config.build + '**/*.html',
        config.build + 'js/**/*.js'
    );
    clean(files, done);
});

gulp.task('templatecache', ['clean-code'], function() {
    log('creating angularJS $templateCache');

    return gulp
        .src(config.htmlTemplates)
        .pipe($.minifyHtml({empty : true}))
        .pipe($.angularTemplatecache(
            config.templateCache.file,
            config.templateCache.options
        ))
        .pipe(gulp.dest(config.temp));
});

gulp.task('styles', ['clean-styles'], function() {
    log('compiling Less --> CSS');
    return gulp
        .src(config.less)
        .pipe($.plumber())
        .pipe($.less())
        .pipe($.autoprefixer({browsers:['last 2 version', '> 5%']}))
        .pipe(gulp.dest(config.temp));
});

gulp.task('wiredep', function() {
    var options = config.getWiredepOptions();
    var wiredep = require('wiredep').stream;

    return gulp
        .src(config.index)
        .pipe(wiredep(options))
        .pipe($.inject(gulp.src(config.js)))
        .pipe(gulp.dest(config.client));
});

gulp.task('inject', ['wiredep', 'styles'], function() {
    return gulp
      .src(config.index)
      .pipe($.inject(gulp.src(config.css)))
      .pipe($.replace(/="..\/..\/bower_components\//g, '="/bower_components/'))
      .pipe(gulp.dest(config.client));
});

gulp.task('serve-dev', ['inject'], function() {
    serve(true /* isDev */);
});

/////

function serve(isDev) {
    var nodeOptions = {
        script: config.nodeServer,
        delayTime: 1,
        env: {
            'PORT': port,
            'NODE_ENV': isDev ? 'dev' : 'build'
        },
        watch: [config.server]
    };
    return $.nodemon(nodeOptions)
        .on('restart', ['vet'], function(ev) {
            log('*** nodemon restarted');
            log('files changed on restart:\n' + ev);
            setTimeout(function() {
                browserSync.notify('reloading now...');
                browserSync.reload({stream:false});
            }, config.browserReloadDelay);
        })
        .on('start', function() {
            log('*** nodemon started');
            startBrowserSync(isDev);
        })
        .on('crash', function() {
            log('*** nodemon crashed: script crashed for some reason');
        })
        .on('exit', function() {
            log('*** nodemon exited cleanly');
        });
}

function changeEvent(event) {
    var srcPattern = new RegExp('/.*(?=/' + config.source + ')/');
    log('File ' + event.path.replace(srcPattern, '') + '' + event.type);
}

function log(msg) {
    if (typeof(msg) === 'object') {
        for (var item in msg) {
            if (msg.hasOwnProperty(item)) {
                $.util.log($.util.colors.blue(msg[item]));
            }
        }
    } else {
        $.util.log($.util.colors.blue(msg));
    }
}

function clean(path, done) {
    log('Cleaning: ' + $.util.colors.blue(path));
    del(path, done);
}

function startBrowserSync() {
    if (args.nosync || browserSync.active) {
        return;
    }
    log('starting browser-sync on port ' + port);

    gulp.watch([config.less], ['styles'])
      .on('change', function(event) { changeEvent(event); });

    var options = {
        proxy: 'localhost:' + port,
        port: 8681,
        files: [
          config.client + '**/*.*',
          '!' + config.less,
          config.temp + '**/*.css'
        ],
        ghostMode: {
            clicks: true,
            location: false,
            forms: true,
            scroll: true
        },
        injectChanges: true,
        logFileChanges: true,
        logLevel: 'debug',
        logPrefix: 'gulp-patterns',
        notify: true,
        reloadDelay: 1000
    };
    browserSync(options);
}
<commit_msg>added 'templatecache' as dependency to inject task<commit_after>var gulp = require('gulp');
var del = require('del');
var args = require('yargs').argv;
var $ = require('gulp-load-plugins')({lazy:true});
var browserSync = require('browser-sync');

var config = require('./gulp.config')();

var port = process.env.PORT || config.defaultPort;

gulp.task('help', $.taskListing);
gulp.task('default', ['help']);

gulp.task('vet', function() {
    log('vetting js now');
    return gulp
		.src(config.alljs)
		.pipe($.jscs())
		.pipe($.jshint())
		.pipe($.jshint.reporter('jshint-stylish', {verbose:true}))
        .pipe($.jshint.reporter('fail'));
});

gulp.task('clean-styles', function(done) {
    var files = config.temp + '**/*.css';
    clean(files, done);
});

gulp.task('clean-code', function(done) {
    var files = [].concat(
        config.temp + '**/*.js',
        config.build + '**/*.html',
        config.build + 'js/**/*.js'
    );
    clean(files, done);
});

gulp.task('templatecache', ['clean-code'], function() {
    log('creating angularJS $templateCache');

    return gulp
        .src(config.htmlTemplates)
        .pipe($.minifyHtml({empty : true}))
        .pipe($.angularTemplatecache(
            config.templateCache.file,
            config.templateCache.options
        ))
        .pipe(gulp.dest(config.temp));
});

gulp.task('styles', ['clean-styles'], function() {
    log('compiling Less --> CSS');
    return gulp
        .src(config.less)
        .pipe($.plumber())
        .pipe($.less())
        .pipe($.autoprefixer({browsers:['last 2 version', '> 5%']}))
        .pipe(gulp.dest(config.temp));
});

gulp.task('wiredep', function() {
    var options = config.getWiredepOptions();
    var wiredep = require('wiredep').stream;

    return gulp
        .src(config.index)
        .pipe(wiredep(options))
        .pipe($.inject(gulp.src(config.js)))
        .pipe(gulp.dest(config.client));
});

gulp.task('inject', ['wiredep', 'styles', 'templatecache'], function() {
    return gulp
      .src(config.index)
      .pipe($.inject(gulp.src(config.css)))
      .pipe($.replace(/="..\/..\/bower_components\//g, '="/bower_components/'))
      .pipe(gulp.dest(config.client));
});

gulp.task('serve-dev', ['inject'], function() {
    serve(true /* isDev */);
});

/////

function serve(isDev) {
    var nodeOptions = {
        script: config.nodeServer,
        delayTime: 1,
        env: {
            'PORT': port,
            'NODE_ENV': isDev ? 'dev' : 'build'
        },
        watch: [config.server]
    };
    return $.nodemon(nodeOptions)
        .on('restart', ['vet'], function(ev) {
            log('*** nodemon restarted');
            log('files changed on restart:\n' + ev);
            setTimeout(function() {
                browserSync.notify('reloading now...');
                browserSync.reload({stream:false});
            }, config.browserReloadDelay);
        })
        .on('start', function() {
            log('*** nodemon started');
            startBrowserSync(isDev);
        })
        .on('crash', function() {
            log('*** nodemon crashed: script crashed for some reason');
        })
        .on('exit', function() {
            log('*** nodemon exited cleanly');
        });
}

function changeEvent(event) {
    var srcPattern = new RegExp('/.*(?=/' + config.source + ')/');
    log('File ' + event.path.replace(srcPattern, '') + '' + event.type);
}

function log(msg) {
    if (typeof(msg) === 'object') {
        for (var item in msg) {
            if (msg.hasOwnProperty(item)) {
                $.util.log($.util.colors.blue(msg[item]));
            }
        }
    } else {
        $.util.log($.util.colors.blue(msg));
    }
}

function clean(path, done) {
    log('Cleaning: ' + $.util.colors.blue(path));
    del(path, done);
}

function startBrowserSync() {
    if (args.nosync || browserSync.active) {
        return;
    }
    log('starting browser-sync on port ' + port);

    gulp.watch([config.less], ['styles'])
      .on('change', function(event) { changeEvent(event); });

    var options = {
        proxy: 'localhost:' + port,
        port: 8681,
        files: [
          config.client + '**/*.*',
          '!' + config.less,
          config.temp + '**/*.css'
        ],
        ghostMode: {
            clicks: true,
            location: false,
            forms: true,
            scroll: true
        },
        injectChanges: true,
        logFileChanges: true,
        logLevel: 'debug',
        logPrefix: 'gulp-patterns',
        notify: true,
        reloadDelay: 1000
    };
    browserSync(options);
}
<|endoftext|>


<commit_before>'use strict';

var babelify   = require('babelify');
var browserify = require('browserify');
var del        = require('del');
var gulp       = require('gulp');
var eslint     = require('gulp-eslint');
var less       = require('gulp-less');
var minifyCSS  = require('gulp-minify-css');
var removeCode = require('gulp-remove-code');
var rename     = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var gutil      = require('gulp-util');
var source     = require('vinyl-source-stream');
var watchify   = require('watchify');

// Make Gulp complete after async tasks. https://github.com/gulpjs/gulp/issues/167
var isWatching = true;
gulp.on('stop', function() {
  if(!isWatching) {
    process.nextTick(function() {
      process.exit(0);
    });
  }
});

/*********************************** Tasks ************************************/
// Default
gulp.task('default', ['build:dev']);

// Used by all build tasks
gulp.task('clean', clean);
gulp.task('clean:core', cleanCore);
gulp.task('clean:css', cleanCss);
gulp.task('clean:server', cleanServer);
gulp.task('lint:js', lintJS);
gulp.task('move:all', ['move:core', 'move:server'], function(cb){cb();});
gulp.task('move:core', ['clean:core'], moveCore);
gulp.task('move:server', ['clean:server', 'lint:php'], moveServer);
gulp.task('less', ['clean:less'], lessCSS);

// Used by all dev build tasks
gulp.task('build:dev', ['lint:js', 'move:all', 'less'], buildDev);
gulp.task('watch:core', watchCore);
gulp.task('watch:less', watchLess);

// Prod build tasks
gulp.task('build:prod', ['lint:js', 'move:all', 'less'], buildProd);

/*********************************** Paths ************************************/
// TODO: implement

/******************************* Task functions *******************************/

function buildDev(callback) {
  var bundler = getBundler(['src/client/js/main.js']);
  var watcher = getWatcher(bundler, rebundle);

  function rebundle() {
    lintJS(callback);

    return watcher.bundle()
      .pipe(source('bundle.min.js'))
      .pipe(gulp.dest('dist/js'));
  }

  rebundle();
  watchLess(callback);
  watchCore(callback);
  return callback();
}

/**
 * Builds a production version of the website.
 * TODO: I think the removeCode is going to mess-up the sourcemaps. Check this.
 */
function buildProd() {
  isWatching = false;

  var bundler = getBundler(['src/client/js/main.js']);
  bundler.transform('stripify');
  bundler.plugin('minifyify', { map: 'bundle.min.js.map', output: 'dist/js/bundle.min.js.map' } );

  return bundler.bundle()
    .pipe(source('bundle.min.js'))
    .pipe(removeCode( { production: true } ))
    .pipe(gulp.dest('dist/js'));
}

// Cleans dist/
function clean() {
  return del(['dist']);
}

// Cleans core files
function cleanCore() {
  return del(['dist/*.*', 'dist/js/plugins.js', '!dist/**/*.php']);
}

// Cleans dist/styles
function cleanCss() {
  return del(['dist/styles/**/*.css']);
}

// Cleans .php files
function cleanServer() {
  return del(['dist/**/*.php']);
}

// Move and minify Less
function lessCSS() {
  return gulp.src(['src/client/styles/**/*.css'], {base: 'src/client/styles'})
      .pipe(rename(function(path) {
        path.extname = ".min" + path.extname;
      }))
      .pipe(sourcemaps.init())
      .pipe(less())
      .pipe(minifyCSS)
      .pipe(sourcemaps.write())
      .pipe(gulp.dest('dist/styles'));
}

function lintJS() {
  return gulp.src(['src/client/components/**/*.*', 'src/client/js/main.js', 'src/client/stores/**/*.*', 'src/client/actions/**/*.*'])
      .pipe(eslint())
      .pipe(eslint.format())
      .pipe(eslint.failAfterError());
}

// Moves root files that need no processing into dist
function moveCore() {
  return gulp.src(['src/client/*.*', 'src/client/js/plugins.js'], { base: 'src/client' } )
      .pipe(gulp.dest('dist'));
}

// Moves php files that need no processing into dist
function moveServer() {
  return gulp.src(['src/server/**/*.php'], { base: 'src/server' } )
      .pipe(gulp.dest('dist'));
}

// Watch for changes to core
function watchCore() {
  gulp.watch(['src/client/*.*'], ['move:core']);
}

// Watch for changes to CSS
function watchLess() {
  gulp.watch(['src/client/styles/**/*.*'], ['less']);
}

/****************************** Helper functions ******************************/

/**
 * Gets the default bundler used by all builds. By default, the bundler will
 * perform JSX and ES6 transforms.
 *
 * @param path An array of string representing the application roots
 * @return A basically configured Browserify bundler
 */
function getBundler(paths) {
  var bundler = browserify({
    entries: paths,
    debug: true,
    extensions: ['.jsx'],
    cache: {},
    packageCache: {}
  });

  bundler.transform(babelify, {presets: ["es2015", "react"]});

  bundler.on('log', gutil.log);
  bundler.on('error', gutil.log.bind(gutil.colors.red, 'Browserify Error'));

  return bundler;
}

/**
 * Gets the default Watchify watcher used by dev builds. By default, the watcher
 * will rebundle the Browserify package when an update occurs.
 *
 * @param bundler The Browserify bundler object
 * @param rebundle A function to perform when Watchify detects a code update
 * @return A basically configured Watchify watcher
 */
function getWatcher(bundler, rebundle) {
  bundler.plugin(watchify);
  bundler.on('update', rebundle);

  return bundler;
}
<commit_msg>removed non-needed comment<commit_after>// NOTE: This file is written in ES5 so as to be backwards compatible with older versions on npm.

'use strict';

var babelify   = require('babelify');
var browserify = require('browserify');
var del        = require('del');
var gulp       = require('gulp');
var eslint     = require('gulp-eslint');
var less       = require('gulp-less');
var minifyCSS  = require('gulp-minify-css');
var removeCode = require('gulp-remove-code');
var rename     = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var gutil      = require('gulp-util');
var source     = require('vinyl-source-stream');
var watchify   = require('watchify');

// Make Gulp complete after async tasks. https://github.com/gulpjs/gulp/issues/167
var isWatching = true;
gulp.on('stop', function() {
  if(!isWatching) {
    process.nextTick(function() {
      process.exit(0);
    });
  }
});

/*********************************** Tasks ************************************/
// Default
gulp.task('default', ['build:dev']);

// Used by all build tasks
gulp.task('clean', clean);
gulp.task('clean:core', cleanCore);
gulp.task('clean:css', cleanCss);
gulp.task('clean:server', cleanServer);
gulp.task('lint:js', lintJS);
gulp.task('move:all', ['move:core', 'move:server'], function(cb){cb();});
gulp.task('move:core', ['clean:core'], moveCore);
gulp.task('move:server', ['clean:server', 'lint:php'], moveServer);
gulp.task('less', ['clean:less'], lessCSS);

// Used by all dev build tasks
gulp.task('build:dev', ['lint:js', 'move:all', 'less'], buildDev);
gulp.task('watch:core', watchCore);
gulp.task('watch:less', watchLess);

// Prod build tasks
gulp.task('build:prod', ['lint:js', 'move:all', 'less'], buildProd);

/******************************* Task functions *******************************/

function buildDev(callback) {
  var bundler = getBundler(['src/client/js/main.js']);
  var watcher = getWatcher(bundler, rebundle);

  function rebundle() {
    lintJS(callback);

    return watcher.bundle()
      .pipe(source('bundle.min.js'))
      .pipe(gulp.dest('dist/js'));
  }

  rebundle();
  watchLess(callback);
  watchCore(callback);
  return callback();
}

/**
 * Builds a production version of the website.
 * TODO: I think the removeCode is going to mess-up the sourcemaps. Check this.
 */
function buildProd() {
  isWatching = false;

  var bundler = getBundler(['src/client/js/main.js']);
  bundler.transform('stripify');
  bundler.plugin('minifyify', { map: 'bundle.min.js.map', output: 'dist/js/bundle.min.js.map' } );

  return bundler.bundle()
    .pipe(source('bundle.min.js'))
    .pipe(removeCode( { production: true } ))
    .pipe(gulp.dest('dist/js'));
}

// Cleans dist/
function clean() {
  return del(['dist']);
}

// Cleans core files
function cleanCore() {
  return del(['dist/*.*', 'dist/js/plugins.js', '!dist/**/*.php']);
}

// Cleans dist/styles
function cleanCss() {
  return del(['dist/styles/**/*.css']);
}

// Cleans .php files
function cleanServer() {
  return del(['dist/**/*.php']);
}

// Move and minify Less
function lessCSS() {
  return gulp.src(['src/client/styles/**/*.css'], {base: 'src/client/styles'})
      .pipe(rename(function(path) {
        path.extname = ".min" + path.extname;
      }))
      .pipe(sourcemaps.init())
      .pipe(less())
      .pipe(minifyCSS)
      .pipe(sourcemaps.write())
      .pipe(gulp.dest('dist/styles'));
}

function lintJS() {
  return gulp.src(['src/client/components/**/*.*', 'src/client/js/main.js', 'src/client/stores/**/*.*', 'src/client/actions/**/*.*'])
      .pipe(eslint())
      .pipe(eslint.format())
      .pipe(eslint.failAfterError());
}

// Moves root files that need no processing into dist
function moveCore() {
  return gulp.src(['src/client/*.*', 'src/client/js/plugins.js'], { base: 'src/client' } )
      .pipe(gulp.dest('dist'));
}

// Moves php files that need no processing into dist
function moveServer() {
  return gulp.src(['src/server/**/*.php'], { base: 'src/server' } )
      .pipe(gulp.dest('dist'));
}

// Watch for changes to core
function watchCore() {
  gulp.watch(['src/client/*.*'], ['move:core']);
}

// Watch for changes to CSS
function watchLess() {
  gulp.watch(['src/client/styles/**/*.*'], ['less']);
}

/****************************** Helper functions ******************************/

/**
 * Gets the default bundler used by all builds. By default, the bundler will
 * perform JSX and ES6 transforms.
 *
 * @param path An array of string representing the application roots
 * @return A basically configured Browserify bundler
 */
function getBundler(paths) {
  var bundler = browserify({
    entries: paths,
    debug: true,
    extensions: ['.jsx'],
    cache: {},
    packageCache: {}
  });

  bundler.transform(babelify, {presets: ["es2015", "react"]});

  bundler.on('log', gutil.log);
  bundler.on('error', gutil.log.bind(gutil.colors.red, 'Browserify Error'));

  return bundler;
}

/**
 * Gets the default Watchify watcher used by dev builds. By default, the watcher
 * will rebundle the Browserify package when an update occurs.
 *
 * @param bundler The Browserify bundler object
 * @param rebundle A function to perform when Watchify detects a code update
 * @return A basically configured Watchify watcher
 */
function getWatcher(bundler, rebundle) {
  bundler.plugin(watchify);
  bundler.on('update', rebundle);

  return bundler;
}
<|endoftext|>