<commit_before>'use strict';

var gulp = require('gulp');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var watch = require('gulp-watch');
var concatCss = require('gulp-concat-css');
var minifyCss = require('gulp-minify-css');
var connect = require('gulp-connect');

var config = {
    dev: true,
    srcJS: ['src/main/webapp/inc/js/lib/angular.js',
            'src/main/webapp/inc/js/lib/*.js',
            'src/main/webapp/inc/js/app.js',
            'src/main/webapp/inc/js/app/**/*module.js',
            'src/main/webapp/inc/js/app/**/*.js'
	   ],
    destJS: 'prd/js/',
    outJS: 'game.js',
    watchJS: 'src/main/webapp/inc/js/app/**/*.js',
    srcCSS: ['src/main/webapp/inc/css/*.css'],
    destCSS: 'prd/css/',
    outCSS: 'game.css',
    watchCSS: 'src/main/webapp/inc/css/*.css'
};

gulp.task('set-production', function () {
    config.dev = false;
});

gulp.task('prod', ['set-production', 'build-js', 'build-css']);

gulp.task('build-js', function () {
    return gulp.src(config.srcJS)
        .pipe(gulpif(config.dev, sourcemaps.init()))
	.pipe(concat(config.outJS))
        .pipe(uglify())
        .pipe(gulpif(config.dev, sourcemaps.write()))
        .pipe(gulp.dest(config.destJS));
});

gulp.task('build-css', function () {
    return gulp.src(config.srcCSS)
	.pipe(gulpif(config.dev, sourcemaps.init()))
	.pipe(concatCss(config.outCSS))
	.pipe(minifyCss())
	.pipe(gulpif(config.dev, sourcemaps.write()))
        .pipe(gulp.dest(config.destCSS));
});

gulp.task('watch', ['build-js', 'build-css', 'connect'], function () {
    watch(config.watchJS, function() {
        gulp.start('build-js');
    });
    watch(config.watchCSS, function() {
        gulp.start('build-css');
    });
});

gulp.task('connect', function() {
    connect.server({
	root: 'prd',
	port: 8282
  });
});
<commit_msg>feat: Use gulp to copy html and partial files<commit_after>'use strict';

var gulp = require('gulp');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var watch = require('gulp-watch');
var concatCss = require('gulp-concat-css');
var minifyCss = require('gulp-minify-css');
var connect = require('gulp-connect');

var config = {
    dev: true,
    srcJS: ['src/main/webapp/inc/js/lib/angular.js',
            'src/main/webapp/inc/js/lib/*.js',
            'src/main/webapp/inc/js/app.js',
            'src/main/webapp/inc/js/app/**/*module.js',
            'src/main/webapp/inc/js/app/**/*.js'
	   ],
    destJS: 'prd/js/',
    outJS: 'game.js',
    watchJS: 'src/main/webapp/inc/js/app/**/*.js',
    srcCSS: ['src/main/webapp/inc/css/*.css'],
    destCSS: 'prd/css/',
    outCSS: 'game.css',
    watchCSS: 'src/main/webapp/inc/css/*.css',
    srcHtml: ['src/main/webapp/WEB-INF/game.html'],
    destHtml: 'prd',
    watchHtml: 'src/main/webapp/WEB-INF/game.html',
    scrPartials: ['src/main/webapp/inc/html/game/*.html',
	      'src/main/webapp/inc/html/game/create/*.html'],
    destPartials: 'prd/partials'
};

gulp.task('set-production', function () {
    config.dev = false;
});

gulp.task('prod', ['set-production', 'build-js', 'build-css', 'build-html']);

gulp.task('build-js', function () {
    return gulp.src(config.srcJS)
        .pipe(gulpif(config.dev, sourcemaps.init()))
	.pipe(concat(config.outJS))
        .pipe(uglify())
        .pipe(gulpif(config.dev, sourcemaps.write()))
        .pipe(gulp.dest(config.destJS));
});

gulp.task('build-css', function () {
    return gulp.src(config.srcCSS)
	.pipe(gulpif(config.dev, sourcemaps.init()))
	.pipe(concatCss(config.outCSS))
	.pipe(minifyCss())
	.pipe(gulpif(config.dev, sourcemaps.write()))
        .pipe(gulp.dest(config.destCSS));
});

gulp.task('build-html', function () {
    return gulp.src(config.srcHtml)
	.pipe(gulp.dest(config.destHtml));
});

gulp.task('build-partials', function () {
    return gulp.src(config.scrPartials)
	.pipe(gulp.dest(config.destPartials));
});

gulp.task('watch', ['build-js',
		    'build-css',
		    'build-html',
		    'build-partials',
		    'connect'],
	  function () {
    watch(config.watchJS, function() {
        gulp.start('build-js');
    });
    watch(config.watchCSS, function() {
        gulp.start('build-css');
    });
    watch(config.watchHtml, function () {
	gulp.start('build-html');
    });
});

gulp.task('connect', function() {
    connect.server({
	root: 'prd',
	port: 8282
  });
});
<|endoftext|>


<commit_before>'use strict';

/*=====================================
=        Default Configuration        =
=====================================*/

// Please use config.js to override these selectively:

var config = {
  dest: 'www',
  minify_images: true,

  vendor: {
    js: [
      './bower_components/jquery/dist/jquery.js',
      './bower_components/modernizr/modernizr.js',
      './bower_components/angular/angular.js',
      './bower_components/angular-route/angular-route.js',
      './bower_components/angular-translate/angular-translate.js',
      './bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js',
      './bower_components/mobile-angular-ui/dist/js/mobile-angular-ui.js',
      './bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
      './bower_components/angular-ui-select/dist/select.js',
      './bower_components/angular-bindonce/bindonce.js',
      './bower_components/waypoints/waypoints.js',
      './bower_components/SHA-1/sha1.js',
      './bower_components/angulartics/src/angulartics.js',
      './bower_components/angulartics/src/angulartics-piwik.js'
    ],

    fonts: [
      './bower_components/font-awesome/fonts/fontawesome-webfont.*',
      './src/fonts/*'
    ]
  },

  swellrt: {
    server : 'http://localhost:9898',
    // user and pass have to be credentials of an existing user in wave server
    user : 'test@local.net',
    pass : 'test',
    // WaveIds have to exist in wave server
    waveId : 'local.net/gen+12345abcde',
    testimoniesWaveId : 'local.net/gen+12345abcde',
    helpWaveId : 'local.net/gen+12345abcde',
    thanksappWaveId : 'local.net/gen+12345abcde',
    chatpadWaveId : 'local.net/gen+12345abcde'
  },

  server: {
    host: '0.0.0.0',
    port: '8000'
  },

  weinre: {
    httpPort:     8001,
    boundHost:    'localhost',
    verbose:      false,
    debug:        false,
    readTimeout:  5,
    deathTimeout: 15
  },

  deploy: {
    origin: 'deploy',
    branch: 'dist'
  }
};

if (require('fs').existsSync('./config.js')) {
  var configFn = require('./config');
  configFn(config);
}

// Use configuration in other modules, such as Karma
module.exports.config = config;

/*-----  End of Configuration  ------*/

/*========================================
=            Requiring stuffs            =
========================================*/

var gulp           = require('gulp'),
  seq            = require('run-sequence'),
  connect        = require('gulp-connect'),
  sass           = require('gulp-sass'),
  uglify         = require('gulp-uglify'),
  sourcemaps     = require('gulp-sourcemaps'),
  cssmin         = require('gulp-cssmin'),
  order          = require('gulp-order'),
  concat         = require('gulp-concat'),
  ignore         = require('gulp-ignore'),
  rimraf         = require('gulp-rimraf'),
  imagemin       = require('gulp-imagemin'),
  pngcrush       = require('imagemin-pngcrush'),
  templateCache  = require('gulp-angular-templatecache'),
  mobilizer      = require('gulp-mobilizer'),
  ngAnnotate     = require('gulp-ng-annotate'),
  replace        = require('gulp-replace'),
  ngFilesort     = require('gulp-angular-filesort'),
  streamqueue    = require('streamqueue'),
  rename         = require('gulp-rename'),
  path           = require('path'),
  jshint         = require('gulp-jshint'),
  karma          = require('karma').server,
  angularProtractor = require('gulp-angular-protractor'),
  ghPages        = require('gulp-gh-pages');

/*================================================
=            Report Errors to Console            =
================================================*/

gulp.on('error', function(e) {
  throw(e);
});

/*=========================================
=            Clean dest folder            =
=========================================*/

gulp.task('clean', function (cb) {
  return gulp.src([
    path.join(config.dest, 'index.html'),
    path.join(config.dest, 'images'),
    path.join(config.dest, 'css'),
    path.join(config.dest, 'js'),
    path.join(config.dest, 'fonts'),
    path.join(config.dest, 'l10n')
  ], { read: false })
 .pipe(rimraf());
});

/*==========================================
=            Start a web server            =
==========================================*/

gulp.task('connect', function() {
if (typeof config.server === 'object') {
  connect.server({
    root: config.dest,
    host: config.server.host,
    port: config.server.port,
    livereload: true
  });
} else {
  throw new Error('Connect is not configured');
}
});

/*==============================================================
=            Setup live reloading on source changes            =
==============================================================*/

gulp.task('livereload', function () {
gulp.src(path.join(config.dest, '*.html'))
  .pipe(connect.reload());
});

/*=====================================
=            Minify images            =
=====================================*/

gulp.task('images', function () {
var stream = gulp.src('src/images/**/*');

if (config.minify_images) {
  stream = stream.pipe(imagemin({
      progressive: true,
      svgoPlugins: [{removeViewBox: false}],
      use: [pngcrush()]
  }));
}

return stream.pipe(gulp.dest(path.join(config.dest, 'images')));
});

/*==================================
=            Copy fonts            =
==================================*/

gulp.task('fonts', function() {
return gulp.src(config.vendor.fonts)
.pipe(gulp.dest(path.join(config.dest, 'fonts')));
});

/*==================================
=            Copy l10n            =
==================================*/

gulp.task('l10n', function() {
  return gulp.src('src/l10n/**/*')
    .pipe(gulp.dest(path.join(config.dest, 'l10n')));
});

/*=================================================
=            Copy html files to dest              =
=================================================*/

gulp.task('html', function() {
  var inject = [];

  if (config.swellrt) {
    inject.push('<script src="'+config.swellrt.server+'/swellrt/swellrt.nocache.js"></script>');
    inject.push('<script>window.swellrtConfig = '+JSON.stringify(config.swellrt)+';</script>');
  }

  if (typeof config.weinre === 'object') {
    inject.push('<script src="http://'+config.weinre.boundHost+':'+config.weinre.httpPort+'/target/target-script-min.js"></script>');
  }

  gulp.src(['src/html/**/*.html'])
  .pipe(replace('<!-- inject:js -->', inject.join('\n    ')))
  .pipe(gulp.dest(config.dest));
});

/*======================================================================
=            Compile, minify, mobilize Sass                            =
======================================================================*/

gulp.task('sass', function () {
  gulp.src('./src/sass/app.sass')
    .pipe(sourcemaps.init())
    .pipe(sass({
        includePaths: [ path.resolve(__dirname, 'src/sass'), path.resolve(__dirname, 'bower_components') ]
      }).on('error', sass.logError))
    .pipe(mobilizer('app.css', {
      'app.css': {
        hover: 'exclude',
        screens: ['0px']
      },
      'hover.css': {
        hover: 'only',
        screens: ['0px']
      }
    }))
    .pipe(cssmin())
    .pipe(rename({suffix: '.min'}))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest(path.join(config.dest, 'css')));
});

/*====================================================================
=                             jshint                                 =
====================================================================*/

gulp.task('jshint', function() {
  return gulp.src('./src/js/**/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'));
});

/*====================================================================
=            Compile and minify js generating source maps            =
====================================================================*/
// - Orders ng deps automatically
// - Precompile templates to ng templateCache

gulp.task('js', function() {
    streamqueue({ objectMode: true },
      gulp.src(config.vendor.js),
      gulp.src('./src/js/**/*.js').pipe(ngFilesort()),
      gulp.src(['src/templates/**/*.html']).pipe(templateCache({ module: 'Pear2Pear' }))
    )
    .pipe(sourcemaps.init())
    .pipe(concat('app.js'))
    .pipe(ngAnnotate())
    .pipe(uglify())
    .pipe(rename({suffix: '.min'}))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(path.join(config.dest, 'js')));
});

/*===================================================================
=            Watch for source changes and rebuild/reload            =
===================================================================*/

gulp.task('watch', function () {
  if (typeof config.server === 'object') {
    gulp.watch([config.dest + '/**/*'], ['livereload']);
  }
  gulp.watch(['./src/html/**/*'], ['html']);
  gulp.watch(['./src/sass/**/*'], ['sass']);
  gulp.watch(['./src/js/**/*', './src/templates/**/*', config.vendor.js], ['jshint', 'js']);
  gulp.watch(['./src/images/**/*'], ['images']);
  gulp.watch(['./src/l10n/**/*'], ['l10n']);
});

/*===================================================
=            Starts a Weinre Server                 =
===================================================*/

gulp.task('weinre', function() {
  if (typeof config.weinre === 'object') {
    var weinre = require('./node_modules/weinre/lib/weinre');
    weinre.run(config.weinre);
  } else {
    throw new Error('Weinre is not configured');
  }
});

/*======================================
=            Build Sequence            =
======================================*/

gulp.task('build', function(done) {
  var tasks = ['html', 'fonts', 'l10n', 'images', 'sass', 'js'];
  seq('clean', tasks, done);
});

/*======================================
=        Unit testing with Karma       =
======================================*/

gulp.task('unit-test', function(done) {
  karma.start({
    configFile: __dirname + '/test/karma.conf.js',
    singleRun: true
  }, done);
});

/*================================================
=        End to end testing with protractor      =
=================================================*/

gulp.task('e2e-test', function(done) {
  gulp.src(['./test/e2e/**/*.js'])
    .pipe(angularProtractor({
      'configFile': 'test/protractor.conf.js',
      'args': ['--baseUrl', 'http://127.0.0.1:8000'],
      'autoStartStopServer': true,
      'debug': true
    }))
    .on('error', function(e) { throw e })
});

/*====================================
=              Test Task             =
====================================*/

gulp.task('test', function(done){
  seq('unit-test', 'e2e-test', done);
});

/*====================================
=              Deploy Task           =
====================================*/

gulp.task('deploy', function(done) {
  return gulp.src('./www/**/*')
    .pipe(ghPages(config.deploy));
});

/*============================================
=         Continous Delivery Task            =
============================================*/

gulp.task('ci', function(done) {
  seq('build', 'test', 'deploy', done);
});

/*====================================
=            Default Task            =
====================================*/

gulp.task('default', function(done){
  var tasks = [];

  if (typeof config.weinre === 'object') {
    tasks.push('weinre');
  }

  if (typeof config.server === 'object') {
    tasks.push('connect');
  }

  tasks.push('watch');

  seq('build', tasks, done);
});
<commit_msg>Fix cd gulp task name<commit_after>'use strict';

/*=====================================
=        Default Configuration        =
=====================================*/

// Please use config.js to override these selectively:

var config = {
  dest: 'www',
  minify_images: true,

  vendor: {
    js: [
      './bower_components/jquery/dist/jquery.js',
      './bower_components/modernizr/modernizr.js',
      './bower_components/angular/angular.js',
      './bower_components/angular-route/angular-route.js',
      './bower_components/angular-translate/angular-translate.js',
      './bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js',
      './bower_components/mobile-angular-ui/dist/js/mobile-angular-ui.js',
      './bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
      './bower_components/angular-ui-select/dist/select.js',
      './bower_components/angular-bindonce/bindonce.js',
      './bower_components/waypoints/waypoints.js',
      './bower_components/SHA-1/sha1.js',
      './bower_components/angulartics/src/angulartics.js',
      './bower_components/angulartics/src/angulartics-piwik.js'
    ],

    fonts: [
      './bower_components/font-awesome/fonts/fontawesome-webfont.*',
      './src/fonts/*'
    ]
  },

  swellrt: {
    server : 'http://localhost:9898',
    // user and pass have to be credentials of an existing user in wave server
    user : 'test@local.net',
    pass : 'test',
    // WaveIds have to exist in wave server
    waveId : 'local.net/gen+12345abcde',
    testimoniesWaveId : 'local.net/gen+12345abcde',
    helpWaveId : 'local.net/gen+12345abcde',
    thanksappWaveId : 'local.net/gen+12345abcde',
    chatpadWaveId : 'local.net/gen+12345abcde'
  },

  server: {
    host: '0.0.0.0',
    port: '8000'
  },

  weinre: {
    httpPort:     8001,
    boundHost:    'localhost',
    verbose:      false,
    debug:        false,
    readTimeout:  5,
    deathTimeout: 15
  },

  deploy: {
    origin: 'deploy',
    branch: 'dist'
  }
};

if (require('fs').existsSync('./config.js')) {
  var configFn = require('./config');
  configFn(config);
}

// Use configuration in other modules, such as Karma
module.exports.config = config;

/*-----  End of Configuration  ------*/

/*========================================
=            Requiring stuffs            =
========================================*/

var gulp           = require('gulp'),
  seq            = require('run-sequence'),
  connect        = require('gulp-connect'),
  sass           = require('gulp-sass'),
  uglify         = require('gulp-uglify'),
  sourcemaps     = require('gulp-sourcemaps'),
  cssmin         = require('gulp-cssmin'),
  order          = require('gulp-order'),
  concat         = require('gulp-concat'),
  ignore         = require('gulp-ignore'),
  rimraf         = require('gulp-rimraf'),
  imagemin       = require('gulp-imagemin'),
  pngcrush       = require('imagemin-pngcrush'),
  templateCache  = require('gulp-angular-templatecache'),
  mobilizer      = require('gulp-mobilizer'),
  ngAnnotate     = require('gulp-ng-annotate'),
  replace        = require('gulp-replace'),
  ngFilesort     = require('gulp-angular-filesort'),
  streamqueue    = require('streamqueue'),
  rename         = require('gulp-rename'),
  path           = require('path'),
  jshint         = require('gulp-jshint'),
  karma          = require('karma').server,
  angularProtractor = require('gulp-angular-protractor'),
  ghPages        = require('gulp-gh-pages');

/*================================================
=            Report Errors to Console            =
================================================*/

gulp.on('error', function(e) {
  throw(e);
});

/*=========================================
=            Clean dest folder            =
=========================================*/

gulp.task('clean', function (cb) {
  return gulp.src([
    path.join(config.dest, 'index.html'),
    path.join(config.dest, 'images'),
    path.join(config.dest, 'css'),
    path.join(config.dest, 'js'),
    path.join(config.dest, 'fonts'),
    path.join(config.dest, 'l10n')
  ], { read: false })
 .pipe(rimraf());
});

/*==========================================
=            Start a web server            =
==========================================*/

gulp.task('connect', function() {
if (typeof config.server === 'object') {
  connect.server({
    root: config.dest,
    host: config.server.host,
    port: config.server.port,
    livereload: true
  });
} else {
  throw new Error('Connect is not configured');
}
});

/*==============================================================
=            Setup live reloading on source changes            =
==============================================================*/

gulp.task('livereload', function () {
gulp.src(path.join(config.dest, '*.html'))
  .pipe(connect.reload());
});

/*=====================================
=            Minify images            =
=====================================*/

gulp.task('images', function () {
var stream = gulp.src('src/images/**/*');

if (config.minify_images) {
  stream = stream.pipe(imagemin({
      progressive: true,
      svgoPlugins: [{removeViewBox: false}],
      use: [pngcrush()]
  }));
}

return stream.pipe(gulp.dest(path.join(config.dest, 'images')));
});

/*==================================
=            Copy fonts            =
==================================*/

gulp.task('fonts', function() {
return gulp.src(config.vendor.fonts)
.pipe(gulp.dest(path.join(config.dest, 'fonts')));
});

/*==================================
=            Copy l10n            =
==================================*/

gulp.task('l10n', function() {
  return gulp.src('src/l10n/**/*')
    .pipe(gulp.dest(path.join(config.dest, 'l10n')));
});

/*=================================================
=            Copy html files to dest              =
=================================================*/

gulp.task('html', function() {
  var inject = [];

  if (config.swellrt) {
    inject.push('<script src="'+config.swellrt.server+'/swellrt/swellrt.nocache.js"></script>');
    inject.push('<script>window.swellrtConfig = '+JSON.stringify(config.swellrt)+';</script>');
  }

  if (typeof config.weinre === 'object') {
    inject.push('<script src="http://'+config.weinre.boundHost+':'+config.weinre.httpPort+'/target/target-script-min.js"></script>');
  }

  gulp.src(['src/html/**/*.html'])
  .pipe(replace('<!-- inject:js -->', inject.join('\n    ')))
  .pipe(gulp.dest(config.dest));
});

/*======================================================================
=            Compile, minify, mobilize Sass                            =
======================================================================*/

gulp.task('sass', function () {
  gulp.src('./src/sass/app.sass')
    .pipe(sourcemaps.init())
    .pipe(sass({
        includePaths: [ path.resolve(__dirname, 'src/sass'), path.resolve(__dirname, 'bower_components') ]
      }).on('error', sass.logError))
    .pipe(mobilizer('app.css', {
      'app.css': {
        hover: 'exclude',
        screens: ['0px']
      },
      'hover.css': {
        hover: 'only',
        screens: ['0px']
      }
    }))
    .pipe(cssmin())
    .pipe(rename({suffix: '.min'}))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest(path.join(config.dest, 'css')));
});

/*====================================================================
=                             jshint                                 =
====================================================================*/

gulp.task('jshint', function() {
  return gulp.src('./src/js/**/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'));
});

/*====================================================================
=            Compile and minify js generating source maps            =
====================================================================*/
// - Orders ng deps automatically
// - Precompile templates to ng templateCache

gulp.task('js', function() {
    streamqueue({ objectMode: true },
      gulp.src(config.vendor.js),
      gulp.src('./src/js/**/*.js').pipe(ngFilesort()),
      gulp.src(['src/templates/**/*.html']).pipe(templateCache({ module: 'Pear2Pear' }))
    )
    .pipe(sourcemaps.init())
    .pipe(concat('app.js'))
    .pipe(ngAnnotate())
    .pipe(uglify())
    .pipe(rename({suffix: '.min'}))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(path.join(config.dest, 'js')));
});

/*===================================================================
=            Watch for source changes and rebuild/reload            =
===================================================================*/

gulp.task('watch', function () {
  if (typeof config.server === 'object') {
    gulp.watch([config.dest + '/**/*'], ['livereload']);
  }
  gulp.watch(['./src/html/**/*'], ['html']);
  gulp.watch(['./src/sass/**/*'], ['sass']);
  gulp.watch(['./src/js/**/*', './src/templates/**/*', config.vendor.js], ['jshint', 'js']);
  gulp.watch(['./src/images/**/*'], ['images']);
  gulp.watch(['./src/l10n/**/*'], ['l10n']);
});

/*===================================================
=            Starts a Weinre Server                 =
===================================================*/

gulp.task('weinre', function() {
  if (typeof config.weinre === 'object') {
    var weinre = require('./node_modules/weinre/lib/weinre');
    weinre.run(config.weinre);
  } else {
    throw new Error('Weinre is not configured');
  }
});

/*======================================
=            Build Sequence            =
======================================*/

gulp.task('build', function(done) {
  var tasks = ['html', 'fonts', 'l10n', 'images', 'sass', 'js'];
  seq('clean', tasks, done);
});

/*======================================
=        Unit testing with Karma       =
======================================*/

gulp.task('unit-test', function(done) {
  karma.start({
    configFile: __dirname + '/test/karma.conf.js',
    singleRun: true
  }, done);
});

/*================================================
=        End to end testing with protractor      =
=================================================*/

gulp.task('e2e-test', function(done) {
  gulp.src(['./test/e2e/**/*.js'])
    .pipe(angularProtractor({
      'configFile': 'test/protractor.conf.js',
      'args': ['--baseUrl', 'http://127.0.0.1:8000'],
      'autoStartStopServer': true,
      'debug': true
    }))
    .on('error', function(e) { throw e })
});

/*====================================
=              Test Task             =
====================================*/

gulp.task('test', function(done){
  seq('unit-test', 'e2e-test', done);
});

/*====================================
=              Deploy Task           =
====================================*/

gulp.task('deploy', function(done) {
  return gulp.src('./www/**/*')
    .pipe(ghPages(config.deploy));
});

/*============================================
=         Continous Delivery Task            =
============================================*/

gulp.task('cd', function(done) {
  seq('build', 'test', 'deploy', done);
});

/*====================================
=            Default Task            =
====================================*/

gulp.task('default', function(done){
  var tasks = [];

  if (typeof config.weinre === 'object') {
    tasks.push('weinre');
  }

  if (typeof config.server === 'object') {
    tasks.push('connect');
  }

  tasks.push('watch');

  seq('build', tasks, done);
});
<|endoftext|>


<commit_before>// Utilities
var fs = require('fs');

// Gulp
var gulp = require('gulp');

// Gulp plugins
var gutil  = require('gulp-util');
var concat = require('gulp-concat');
var header = require('gulp-header');
var autoprefixer = require('gulp-autoprefixer');
var runSequence = require('run-sequence');
var minify = require('gulp-minify-css');
var rename = require('gulp-rename');

// Misc/global vars
var pkg    = JSON.parse(fs.readFileSync('package.json'));
var banner = [
  '@charset "UTF-8";\n',
  '/*!',
  ' * <%= name %> -<%= homepage %>',
  ' * Version - <%= version %>',
  ' * Licensed under the MIT license - http://opensource.org/licenses/MIT',
  ' *',
  ' * Copyright (c) <%= new Date().getFullYear() %> <%= author.name %>',
  ' */\n\n'
].join('\n');
var activatedAnimations = activateAnimations();

// ----------------------------
// Gulp task definitions
// ----------------------------

gulp.task('default', function() {
  runSequence('concatCSS', 'addHeader', 'prefixes', 'minifyCSS');
});

gulp.task('concatCSS', function() {
  return gulp.src(activatedAnimations)
    .pipe(concat('animate.css'))
    .pipe(gulp.dest('./'));
});

gulp.task('addHeader', function() {
  return gulp.src('animate.css')
    .pipe(header(banner, pkg))
    .pipe(gulp.dest('./'));
});

gulp.task('prefixes', function() {
  return gulp.src('animate.css')
    .pipe(autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(gulp.dest('./'));
});

gulp.task('minifyCSS', function() {
  return gulp.src('animate.css')
    .pipe(rename('animate.min.css'))
    .pipe(minify())
    .pipe(gulp.dest('./'));
});

// ----------------------------
// Helpers/functions
// ----------------------------

// Read the config file and return an array of the animations to be activated
function activateAnimations() {
  var categories = JSON.parse(fs.readFileSync('animate-config.json')),
    category, files, file,
    target = [ 'source/_base.css' ],
    count = 0;

  for (category in categories) {
    if (categories.hasOwnProperty(category)) {
      files = categories[category];

      for (file in files) {
        if (files.hasOwnProperty(file) && files[file]) {
          target.push('source/' + category + '/' + file + '.css');
          count += 1;
        }
      }
    }
  }

  if (!count) {
    gutil.log('No animations activated.');
  } else {
    gutil.log(count + (count > 1 ? ' animations' : ' animation') + ' activated.');
  }

  return target;
};
<commit_msg>Remove unnecessary semicolon in gulpfile.js<commit_after>// Utilities
var fs = require('fs');

// Gulp
var gulp = require('gulp');

// Gulp plugins
var gutil  = require('gulp-util');
var concat = require('gulp-concat');
var header = require('gulp-header');
var autoprefixer = require('gulp-autoprefixer');
var runSequence = require('run-sequence');
var minify = require('gulp-minify-css');
var rename = require('gulp-rename');

// Misc/global vars
var pkg    = JSON.parse(fs.readFileSync('package.json'));
var banner = [
  '@charset "UTF-8";\n',
  '/*!',
  ' * <%= name %> -<%= homepage %>',
  ' * Version - <%= version %>',
  ' * Licensed under the MIT license - http://opensource.org/licenses/MIT',
  ' *',
  ' * Copyright (c) <%= new Date().getFullYear() %> <%= author.name %>',
  ' */\n\n'
].join('\n');
var activatedAnimations = activateAnimations();

// ----------------------------
// Gulp task definitions
// ----------------------------

gulp.task('default', function() {
  runSequence('concatCSS', 'addHeader', 'prefixes', 'minifyCSS');
});

gulp.task('concatCSS', function() {
  return gulp.src(activatedAnimations)
    .pipe(concat('animate.css'))
    .pipe(gulp.dest('./'));
});

gulp.task('addHeader', function() {
  return gulp.src('animate.css')
    .pipe(header(banner, pkg))
    .pipe(gulp.dest('./'));
});

gulp.task('prefixes', function() {
  return gulp.src('animate.css')
    .pipe(autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(gulp.dest('./'));
});

gulp.task('minifyCSS', function() {
  return gulp.src('animate.css')
    .pipe(rename('animate.min.css'))
    .pipe(minify())
    .pipe(gulp.dest('./'));
});

// ----------------------------
// Helpers/functions
// ----------------------------

// Read the config file and return an array of the animations to be activated
function activateAnimations() {
  var categories = JSON.parse(fs.readFileSync('animate-config.json')),
    category, files, file,
    target = [ 'source/_base.css' ],
    count = 0;

  for (category in categories) {
    if (categories.hasOwnProperty(category)) {
      files = categories[category];

      for (file in files) {
        if (files.hasOwnProperty(file) && files[file]) {
          target.push('source/' + category + '/' + file + '.css');
          count += 1;
        }
      }
    }
  }

  if (!count) {
    gutil.log('No animations activated.');
  } else {
    gutil.log(count + (count > 1 ? ' animations' : ' animation') + ' activated.');
  }

  return target;
}
<|endoftext|>


<commit_before>const gulp = require('gulp');
const babel = require('gulp-babel');

const paths = {
  scripts: ['src/js/**/*.js']
};

gulp.task('copyjs', () => {
    gulp
        .src(paths.scripts)
        .pipe(babel({
			presets: ['es2015']
		}))
        .pipe(gulp.dest('public/scripts'));
});
<commit_msg>intendation changes<commit_after>const gulp = require('gulp');
const babel = require('gulp-babel');

const paths = {
  scripts: ['src/js/**/*.js']
};

gulp.task('copyjs', () => {
    gulp
        .src(paths.scripts)
        .pipe(babel({
            presets: ['es2015']
        }))
        .pipe(gulp.dest('public/scripts'));
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var gutil = require('gulp-util');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var sourcemaps = require('gulp-sourcemaps');
var Promise = require('bluebird');

var fs = Promise.promisifyAll(require('fs'));
var path = require('path');

// js
var browserify = require('browserify');
var watchify = require('watchify');
var uglify = require('gulp-uglify');
var isogram = require('isogram');
var str = require('string-to-stream');

// css
var less = require('gulp-less');
var postcss = require('gulp-postcss');
var nano = require('cssnano');

// fonts
var flatten = require('gulp-flatten');

// html
var htmlmin = require('gulp-htmlmin');

var PostMonitor = require('./bin/monitorPosts');
var config = require('./config');

var src = 'src/';
var dist = 'dist/';

var watching = false;
var b = watchify(browserify(watchify.args))
  .transform('babelify', {presets: ['es2015', 'react']})
  .add(src+'index.jsx')
  .add(str(isogram({id: 'UA-63592021-1'})))
  .on('log', gutil.log);

function bundle () {
  return b.bundle()
    .on('error', gutil.log.bind(gutil, 'Browserify Error'))
    .pipe(source('index.js'))
    .pipe(buffer())
    .pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file
      // Add transformation tasks to the pipeline here
      .pipe(uglify({compress: {drop_debugger: false}}))
      .on('error', gutil.log)
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(dist))
    .on('end', function () { if (!watching) b.close(); });
};
gulp.task('build-js', bundle);
gulp.task('build-fonts', function () {
  return gulp.src('**/*.{ttf,woff,woff2,eof,svg}')
    .pipe(flatten())
    .pipe(gulp.dest(path.join(dist, 'fonts')));
});
gulp.task('build-css', function () {
  return gulp.src(src+'index.less')
    .pipe(sourcemaps.init())
      // Add transformation tasks to the pipeline here
      .pipe(less())
      .pipe(postcss([nano]))
      .on('error', gutil.log)
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(dist));
});
gulp.task('build-html', ['build-js', 'build-css', 'build-fonts'], function () {
  return gulp.src(src+'index.html')
    .pipe(htmlmin({collapseWhitespace: true, removeComments: true}))
    .pipe(gulp.dest('.'));
});
gulp.task('build', ['build-html']);

gulp.task('before-watch', function () { watching = true; });
gulp.task('watch', ['before-watch', 'build'], function () {
  b.on('update', bundle);
  gulp.watch('**/*.less', ['build-css']);
  gulp.watch('**/*.html', ['build-html']);
});

gulp.task('monitor-posts', function () {
  new PostMonitor(config);
});

gulp.task('default', ['build']);
<commit_msg>style(es6): es6ify gulpfile<commit_after>var gulp = require('gulp')
var gutil = require('gulp-util')
var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer')
var sourcemaps = require('gulp-sourcemaps')
var Promise = require('bluebird')

var fs = Promise.promisifyAll(require('fs'))
var path = require('path')

// js
var browserify = require('browserify')
var watchify = require('watchify')
var uglify = require('gulp-uglify')
var isogram = require('isogram')
var str = require('string-to-stream')

// css
var less = require('gulp-less')
var postcss = require('gulp-postcss')
var nano = require('cssnano')

// fonts
var flatten = require('gulp-flatten')

// html
var htmlmin = require('gulp-htmlmin')

var PostMonitor = require('./bin/monitorPosts')
var config = require('./config')

var src = 'src/'
var dist = 'dist/'

var watching = false
var b = watchify(browserify(watchify.args))
  .transform('babelify', {presets: ['es2015', 'react']})
  .add(src+'index.jsx')
  .add(str(isogram({id: 'UA-63592021-1'})))
  .on('log', gutil.log)

function bundle () {
  return b.bundle()
    .on('error', gutil.log.bind(gutil, 'Browserify Error'))
    .pipe(source('index.js'))
    .pipe(buffer())
    .pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file
      // Add transformation tasks to the pipeline here
      .pipe(uglify({compress: {drop_debugger: false}}))
      .on('error', gutil.log)
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(dist))
    .on('end', () => { if (!watching) b.close() })
}
gulp.task('build-js', bundle)
gulp.task('build-fonts', () => {
  return gulp.src('**/*.{ttf,woff,woff2,eof,svg}')
    .pipe(flatten())
    .pipe(gulp.dest(path.join(dist, 'fonts')))
})
gulp.task('build-css', () => {
  return gulp.src(src+'index.less')
    .pipe(sourcemaps.init())
      // Add transformation tasks to the pipeline here
      .pipe(less())
      .pipe(postcss([nano]))
      .on('error', gutil.log)
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(dist))
})
gulp.task('build-html', ['build-js', 'build-css', 'build-fonts'], () => {
  return gulp.src(src+'index.html')
    .pipe(htmlmin({collapseWhitespace: true, removeComments: true}))
    .pipe(gulp.dest('.'))
})
gulp.task('build', ['build-html'])

gulp.task('before-watch', () => { watching = true })
gulp.task('watch', ['before-watch', 'build'], () => {
  b.on('update', bundle)
  gulp.watch('**/*.less', ['build-css'])
  gulp.watch('**/*.html', ['build-html'])
})

gulp.task('monitor-posts', () => {
  new PostMonitor(config)
})

gulp.task('default', ['build'])
<|endoftext|>


<commit_before>"use strict";

var gulp = require("gulp");
var jshint = require("gulp-jshint");
var jscs = require("gulp-jscs");
var istanbul = require("gulp-istanbul");
var mocha = require("gulp-mocha");

var files = [
    "./compile.js",
    "./mixin.js",
];

var configFiles = [
    "./gulpfile.js",
    "./test/**/*.js",
];

function handleError (error) {
    throw error;
}

gulp.task("jscs", function () {
    return gulp.src(files.concat(configFiles))
        .pipe(jscs("./.jscs.json"))
        .on("error", handleError);
});

gulp.task("jshint", function () {
    return gulp.src(files.concat(configFiles))
        .pipe(jshint())
        .pipe(jshint.reporter("default"))
        .pipe(jshint.reporter("fail"))
        .on("error", handleError);
});

gulp.task("mocha", function (callback) {
    gulp.src(files)
        .pipe(istanbul())
        .on("finish", function () {
            gulp.src(["test/_init.js", "test/**/*Spec.js"])
                .pipe(mocha({ reporter: "spec" }))
                .pipe(istanbul.writeReports({ dir: "./coverage" }))
                .on("end", callback);
        });
});

gulp.task("test", ["jshint", "jscs", "mocha"]);
<commit_msg>Removed manual error handling.<commit_after>"use strict";

var gulp = require("gulp");
var jshint = require("gulp-jshint");
var jscs = require("gulp-jscs");
var istanbul = require("gulp-istanbul");
var mocha = require("gulp-mocha");

var files = [
    "./compile.js",
    "./mixin.js",
];

var configFiles = [
    "./gulpfile.js",
    "./test/**/*.js",
];

gulp.task("jscs", function () {
    return gulp.src(files.concat(configFiles))
        .pipe(jscs("./.jscs.json"));
});

gulp.task("jshint", function () {
    return gulp.src(files.concat(configFiles))
        .pipe(jshint())
        .pipe(jshint.reporter("default"))
        .pipe(jshint.reporter("fail"));
});

gulp.task("mocha", function (callback) {
    gulp.src(files)
        .pipe(istanbul())
        .on("finish", function () {
            gulp.src(["test/_init.js", "test/**/*Spec.js"])
                .pipe(mocha({ reporter: "spec" }))
                .pipe(istanbul.writeReports({ dir: "./coverage" }))
                .on("end", callback);
        });
});

gulp.task("test", ["jshint", "jscs", "mocha"]);
<|endoftext|>


<commit_before>'use strict';

var gulp = require( 'gulp' );
var karma = require( 'karma' ).server;
var jshint = require( 'gulp-jshint' );
var concat = require( 'gulp-concat' );
var uglify = require( 'gulp-uglify' );
var header = require( 'gulp-header' );
var jscs = require( 'gulp-jscs' );
var plato = require( 'plato' );
var exec = require( 'child_process' ).exec;
var pkg = require( './package.json' );

var coreFiles = 'src/**/*.js';
var allFiles = '{test,src}/**/*.js';

function banner() {
  return [
    '/**!',
    ' * <%= pkg.name.replace("@fdaciuk/", "") %> - v<%= pkg.version %>',
    ' * <%= pkg.description %>',
    ' * <%= pkg.homepage %>',
    '',
    ' * <%= new Date( Date.now() ) %>',
    ' * <%= pkg.license %> (c) <%= pkg.author %>',
    '*/',
    ''
  ].join( '\n' );
}

gulp.task( 'lint', function() {
  gulp.src( allFiles )
    .pipe( jshint() )
    .pipe( jshint.reporter( 'default' ) );

  gulp.src( allFiles )
    .pipe( jscs() )
    .on( 'error', function( err ) {
      var ERROR_CODE = 1;
      console.log( err.toString() );
      process.exit( ERROR_CODE );
    });
});

gulp.task( 'uglify', function() {
  gulp.src( coreFiles )
    .pipe( concat( 'ajax.min.js' ) )
    .pipe( uglify() )
    .pipe( header( banner(), { pkg: pkg } ) )
    .pipe( gulp.dest( './dist' ) );
});

gulp.task( 'test', function( done ) {
  karma.start({
    configFile: __dirname + '/karma.conf.js',
    singleRun: true
  }, done );
});

gulp.task( 'webserver', function( done ) {
  require( './api/app' );
  exec( 'pkill -9 python && python -m SimpleHTTPServer 9001', function() {
    console.log( 'Server listen on port 9001' );
    done();
  });
});

gulp.task( 'watch', [ 'test', 'lint' ], function() {
  gulp.watch( '{test,src}/**/*.js', [ 'test', 'lint' ]);
});

gulp.task( 'plato', function( done ) {
  var files = [ coreFiles ];
  var outputDir = './plato';
  var options = { title: '#Ajax' };
  function callback( report ) { done(); };
  plato.inspect( files, outputDir, options, callback );
});

gulp.task( 'deploy', function( done ) {
  console.log( 'Deploying...' );
  var date = new Date( Date.now() );
  var commands = [
    'gulp uglify',
    'git add .',
    'git commit -m "Minifying"',
    'gulp plato',
    'rm -rf .tmp',
    'mkdir .tmp',
    'cd .tmp',
    'git clone git@github.com:reportz/ajax.git ./',
    'cp -R ../coverage ../plato ./',
    'git add -A',
    'git commit -m "Update reports at ' + date + ' "',
    'git push origin gh-pages',
    'cd ../',
    'rm -rf .tmp',
    'git checkout master',
    'git merge dev',
    'git push origin master --tags',
    'npm run publish',
    'git checkout dev'
  ];
  exec( commands.join( ' && ' ), function( err, stdout, stderr ) {
    console.log( 'Done!' );
    if( stdout ) console.log( 'STDOUT:', stdout );
    if( stderr ) console.log( 'STDERR:', stderr );
    if( err ) console.log( 'ERROR:', err );
    process.exit(1);
    done();
  });
});

gulp.task( 'default', [ 'webserver', 'watch' ]);
<commit_msg>Remove command npm publish<commit_after>'use strict';

var gulp = require( 'gulp' );
var karma = require( 'karma' ).server;
var jshint = require( 'gulp-jshint' );
var concat = require( 'gulp-concat' );
var uglify = require( 'gulp-uglify' );
var header = require( 'gulp-header' );
var jscs = require( 'gulp-jscs' );
var plato = require( 'plato' );
var exec = require( 'child_process' ).exec;
var pkg = require( './package.json' );

var coreFiles = 'src/**/*.js';
var allFiles = '{test,src}/**/*.js';

function banner() {
  return [
    '/**!',
    ' * <%= pkg.name.replace("@fdaciuk/", "") %> - v<%= pkg.version %>',
    ' * <%= pkg.description %>',
    ' * <%= pkg.homepage %>',
    '',
    ' * <%= new Date( Date.now() ) %>',
    ' * <%= pkg.license %> (c) <%= pkg.author %>',
    '*/',
    ''
  ].join( '\n' );
}

gulp.task( 'lint', function() {
  gulp.src( allFiles )
    .pipe( jshint() )
    .pipe( jshint.reporter( 'default' ) );

  gulp.src( allFiles )
    .pipe( jscs() )
    .on( 'error', function( err ) {
      var ERROR_CODE = 1;
      console.log( err.toString() );
      process.exit( ERROR_CODE );
    });
});

gulp.task( 'uglify', function() {
  gulp.src( coreFiles )
    .pipe( concat( 'ajax.min.js' ) )
    .pipe( uglify() )
    .pipe( header( banner(), { pkg: pkg } ) )
    .pipe( gulp.dest( './dist' ) );
});

gulp.task( 'test', function( done ) {
  karma.start({
    configFile: __dirname + '/karma.conf.js',
    singleRun: true
  }, done );
});

gulp.task( 'webserver', function( done ) {
  require( './api/app' );
  exec( 'pkill -9 python && python -m SimpleHTTPServer 9001', function() {
    console.log( 'Server listen on port 9001' );
    done();
  });
});

gulp.task( 'watch', [ 'test', 'lint' ], function() {
  gulp.watch( '{test,src}/**/*.js', [ 'test', 'lint' ]);
});

gulp.task( 'plato', function( done ) {
  var files = [ coreFiles ];
  var outputDir = './plato';
  var options = { title: '#Ajax' };
  function callback( report ) { done(); };
  plato.inspect( files, outputDir, options, callback );
});

gulp.task( 'deploy', function( done ) {
  console.log( 'Deploying...' );
  var date = new Date( Date.now() );
  var commands = [
    'gulp uglify',
    'git add .',
    'git commit -m "Minifying"',
    'gulp plato',
    'rm -rf .tmp',
    'mkdir .tmp',
    'cd .tmp',
    'git clone git@github.com:reportz/ajax.git ./',
    'cp -R ../coverage ../plato ./',
    'git add -A',
    'git commit -m "Update reports at ' + date + ' "',
    'git push origin gh-pages',
    'cd ../',
    'rm -rf .tmp',
    'git checkout master',
    'git merge dev',
    'git push origin master --tags',
    'git checkout dev'
  ];
  exec( commands.join( ' && ' ), function( err, stdout, stderr ) {
    console.log( 'Done!' );
    if( stdout ) console.log( 'STDOUT:', stdout );
    if( stderr ) console.log( 'STDERR:', stderr );
    if( err ) console.log( 'ERROR:', err );
    process.exit(1);
    done();
  });
});

gulp.task( 'default', [ 'webserver', 'watch' ]);
<|endoftext|>


<commit_before>var browserify  = require('browserify');
var del         = require('del');
var minimist    = require('minimist');
var gulp        = require('gulp');
var coverage    = require('gulp-coverage');
var jshint      = require('gulp-jshint');
var jsxhint     = require('gulp-jsxhint');
var map         = require('map-stream');
var mocha       = require('gulp-spawn-mocha');
var nodemon     = require('gulp-nodemon');
var stylish     = require('jshint-stylish');
var reactify    = require('reactify');
var react       = require('gulp-react');
var runSequence = require('run-sequence');
var uglify      = require('gulp-uglify');
var sass        = require('gulp-sass');
var source      = require('vinyl-source-stream');
var streamify   = require('gulp-streamify');
var watch       = require('gulp-watch');

var options = minimist(process.argv.slice(2));

/**
 * Runs Mocha tests for the server
 */
gulp.task('test', function () {
  var sources = ['spec/config.js', 'app/**/*.spec.js'];

  options.reporter = 'min';
  options.istanbul = true;
  options.debugBrk = options.debug ? 'debug' : undefined;

  return gulp
    .src(sources)
    .pipe(mocha(options));
});

/**
 * Lints the server
 */
gulp.task('lint-server', function () {
  var sources = ['app/**/*.js', '!app/public/**/*.js'];

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

/**
 * Lints the client
 */
gulp.task('lint-client', function (done) {
  return gulp
    .src(['app/public/**/*.js'])
    .pipe(react())
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish', { verbose: true }))
    .pipe(jshint.reporter('fail'))
    .pipe(done);
});

/**
 * Cleans the dist directory
 */
gulp.task('clean', function (callback) {
  del(['./dist/**/*'], callback);
});

/**
 * Compiles the client javascript
 */
gulp.task('browserify', function () {
  var b = browserify({ debug: true });
  b.transform(reactify);
  b.add('./app/public/app.js');
  b.plugin('minifyify', { map: 'app.js.map', output: __dirname + '/dist/public/app.js.map' });

  return b.bundle()
    .pipe(source('public/app.js'))
    .pipe(gulp.dest('./dist/'));
});

/**
 * Copies the server component to the dist directory
 */
gulp.task('copy-server', function () {
  return gulp
    .src(['./app/**/*', '!./app/public/**/*'])
    .pipe(gulp.dest('./dist/'));
});

/**
 * Copies the client component to the dist directory
 */
gulp.task('copy-client', function () {
  return gulp
    .src(['./app/public/index.html'])
    .pipe(gulp.dest('./dist/public/'));
});

/**
 * Compiles the client SASS
 */
gulp.task('sass', function () {
  return gulp
    .src(['./app/public/main.scss'])
    .pipe(sass({
      outputStyle: 'compress'
    }))
    .pipe(gulp.dest('./dist/public/'));
});

/**
 * Builds the application
 */
gulp.task('build', function (done) {
  runSequence('clean', 'copy-server', 'browserify', 'copy-client', 'sass', done);
});

/**
 * Automatic server reload
 */
gulp.task('nodemon', ['build'], function (done) {
  var called = false;
  return nodemon({
    script: './dist/index.js',
    ext: 'js',
    ignore: ['dist/**/*', 'app/public/**/*']
  }).on('change', ['lint-server', 'copy-server'])
    .on('start', ['watch']);
});

/**
 * Development task
 */
gulp.task('watch', function () {
  gulp.watch(['app/public/**/*.js'], ['browserify']);
  gulp.watch(['app/public/index.html'], ['copy-client']);
  gulp.watch(['app/public/**/*.scss'], ['sass']);
});

/**
 * Default
 */
gulp.task('default', ['nodemon']);<commit_msg>log sass errors to console<commit_after>var browserify  = require('browserify');
var del         = require('del');
var minimist    = require('minimist');
var gulp        = require('gulp');
var coverage    = require('gulp-coverage');
var jshint      = require('gulp-jshint');
var jsxhint     = require('gulp-jsxhint');
var map         = require('map-stream');
var mocha       = require('gulp-spawn-mocha');
var nodemon     = require('gulp-nodemon');
var stylish     = require('jshint-stylish');
var reactify    = require('reactify');
var react       = require('gulp-react');
var runSequence = require('run-sequence');
var uglify      = require('gulp-uglify');
var sass        = require('gulp-sass');
var source      = require('vinyl-source-stream');
var streamify   = require('gulp-streamify');
var watch       = require('gulp-watch');

var options = minimist(process.argv.slice(2));

/**
 * Runs Mocha tests for the server
 */
gulp.task('test', function () {
  var sources = ['spec/config.js', 'app/**/*.spec.js'];

  options.reporter = 'min';
  options.istanbul = true;
  options.debugBrk = options.debug ? 'debug' : undefined;

  return gulp
    .src(sources)
    .pipe(mocha(options));
});

/**
 * Lints the server
 */
gulp.task('lint-server', function () {
  var sources = ['app/**/*.js', '!app/public/**/*.js'];

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

/**
 * Lints the client
 */
gulp.task('lint-client', function (done) {
  return gulp
    .src(['app/public/**/*.js'])
    .pipe(react())
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish', { verbose: true }))
    .pipe(jshint.reporter('fail'))
    .pipe(done);
});

/**
 * Cleans the dist directory
 */
gulp.task('clean', function (callback) {
  del(['./dist/**/*'], callback);
});

/**
 * Compiles the client javascript
 */
gulp.task('browserify', function () {
  var b = browserify({ debug: true });
  b.transform(reactify);
  b.add('./app/public/app.js');
  b.plugin('minifyify', { map: 'app.js.map', output: __dirname + '/dist/public/app.js.map' });

  return b.bundle()
    .pipe(source('public/app.js'))
    .pipe(gulp.dest('./dist/'));
});

/**
 * Copies the server component to the dist directory
 */
gulp.task('copy-server', function () {
  return gulp
    .src(['./app/**/*', '!./app/public/**/*'])
    .pipe(gulp.dest('./dist/'));
});

/**
 * Copies the client component to the dist directory
 */
gulp.task('copy-client', function () {
  return gulp
    .src(['./app/public/index.html'])
    .pipe(gulp.dest('./dist/public/'));
});

/**
 * Compiles the client SASS
 */
gulp.task('sass', function () {
  return gulp
    .src(['./app/public/main.scss'])
    .pipe(sass({
      outputStyle: 'compress',
      errLogToConsole: true
    }))
    .pipe(gulp.dest('./dist/public/'));
});

/**
 * Builds the application
 */
gulp.task('build', function (done) {
  runSequence('clean', 'copy-server', 'browserify', 'copy-client', 'sass', done);
});

/**
 * Automatic server reload
 */
gulp.task('nodemon', ['build'], function (done) {
  var called = false;
  return nodemon({
    script: './dist/index.js',
    ext: 'js',
    ignore: ['dist/**/*', 'app/public/**/*']
  }).on('change', ['lint-server', 'copy-server'])
    .on('start', ['watch']);
});

/**
 * Development task
 */
gulp.task('watch', function () {
  gulp.watch(['app/public/**/*.js'], ['browserify']);
  gulp.watch(['app/public/index.html'], ['copy-client']);
  gulp.watch(['app/public/**/*.scss'], ['sass']);
});

/**
 * Default
 */
gulp.task('default', ['nodemon']);<|endoftext|>


<commit_before>'use strict';

var browserify  = require('browserify');
var gulp        = require('gulp');

var concat    = require('gulp-concat');
var importCss = require('gulp-import-css');
var minifyCss = require('gulp-minify-css');
var nodemon   = require('gulp-nodemon');
var streamify = require('gulp-streamify');
var uglify    = require('gulp-uglify');

var source = require('vinyl-source-stream');

gulp.task('compile-js', function() {
  return browserify('src/js/splash.js')
  .bundle()
  .pipe(source('splash.min.js'))
  .pipe(streamify(uglify()))
  .pipe(gulp.dest('public'));
});

gulp.task('compile-css', function() {
  return gulp.src('src/css/splash.css')
    .pipe(importCss())
    .pipe(concat('splash.min.css'))
    .pipe(minifyCss('splash.min.css'))
    .pipe(gulp.dest('public'));
});

gulp.task('compile', ['compile-js', 'compile-css']);

gulp.task('server', ['compile'], function () {
  return nodemon({
    script: 'server.js',
    ext: 'js css html',
    env: { 'NODE_ENV': 'development' },
    tasks: ['compile']
  });
});
<commit_msg>Updated gulp server task to be more efficient<commit_after>'use strict';

var browserify  = require('browserify');
var gulp        = require('gulp');

var concat    = require('gulp-concat');
var importCss = require('gulp-import-css');
var minifyCss = require('gulp-minify-css');
var nodemon   = require('gulp-nodemon');
var streamify = require('gulp-streamify');
var uglify    = require('gulp-uglify');

var source = require('vinyl-source-stream');

gulp.task('compile-js', function() {
  return browserify('src/js/splash.js')
  .bundle()
  .pipe(source('splash.min.js'))
  .pipe(streamify(uglify()))
  .pipe(gulp.dest('public'));
});

gulp.task('compile-css', function() {
  return gulp.src('src/css/splash.css')
    .pipe(importCss())
    .pipe(concat('splash.min.css'))
    .pipe(minifyCss('splash.min.css'))
    .pipe(gulp.dest('public'));
});

gulp.task('compile', ['compile-js', 'compile-css']);

gulp.task('server', ['compile'], function() {
  gulp.watch('./src/css/*.css', ['compile-css']);
  gulp.watch('./src/js/*.js', ['compile-js']);
  return nodemon({
    script: 'server',
    env: { NODE_ENV: 'development'},
    watch: ['server/**/*.js'],
  });
});
<|endoftext|>


<commit_before>/*eslint-env node*/

'use strict';

var path = require('path');

var browserify = require('browserify');
var eventStream = require('event-stream');
var glob = require('glob');
var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
var rimraf = require('rimraf');
var source = require('vinyl-source-stream');

var plugins = require('gulp-load-plugins')();

var args = require('yargs').argv;

var paths = {
  js: './static/js/**.js',
  jsEntries: './static/js/*.js',
  sass: './static/sass/**.scss',
  python: '**/*.py'
};

// Clean up files
gulp.task('clean', function (cb) {
  rimraf('./build', cb);
});

// Lint JavaScript code
gulp.task('lint-js', function () {
  return gulp.src(paths.js)
    .pipe(plugins.eslint())
    .pipe(plugins.eslint.format());
});

// Lint Python code
gulp.task('lint-python', function () {
  return gulp.src(paths.python)
    .pipe(plugins.shell([
      'flake8 <%= file.path %>',
      'pylint --reports=no <%= file.path %>'
    ]));
});

gulp.task('lint', ['lint-js', 'lint-python']);

// Ensure bower components are installed
gulp.task('bower-install', function () {
  return plugins.bower();
});

// Collect the main files of the installed bower components
gulp.task('bower', ['bower-install'], function () {
  return gulp.src(mainBowerFiles())
    .pipe(gulp.dest('./build/vendor'));
});

// Browserify all of our JavaScript entry points
gulp.task('browserify', function () {
  // XXX: I kind of hate this but couldn't figure out how to start the stream
  // with gulp.src and use the filenames it provides.
  var files = glob.sync(paths.jsEntries);

  var tasks = files.map(function (js) {
    var basename = 'bundle-' + path.basename(js, '.js');

    return browserify(js, {debug: true})
        .plugin('minifyify', {
          map: '/static/js/' + basename + '.map.json',
          output: './build/js/' + basename + '.map.json'
        })
        .bundle()
        .on('error', function (err) {
          console.log(err.toString());

          this.emit('end');
        })
      .pipe(source(basename + '.js'))
      .pipe(gulp.dest('./build/js'))
      .pipe(plugins.if(!args.production, plugins.livereload()));
  });

  return eventStream.concat.apply(null, tasks);
});

// Compile sass files into CSS
gulp.task('sass', function () {
  return gulp.src(paths.sass)
    .pipe(plugins.sass())
    .pipe(gulp.dest('./build/css'))
    .pipe(plugins.if(!args.production, plugins.livereload()));
});

// Run browserify on JS changes, sass on sass changes
gulp.task('watch', function () {
  gulp.watch(paths.js, ['browserify']);
  gulp.watch(paths.sass, ['sass']);
  gulp.watch('./bower.json', ['bower']);
});

// Just build the files in ./build
gulp.task('build', ['bower', 'browserify', 'sass']);

// Build, livereload, and watch
gulp.task('default', ['build', 'watch']);
<commit_msg>Fix whitespace<commit_after>/*eslint-env node*/

'use strict';

var path = require('path');

var browserify = require('browserify');
var eventStream = require('event-stream');
var glob = require('glob');
var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
var rimraf = require('rimraf');
var source = require('vinyl-source-stream');

var plugins = require('gulp-load-plugins')();

var args = require('yargs').argv;

var paths = {
  js: './static/js/**.js',
  jsEntries: './static/js/*.js',
  sass: './static/sass/**.scss',
  python: '**/*.py'
};

// Clean up files
gulp.task('clean', function (cb) {
  rimraf('./build', cb);
});

// Lint JavaScript code
gulp.task('lint-js', function () {
  return gulp.src(paths.js)
    .pipe(plugins.eslint())
    .pipe(plugins.eslint.format());
});

// Lint Python code
gulp.task('lint-python', function () {
  return gulp.src(paths.python)
    .pipe(plugins.shell([
      'flake8 <%= file.path %>',
      'pylint --reports=no <%= file.path %>'
    ]));
});

gulp.task('lint', ['lint-js', 'lint-python']);

// Ensure bower components are installed
gulp.task('bower-install', function () {
  return plugins.bower();
});

// Collect the main files of the installed bower components
gulp.task('bower', ['bower-install'], function () {
  return gulp.src(mainBowerFiles())
    .pipe(gulp.dest('./build/vendor'));
});

// Browserify all of our JavaScript entry points
gulp.task('browserify', function () {
  // XXX: I kind of hate this but couldn't figure out how to start the stream
  // with gulp.src and use the filenames it provides.
  var files = glob.sync(paths.jsEntries);

  var tasks = files.map(function (js) {
    var basename = 'bundle-' + path.basename(js, '.js');

    return browserify(js, {debug: true})
      .plugin('minifyify', {
        map: '/static/js/' + basename + '.map.json',
        output: './build/js/' + basename + '.map.json'
      })
      .bundle()
      .on('error', function (err) {
        console.log(err.toString());

        this.emit('end');
      })
      .pipe(source(basename + '.js'))
      .pipe(gulp.dest('./build/js'))
      .pipe(plugins.if(!args.production, plugins.livereload()));
  });

  return eventStream.concat.apply(null, tasks);
});

// Compile sass files into CSS
gulp.task('sass', function () {
  return gulp.src(paths.sass)
    .pipe(plugins.sass())
    .pipe(gulp.dest('./build/css'))
    .pipe(plugins.if(!args.production, plugins.livereload()));
});

// Run browserify on JS changes, sass on sass changes
gulp.task('watch', function () {
  gulp.watch(paths.js, ['browserify']);
  gulp.watch(paths.sass, ['sass']);
  gulp.watch('./bower.json', ['bower']);
});

// Just build the files in ./build
gulp.task('build', ['bower', 'browserify', 'sass']);

// Build, livereload, and watch
gulp.task('default', ['build', 'watch']);
<|endoftext|>


<commit_before>/******************************************************************************
 * Gulpfile
 * Be sure to run `npm install` for `gulp` and the following tasks to be
 * available from the command line. All tasks are run using `gulp taskName`.
 ******************************************************************************/
var gulp = require('gulp');
var path = require('path');
var config = require('./ionic.config');

/******************************************************************************
 * gulp watch
 * Build the styles, and rebuild when source files change.
 ******************************************************************************/
gulp.task('watch', ['sass', 'fonts'], function(done) {
  var watch = require('gulp-watch');
  var sassFiles = path.join(config.paths.wwwDir, config.paths.appDir, config.paths.appSassWatch);
  watch(sassFiles, function(){
    gulp.start('sass');
  });
});

/******************************************************************************
 * gulp build
 * Build the styles once, without watching for source file changes.
 ******************************************************************************/
gulp.task('build', ['sass', 'fonts'], function(done) {
  gulp.src('app/**/*.html')
      .pipe(gulp.dest('www/build'));
});

/******************************************************************************
 * gulp sass
 * Convert Sass files to a single bundled CSS file. Uses auto-prefixer
 * to automatically add required vendor prefixes when needed.
 ******************************************************************************/
gulp.task('sass', function(){
  var sass = require('gulp-sass');
  var autoprefixer = require('gulp-autoprefixer');

  var sassSrcFiles = [];
  config.paths.appSassSrc.forEach(function(sassSrc) {
    sassSrcFiles.push( path.join(config.paths.appDir, sassSrc) );
  });

  return gulp.src(sassSrcFiles)
    .pipe(sass({
      includePaths: [path.join(config.paths.ionicDir, config.paths.ionicSassDir)],
    }))
    .on('error', function(err){
      console.error(err.message);
      this.emit('end');
    })
    .pipe(autoprefixer(config.autoPrefixerOpts))
    .pipe(gulp.dest(
      path.join(config.paths.wwwDir, config.paths.buildDir, config.paths.buildCSSDir)
    ));
});

/******************************************************************************
 * gulp fonts
 * Copy Ionic font files to build directory.
 ******************************************************************************/
gulp.task('fonts', function() {
  return gulp.src(path.join(config.paths.ionicDir, config.paths.ionicFontFiles))
         .pipe(gulp.dest(path.join(config.paths.wwwDir, config.paths.buildDir, config.paths.buildFontsDir)));
});

/******************************************************************************
 * gulp clean
 * Delete previous build files.
 ******************************************************************************/
gulp.task('clean', function(done) {
  var del = require('del');
  del([config.paths.buildDir], done);
});
<commit_msg>chore(): remove gulpfile<commit_after><|endoftext|>


<commit_before>const
// gulp related
gulp            = require('gulp'),
clean           = require('gulp-clean'),
runSequence     = require('run-sequence'),
browserSync     = require('browser-sync'),
plumber         = require('gulp-plumber'),
gulpif         = require('gulp-if'),
reload          = browserSync.reload,

//images build
svgSprite       = require('gulp-svg-sprite'),
imagemin        = require('gulp-imagemin'),

// javascript build
webpack         = require('webpack-stream'),
sourcemaps      = require('gulp-sourcemaps'),
babel           = require('gulp-babel'),
concat          = require('gulp-concat'),
uglify          = require('gulp-uglify'),
rename          = require('gulp-rename'),

// (post)css
postcss        = require('gulp-postcss'),
precss         = require('precss'),
autoprefixer   = require('autoprefixer'),
lost           = require('lost'),
cssnext        = require('postcss-cssnext'),
purify         = require('gulp-purifycss'),
mqpacker       = require('css-mqpacker'),
cssnano        = require('cssnano'),

htmlmin        = require('gulp-htmlmin'),

config = {

  folders: {
    dev: 'build',
    src: '.',
    prod: 'production',
  },

  assets: {
    js: 'js/*.js',
    css: {
      base: 'css/main.css',
      final: 'style.css',
    },
    imgs: 'img',
    svg: '/**/*.svg',
    copy: [
        '*fonts/*.+(eot|woff|ttf|svg)',
        'root/*.*',
        'html/**/*.html',
        'index.*'
    ]
  },

  webpack: {
    entry: {
      main: "./js/main.js"
    },
    output: {
      filename: "[name].js",
      path: __dirname + "/build",
    }
  },

  babel: {
    presets: ['es2015']
  },

  postcss: {
    dev: [
      precss(),
      cssnext({ browsers: ['last 2 versions']}),
      lost,
      mqpacker
    ],
    prod: [
      autoprefixer({ browsers: ['last 2 versions']}),
      cssnano
    ]
  },

  svgsprite: {
    shape: {
      dimension: { maxWidth: 48, maxHeight: 48},
      spacing: { padding: 4},
      transform: ['svgo']
    },
    mode: {
      symbol: {
        dest: '.',
        sprite: 'icons',
        example: false
      }
    }
  },

  imagemin: {
    optimizationLevel: 7,
    progressive: true,
    interlace: true,
    multipass: true,
  }

};

let production = false;

gulp.task('set-production', () => {
  production = true;
});

gulp.task('css', () => {
  const src = production ? config.folders.dev+'/'+config.assets.css.final : config.folders.src+'/'+config.assets.css.base;
  const dest = production ? config.folders.prod : config.folders.dev;

  return gulp.src(src)
    .pipe(plumber())
    .pipe(gulpif(production, purify([config.folders.dev+'/**/*.js', config.folders.dev+'/**/*.html'])))
    .pipe(gulpif(production, postcss(config.postcss.prod), postcss(config.postcss.dev)))
    .pipe(rename(config.assets.css.final))
    .pipe(gulp.dest(dest))
});

gulp.task('svg', () => {
  const src = production ? `${config.folders.dev}/${config.assets.imgs}/${config.svgsprite.mode.symbol.sprite}.svg` : `${config.folders.src}/${config.assets.imgs}${config.assets.svg}`;
  const dest = production ? config.folders.prod : config.folders.dev;

  return gulp.src(src)
    .pipe(plumber())
    .pipe(gulpif(!production, svgSprite(config.svgsprite)))
    .pipe(gulp.dest(`${dest}/${config.assets.imgs}`));
});

gulp.task('images', () => {
  const src = (production) ? config.folders.dev : config.folders.src;
  const dest = (production) ? config.folders.prod : config.folders.dev;

  return gulp.src(`${src}/${config.assets.imgs}/**/*.+(gif|jpg|png|woff)`)
    .pipe(plumber())
    .pipe(gulpif(production, imagemin(config.imagemin)))
    .pipe(gulp.dest(`${dest}/${config.assets.imgs}`));
});

gulp.task('scripts', () => {
  if (production) {

    return gulp.src(config.folders.dev+'/*.js')
      .pipe(plumber())
      .pipe(uglify({ mangle: true }))
      .pipe(gulp.dest(config.folders.prod));
  } else {

    return gulp.src(config.assets.js)
      .pipe(plumber())
      .pipe(webpack(config.webpack))
      .pipe(sourcemaps.init())
      .pipe(babel(config.babel))
      .pipe(sourcemaps.write('.'))
      .pipe(gulp.dest(config.folders.dev))
      .pipe(reload({ stream: true }));
  }
});

gulp.task('html', () => {
  return gulp.src(`${config.folders.dev}/**/*.html`)
    .pipe(plumber())
    .pipe(htmlmin({collapseWhitespace: true}))
    .pipe(gulp.dest(config.folders.prod));
});

gulp.task('clean', () => {
  const folder = production ? config.folders.prod: config.folders.dev;

  return gulp.src(folder, { read: false })
    .pipe(clean());
});

gulp.task('copy', function () {
  const dest = production ? config.folders.prod : config.folders.dev;

  return gulp.src(config.assets.copy)
    .pipe(plumber())
    .pipe(gulp.dest(dest));
});

gulp.task('serve', () => {
  const base = production ? config.folders.prod : config.folders.dev;

  browserSync.init({
    server: { baseDir: `./${base}/` },
    open: production,
    ghostMode: {
      clicks: production,
      forms: production,
      scroll: false
    }});
});

gulp.task('watch', () => {
   gulp.watch('*css/**/*.css', ['css', reload]);
   gulp.watch(['*js/**/*.js'], ['scripts', reload]);
   gulp.watch(config.assets.copy, ['copy', reload]);
   gulp.watch([config.assets.imgs+'/**/*.+(gif|jpg|png|woff)'], ['images', reload]);
   gulp.watch([config.assets.imgs+'/**/*.svg'], ['svg', reload]);
});

gulp.task('build', (cb) => { runSequence('clean', ['css', 'svg', 'images', 'copy', 'scripts'], cb); });

gulp.task('production', (cb) => { runSequence('build', 'set-production', 'build', 'html', 'serve', cb); });

gulp.task('default', (cb) => {runSequence('build', 'serve', 'watch', cb); });<commit_msg>Production build logic switch fix<commit_after>const
// gulp related
gulp            = require('gulp'),
clean           = require('gulp-clean'),
runSequence     = require('run-sequence'),
browserSync     = require('browser-sync'),
plumber         = require('gulp-plumber'),
gulpif         = require('gulp-if'),
reload          = browserSync.reload,

//images build
svgSprite       = require('gulp-svg-sprite'),
imagemin        = require('gulp-imagemin'),

// javascript build
webpack         = require('webpack-stream'),
sourcemaps      = require('gulp-sourcemaps'),
babel           = require('gulp-babel'),
concat          = require('gulp-concat'),
uglify          = require('gulp-uglify'),
rename          = require('gulp-rename'),

// (post)css
postcss        = require('gulp-postcss'),
precss         = require('precss'),
autoprefixer   = require('autoprefixer'),
lost           = require('lost'),
cssnext        = require('postcss-cssnext'),
purify         = require('gulp-purifycss'),
mqpacker       = require('css-mqpacker'),
cssnano        = require('cssnano'),

htmlmin        = require('gulp-htmlmin'),

config = {

  folders: {
    dev: 'build',
    src: '.',
    prod: 'production',
  },

  assets: {
    js: 'js/*.js',
    css: {
      base: 'css/main.css',
      final: 'style.css',
    },
    imgs: 'img',
    svg: '/**/*.svg',
    copy: [
        '*fonts/*.+(eot|woff|ttf|svg)',
        'root/*.*',
        'html/**/*.html',
        'index.*'
    ]
  },

  webpack: {
    entry: {
      main: "./js/main.js"
    },
    output: {
      filename: "[name].js",
      path: __dirname + "/build",
    }
  },

  babel: {
    presets: ['es2015']
  },

  postcss: {
    dev: [
      precss(),
      cssnext({ browsers: ['last 2 versions']}),
      lost,
      mqpacker
    ],
    prod: [
      autoprefixer({ browsers: ['last 2 versions']}),
      cssnano
    ]
  },

  svgsprite: {
    shape: {
      dimension: { maxWidth: 48, maxHeight: 48},
      spacing: { padding: 4},
      transform: ['svgo']
    },
    mode: {
      symbol: {
        dest: '.',
        sprite: 'icons',
        example: false
      }
    }
  },

  imagemin: {
    optimizationLevel: 7,
    progressive: true,
    interlace: true,
    multipass: true,
  }

};

let production = false;

gulp.task('set-production', () => {
  production = true;
});

gulp.task('css', () => {
  const src = production ? config.folders.dev+'/'+config.assets.css.final : config.folders.src+'/'+config.assets.css.base;
  const dest = production ? config.folders.prod : config.folders.dev;

  return gulp.src(src)
    .pipe(plumber())
    .pipe(gulpif(production, purify([config.folders.dev+'/**/*.js', config.folders.dev+'/**/*.html'])))
    .pipe(gulpif(production, postcss(config.postcss.prod), postcss(config.postcss.dev)))
    .pipe(rename(config.assets.css.final))
    .pipe(gulp.dest(dest))
});

gulp.task('svg', () => {
  const src = production ? `${config.folders.dev}/${config.assets.imgs}/${config.svgsprite.mode.symbol.sprite}.svg` : `${config.folders.src}/${config.assets.imgs}${config.assets.svg}`;
  const dest = production ? config.folders.prod : config.folders.dev;

  return gulp.src(src)
    .pipe(plumber())
    .pipe(gulpif(!production, svgSprite(config.svgsprite)))
    .pipe(gulp.dest(`${dest}/${config.assets.imgs}`));
});

gulp.task('images', () => {
  const src = (production) ? config.folders.dev : config.folders.src;
  const dest = (production) ? config.folders.prod : config.folders.dev;

  return gulp.src(`${src}/${config.assets.imgs}/**/*.+(gif|jpg|png|woff)`)
    .pipe(plumber())
    .pipe(gulpif(production, imagemin(config.imagemin)))
    .pipe(gulp.dest(`${dest}/${config.assets.imgs}`));
});

gulp.task('scripts', () => {
  if (production) {

    return gulp.src(config.folders.dev+'/*.js')
      .pipe(plumber())
      .pipe(uglify({ mangle: true }))
      .pipe(gulp.dest(config.folders.prod));
  } else {

    return gulp.src(config.assets.js)
      .pipe(plumber())
      .pipe(webpack(config.webpack))
      .pipe(sourcemaps.init())
      .pipe(babel(config.babel))
      .pipe(sourcemaps.write('.'))
      .pipe(gulp.dest(config.folders.dev))
      .pipe(reload({ stream: true }));
  }
});

gulp.task('html', () => {
  return gulp.src(`${config.folders.dev}/**/*.html`)
    .pipe(plumber())
    .pipe(htmlmin({collapseWhitespace: true}))
    .pipe(gulp.dest(config.folders.prod));
});

gulp.task('clean', () => {
  const folder = production ? config.folders.prod: config.folders.dev;

  return gulp.src(folder, { read: false })
    .pipe(clean());
});

gulp.task('copy', function () {
  const dest = production ? config.folders.prod : config.folders.dev;

  return gulp.src(config.assets.copy)
    .pipe(plumber())
    .pipe(gulp.dest(dest));
});

gulp.task('serve', () => {
  const base = production ? config.folders.prod : config.folders.dev;

  browserSync.init({
    server: { baseDir: `./${base}/` },
    open: production,
    ghostMode: {
      clicks: !production,
      forms: !production,
      scroll: false
    }});
});

gulp.task('watch', () => {
   gulp.watch('*css/**/*.css', ['css', reload]);
   gulp.watch(['*js/**/*.js'], ['scripts', reload]);
   gulp.watch(config.assets.copy, ['copy', reload]);
   gulp.watch([config.assets.imgs+'/**/*.+(gif|jpg|png|woff)'], ['images', reload]);
   gulp.watch([config.assets.imgs+'/**/*.svg'], ['svg', reload]);
});

gulp.task('build', (cb) => { runSequence('clean', ['css', 'svg', 'images', 'copy', 'scripts'], cb); });

gulp.task('production', (cb) => { runSequence('build', 'set-production', 'build', 'html', 'serve', cb); });

gulp.task('default', (cb) => {runSequence('build', 'serve', 'watch', cb); });
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');

var paths = {
    images: {
        src: 'resources/assets/images/*',
        dest: 'public/assets/images'
    },
    css: {
        src: 'resources/assets/css/*',
        dest: 'public/assets/css'
    }
};

// === IMAGES ===

var images = function( source ) {
    var imagemin = require('gulp-imagemin')({
        progressive: true,
        svgoPlugins: [{ removeViewBox: false }]
    });
    var changed = require('gulp-changed');

    return source
        .pipe( changed( paths.images.dest ))
        .pipe( imagemin )
        .pipe( gulp.dest( paths.images.dest ));
};

gulp.task('images', function() {
    return images( gulp.src( paths.images.src ));
});

// === CSS ===

gulp.task('copy:normalize', function () {
    var changed = require('gulp-changed');
    return gulp.src( 'node_modules/normalize.css/normalize.css' )
        .pipe( changed( paths.css.dest ))
        .pipe( gulp.dest( paths.css.dest ));
});

// === GENERAL ===

gulp.task('watch', function() {
    var watch = require('gulp-watch');
    var plumber = require('gulp-plumber');

    images( gulp.src( paths.images.src )
        .pipe( watch( paths.images.src ))
        .pipe( plumber() )
    );
});

gulp.task('clean', function( callback ) {
    var del = require('del');
    del([
        paths.images.dest
    ], callback);
});
gulp.task('build', ['images', 'copy:normalize']);
gulp.task('build-clean', ['clean'], function() {
    gulp.start( 'build' );
});

gulp.task('default', ['build']);
<commit_msg>clean everything in public/assets<commit_after>'use strict';

var gulp = require('gulp');

var paths = {
    images: {
        src: 'resources/assets/images/*',
        dest: 'public/assets/images'
    },
    css: {
        src: 'resources/assets/css/*',
        dest: 'public/assets/css'
    }
};

// === IMAGES ===

var images = function( source ) {
    var imagemin = require('gulp-imagemin')({
        progressive: true,
        svgoPlugins: [{ removeViewBox: false }]
    });
    var changed = require('gulp-changed');

    return source
        .pipe( changed( paths.images.dest ))
        .pipe( imagemin )
        .pipe( gulp.dest( paths.images.dest ));
};

gulp.task('images', function() {
    return images( gulp.src( paths.images.src ));
});

// === CSS ===

gulp.task('copy:normalize', function () {
    var changed = require('gulp-changed');
    return gulp.src( 'node_modules/normalize.css/normalize.css' )
        .pipe( changed( paths.css.dest ))
        .pipe( gulp.dest( paths.css.dest ));
});

// === GENERAL ===

gulp.task('watch', function() {
    var watch = require('gulp-watch');
    var plumber = require('gulp-plumber');

    images( gulp.src( paths.images.src )
        .pipe( watch( paths.images.src ))
        .pipe( plumber() )
    );
});

gulp.task('clean', function( callback ) {
    var del = require('del');
    del([
        'public/assets'
    ], callback);
});
gulp.task('build', ['images', 'copy:normalize']);
gulp.task('build-clean', ['clean'], function() {
    gulp.start( 'build' );
});

gulp.task('default', ['build']);
<|endoftext|>


<commit_before>var fs = require('fs'),
	gulp = require('gulp'),
	size = require('gulp-sizereport'),
	jshint = require('gulp-jshint'),
	uglify = require('gulp-uglify'),
	resolve = require('resolve'),
	rename = require('gulp-rename'),
	replace = require('gulp-replace'),
	merge = require('merge2'),
	shell = require('gulp-shell'),
	browserify = require('browserify'),
	resolve = require('resolve'),
	through2 = require('through2'),
	_ = require('lodash');

// ======================================== gulp version

gulp.task('version', function() {

	var streams = merge(),
		version = fs.readFileSync('./src/qwest.js', {encoding: 'utf8'}).match(/^\/\*\! \w+ ([0-9.]+)/)[1];

	streams.add(
		gulp.src( './package.json' )
			.pipe( replace(/"version": "[0-9.]+",/, '"version": "'+version+'",') )
			.pipe( gulp.dest('.') )
	);

	streams.add(
		gulp.src( './README.md' )
			.pipe( replace(/^(\w+) [0-9.]+/, '$1 '+version) )
			.pipe( gulp.dest('.') )
	);

	return streams;

});

// ======================================== gulp lint

gulp.task('lint', function() {

	return gulp.src( './src/qwest.js' )
		.pipe( jshint() )
		.pipe( jshint.reporter('jshint-stylish') );

});

// ======================================== gulp build

gulp.task('build', ['version', 'lint'], function() {

	/*
		https://www.npmjs.com/package/derequire
		https://github.com/substack/webworkify
	*/

	return gulp.src( './src/qwest.js' )
				.pipe( size() )
				.pipe( through2.obj(function(file, enc, next) {

					var b = browserify(null, {standalone: 'qwest'});

					(_.keys(require('./package.json').dependencies) || []).forEach(function(name) {
						b.add(resolve.sync(name, {moduleDirectory: './node_modules/'}));
					});

					b.require('./src/qwest.js', {expose: 'qwest'});

					b.bundle(function(err, res) {
						file.contents = res;
						next(null, file);
					});

				}) )
				//.pipe( uglify() )
				.pipe( rename('qwest.min.js') )
				.pipe( gulp.dest('.') )
				.pipe( size({gzip:true}) );

});

// ======================================== gulp publish

gulp.task('publish', function() {

	return gulp.src('.', {read: false})
				.pipe(shell([
					'npm publish',
					'jam publish'
				]));

});

// ======================================== gulp

gulp.task('default', ['build']);
<commit_msg>Update gulpfile<commit_after>var fs = require('fs'),
	gulp = require('gulp'),
	size = require('gulp-sizereport'),
	jshint = require('gulp-jshint'),
	uglify = require('gulp-uglify'),
	resolve = require('resolve'),
	rename = require('gulp-rename'),
	replace = require('gulp-replace'),
	merge = require('merge2'),
	shell = require('gulp-shell'),
	browserify = require('browserify'),
	resolve = require('resolve'),
	through2 = require('through2'),
	_ = require('lodash');

var name = 'imagine';

// ======================================== gulp version

gulp.task('version', function() {

	var streams = merge(),
		version = fs.readFileSync('./src/'+name+'.js', {encoding: 'utf8'}).match(/^\/\*\! \w+ ([0-9.]+)/)[1];

	streams.add(
		gulp.src( './package.json' )
			.pipe( replace(/"version": "[0-9.]+",/, '"version": "'+version+'",') )
			.pipe( gulp.dest('.') )
	);

	streams.add(
		gulp.src( './README.md' )
			.pipe( replace(/^(\w+) [0-9.]+/, '$1 '+version) )
			.pipe( gulp.dest('.') )
	);

	return streams;

});

// ======================================== gulp lint

gulp.task('lint', function() {

	return gulp.src( './src/'+name+'.js' )
		.pipe( jshint() )
		.pipe( jshint.reporter('jshint-stylish') );

});

// ======================================== gulp build

gulp.task('build', ['version', 'lint'], function() {

	return gulp.src( './src/'+name+'.js' )
				.pipe( size() )
				.pipe( through2.obj(function(file, enc, next) {

					var b = browserify(null, {standalone: name});

					(_.keys(require('./package.json').dependencies) || []).forEach(function(name) {
						b.add(resolve.sync(name, {moduleDirectory: './node_modules/'}));
					});

					b.require('./src/'+name+'.js', {expose: name});

					b.bundle(function(err, res) {
						file.contents = res;
						next(null, file);
					});

				}) )
				//.pipe( uglify() )
				.pipe( rename(name+'.min.js') )
				.pipe( gulp.dest('.') )
				.pipe( size({gzip:true}) );

});

// ======================================== gulp publish

gulp.task('publish', function() {

	return gulp.src('.', {read: false})
				.pipe(shell([
					'npm publish',
					'jam publish'
				]));

});

// ======================================== gulp

gulp.task('default', ['build']);
<|endoftext|>


<commit_before>/*
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/

'use strict';

// 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 reload = browserSync.reload;
var merge = require('merge-stream');
var path = require('path');
var fs = require('fs');
var glob = require('glob');
var historyApiFallback = require('connect-history-api-fallback');

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

var styleTask = function (stylesPath, srcs) {
  return gulp.src(srcs.map(function(src) {
      return path.join('app', stylesPath, src);
    }))
    .pipe($.changed(stylesPath, {extension: '.css'}))
    .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
    .pipe(gulp.dest('.tmp/' + stylesPath))
    .pipe($.if('*.css', $.cssmin()))
    .pipe(gulp.dest('dist/' + stylesPath))
    .pipe($.size({title: stylesPath}));
};

// Compile and Automatically Prefix Stylesheets
gulp.task('styles', function () {
  return styleTask('styles', ['**/*.css']);
});

gulp.task('elements', function () {
  return styleTask('elements', ['**/*.css']);
});

// Lint JavaScript
gulp.task('jshint', function () {
  return gulp.src([
      'app/scripts/**/*.js',
      'app/elements/**/*.js',
      'app/elements/**/*.html'
    ])
    .pipe(reload({stream: true, once: true}))
    .pipe($.jshint.extract()) // Extract JS from .html files
    .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('dist/images'))
    .pipe($.size({title: 'images'}));
});

// Copy All Files At The Root Level (app)
gulp.task('copy', function () {
  var app = gulp.src([
    'app/*',
    '!app/test',
    '!app/precache.json'
  ], {
    dot: true
  }).pipe(gulp.dest('dist'));

  var bower = gulp.src([
    'bower_components/**/*'
  ]).pipe(gulp.dest('dist/bower_components'));

  var elements = gulp.src(['app/elements/**/*.html'])
    .pipe(gulp.dest('dist/elements'));

  var swBootstrap = gulp.src(['bower_components/platinum-sw/bootstrap/*.js'])
    .pipe(gulp.dest('dist/elements/bootstrap'));

  var swToolbox = gulp.src(['bower_components/sw-toolbox/*.js'])
    .pipe(gulp.dest('dist/sw-toolbox'));

  var vulcanized = gulp.src(['app/elements/elements.html'])
    .pipe($.rename('elements.vulcanized.html'))
    .pipe(gulp.dest('dist/elements'));

  return merge(app, bower, elements, vulcanized, swBootstrap, swToolbox)
    .pipe($.size({title: 'copy'}));
});

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

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

  return gulp.src(['app/**/*.html', '!app/{elements,test}/**/*.html'])
    // Replace path for vulcanized assets
    .pipe($.if('*.html', $.replace('elements/elements.html', 'elements/elements.vulcanized.html')))
    .pipe(assets)
    // Concatenate And Minify JavaScript
    .pipe($.if('*.js', $.uglify({preserveComments: 'some'})))
    // Concatenate And Minify Styles
    // In case you are still using useref build blocks
    .pipe($.if('*.css', $.cssmin()))
    .pipe(assets.restore())
    .pipe($.useref())
    // Minify Any HTML
    .pipe($.if('*.html', $.minifyHtml({
      quotes: true,
      empty: true,
      spare: true
    })))
    // Output Files
    .pipe(gulp.dest('dist'))
    .pipe($.size({title: 'html'}));
});

// Vulcanize imports
gulp.task('vulcanize', function () {
  var DEST_DIR = 'dist/elements';

  return gulp.src('dist/elements/elements.vulcanized.html')
    .pipe($.vulcanize({
      stripComments: true,
      inlineCss: true,
      inlineScripts: true
    }))
    .pipe(gulp.dest(DEST_DIR))
    .pipe($.size({title: 'vulcanize'}));
});

// Generate a list of files that should be precached when serving from 'dist'.
// The list will be consumed by the <platinum-sw-cache> element.
gulp.task('precache', function (callback) {
  var dir = 'dist';

  glob('{elements,scripts,styles}/**/*.*', {cwd: dir}, function(error, files) {
    if (error) {
      callback(error);
    } else {
      files.push('index.html', './', 'bower_components/webcomponentsjs/webcomponents-lite.min.js');
      var filePath = path.join(dir, 'precache.json');
      fs.writeFile(filePath, JSON.stringify(files), callback);
    }
  });
});

// Clean Output Directory
gulp.task('clean', del.bind(null, ['.tmp', 'dist']));

// Watch Files For Changes & Reload
gulp.task('serve', ['styles', 'elements', 'images'], function () {
  browserSync({
    notify: false,
    logPrefix: 'PSK',
    snippetOptions: {
      rule: {
        match: '',
        fn: function (snippet) {
          return snippet;
        }
      }
    },
    // 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: {
      baseDir: ['.tmp', 'app'],
      middleware: [ historyApiFallback() ],
      routes: {
        '/bower_components': 'bower_components'
      }
    }
  });

  gulp.watch(['app/**/*.html'], reload);
  gulp.watch(['app/styles/**/*.css'], ['styles', reload]);
  gulp.watch(['app/elements/**/*.css'], ['elements', reload]);
  gulp.watch(['app/{scripts,elements}/**/*.js'], ['jshint']);
  gulp.watch(['app/images/**/*'], reload);
});

// Build and serve the output from the dist build
gulp.task('serve:dist', ['default'], function () {
  browserSync({
    notify: false,
    logPrefix: 'PSK',
    snippetOptions: {
      rule: {
        match: '',
        fn: function (snippet) {
          return snippet;
        }
      }
    },
    // 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: 'dist',
    middleware: [ historyApiFallback() ]
  });
});

// Build Production Files, the Default Task
gulp.task('default', ['clean'], function (cb) {
  runSequence(
    ['copy', 'styles'],
    'elements',
    ['jshint', 'images', 'fonts', 'html'],
    'vulcanize',
    cb);
    // Note: add , 'precache' , after 'vulcanize', if your are going to use Service Worker
});

// Load tasks for web-component-tester
// Adds tasks for `gulp test:local` and `gulp test:remote`
require('web-component-tester').gulp.init(gulp);

// Load custom tasks from the `tasks` directory
try { require('require-dir')('tasks'); } catch (err) {}
<commit_msg>Gulpfile: add callback to `clean` task<commit_after>/*
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/

'use strict';

// 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 reload = browserSync.reload;
var merge = require('merge-stream');
var path = require('path');
var fs = require('fs');
var glob = require('glob');
var historyApiFallback = require('connect-history-api-fallback');

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

var styleTask = function (stylesPath, srcs) {
  return gulp.src(srcs.map(function(src) {
      return path.join('app', stylesPath, src);
    }))
    .pipe($.changed(stylesPath, {extension: '.css'}))
    .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
    .pipe(gulp.dest('.tmp/' + stylesPath))
    .pipe($.if('*.css', $.cssmin()))
    .pipe(gulp.dest('dist/' + stylesPath))
    .pipe($.size({title: stylesPath}));
};

// Compile and Automatically Prefix Stylesheets
gulp.task('styles', function () {
  return styleTask('styles', ['**/*.css']);
});

gulp.task('elements', function () {
  return styleTask('elements', ['**/*.css']);
});

// Lint JavaScript
gulp.task('jshint', function () {
  return gulp.src([
      'app/scripts/**/*.js',
      'app/elements/**/*.js',
      'app/elements/**/*.html'
    ])
    .pipe(reload({stream: true, once: true}))
    .pipe($.jshint.extract()) // Extract JS from .html files
    .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('dist/images'))
    .pipe($.size({title: 'images'}));
});

// Copy All Files At The Root Level (app)
gulp.task('copy', function () {
  var app = gulp.src([
    'app/*',
    '!app/test',
    '!app/precache.json'
  ], {
    dot: true
  }).pipe(gulp.dest('dist'));

  var bower = gulp.src([
    'bower_components/**/*'
  ]).pipe(gulp.dest('dist/bower_components'));

  var elements = gulp.src(['app/elements/**/*.html'])
    .pipe(gulp.dest('dist/elements'));

  var swBootstrap = gulp.src(['bower_components/platinum-sw/bootstrap/*.js'])
    .pipe(gulp.dest('dist/elements/bootstrap'));

  var swToolbox = gulp.src(['bower_components/sw-toolbox/*.js'])
    .pipe(gulp.dest('dist/sw-toolbox'));

  var vulcanized = gulp.src(['app/elements/elements.html'])
    .pipe($.rename('elements.vulcanized.html'))
    .pipe(gulp.dest('dist/elements'));

  return merge(app, bower, elements, vulcanized, swBootstrap, swToolbox)
    .pipe($.size({title: 'copy'}));
});

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

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

  return gulp.src(['app/**/*.html', '!app/{elements,test}/**/*.html'])
    // Replace path for vulcanized assets
    .pipe($.if('*.html', $.replace('elements/elements.html', 'elements/elements.vulcanized.html')))
    .pipe(assets)
    // Concatenate And Minify JavaScript
    .pipe($.if('*.js', $.uglify({preserveComments: 'some'})))
    // Concatenate And Minify Styles
    // In case you are still using useref build blocks
    .pipe($.if('*.css', $.cssmin()))
    .pipe(assets.restore())
    .pipe($.useref())
    // Minify Any HTML
    .pipe($.if('*.html', $.minifyHtml({
      quotes: true,
      empty: true,
      spare: true
    })))
    // Output Files
    .pipe(gulp.dest('dist'))
    .pipe($.size({title: 'html'}));
});

// Vulcanize imports
gulp.task('vulcanize', function () {
  var DEST_DIR = 'dist/elements';

  return gulp.src('dist/elements/elements.vulcanized.html')
    .pipe($.vulcanize({
      stripComments: true,
      inlineCss: true,
      inlineScripts: true
    }))
    .pipe(gulp.dest(DEST_DIR))
    .pipe($.size({title: 'vulcanize'}));
});

// Generate a list of files that should be precached when serving from 'dist'.
// The list will be consumed by the <platinum-sw-cache> element.
gulp.task('precache', function (callback) {
  var dir = 'dist';

  glob('{elements,scripts,styles}/**/*.*', {cwd: dir}, function(error, files) {
    if (error) {
      callback(error);
    } else {
      files.push('index.html', './', 'bower_components/webcomponentsjs/webcomponents-lite.min.js');
      var filePath = path.join(dir, 'precache.json');
      fs.writeFile(filePath, JSON.stringify(files), callback);
    }
  });
});

// Clean Output Directory
gulp.task('clean', function (cb) {
  del(['.tmp', 'dist'], cb);
});

// Watch Files For Changes & Reload
gulp.task('serve', ['styles', 'elements', 'images'], function () {
  browserSync({
    notify: false,
    logPrefix: 'PSK',
    snippetOptions: {
      rule: {
        match: '',
        fn: function (snippet) {
          return snippet;
        }
      }
    },
    // 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: {
      baseDir: ['.tmp', 'app'],
      middleware: [ historyApiFallback() ],
      routes: {
        '/bower_components': 'bower_components'
      }
    }
  });

  gulp.watch(['app/**/*.html'], reload);
  gulp.watch(['app/styles/**/*.css'], ['styles', reload]);
  gulp.watch(['app/elements/**/*.css'], ['elements', reload]);
  gulp.watch(['app/{scripts,elements}/**/*.js'], ['jshint']);
  gulp.watch(['app/images/**/*'], reload);
});

// Build and serve the output from the dist build
gulp.task('serve:dist', ['default'], function () {
  browserSync({
    notify: false,
    logPrefix: 'PSK',
    snippetOptions: {
      rule: {
        match: '',
        fn: function (snippet) {
          return snippet;
        }
      }
    },
    // 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: 'dist',
    middleware: [ historyApiFallback() ]
  });
});

// Build Production Files, the Default Task
gulp.task('default', ['clean'], function (cb) {
  runSequence(
    ['copy', 'styles'],
    'elements',
    ['jshint', 'images', 'fonts', 'html'],
    'vulcanize',
    cb);
    // Note: add , 'precache' , after 'vulcanize', if your are going to use Service Worker
});

// Load tasks for web-component-tester
// Adds tasks for `gulp test:local` and `gulp test:remote`
require('web-component-tester').gulp.init(gulp);

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