<commit_before>/*jslint node: true */
'use strict';

var del          = require('del'),
    gulp         = require('gulp'),
    gulpif       = require('gulp-if'),
    imagemin     = require('gulp-imagemin'),
    jshint       = require('gulp-jshint'),
    karma        = require('karma').server,
    minifyCss    = require('gulp-minify-css'),
    nodemon      = require('gulp-nodemon'),
    rename       = require('gulp-rename'),
    rsync        = require('gulp-rsync'),
    sass         = require('gulp-sass'),
    stylish      = require('jshint-stylish'),
    taskListing  = require('gulp-task-listing'),
    uglify       = require('gulp-uglify'),
    useref       = require('gulp-useref'),
    util         = require('gulp-util'),
    tinylr;

function notifyLiveReload(event) {
  var fileName = require('path').relative(__dirname + '/dist', event.path);
  tinylr.changed({
    body: {
      files: [fileName]
    }
  });
}

gulp.task('help', taskListing);

gulp.task('clean', function() {
    del(['dist/']);
});

// start livereload
gulp.task('livereload', function() {
  tinylr = require('tiny-lr')();
  tinylr.listen(3002);
});

// compile sass in source directory
gulp.task('sass', function () {
  gulp.src(['./src/scss/*.scss'])
  .pipe(sass({ style: 'expanded' }).on('error', sass.logError))
  .pipe(gulp.dest('./src/css'));
});

// install vendor assets in source directory
gulp.task('assets', function() {
  gulp.src('bower_components/**/*.{js,map}')
  .pipe(gulp.dest('src/js/vendor'));
  gulp.src('bower_components/**/modernizr-*.min.js')
  .pipe(rename(function (path) {
    path.dirname  = 'modernizr';
    path.basename = "modernizr.min";
    path.extname  = ".js";
  }))
  .pipe(gulp.dest('src/js/vendor'));
  gulp.src('bower_components/**/*.{css,map}')
  .pipe(gulp.dest('src/css/vendor'));
});

// minify and concatenate linked assets, fix paths in html and install
// to dist directory
gulp.task('html', function () {
  var assets = useref.assets();
  return gulp.src('src/*.html')
  .pipe(assets)
  .pipe(gulpif('*.js', uglify()))
  .pipe(gulpif('*.css', minifyCss()))
  .pipe(assets.restore())
  .pipe(useref())
  .pipe(gulp.dest('dist'));
});

// copy minified vendor libs from source to dist
gulp.task('assets-dist', ['optimize-images-dist'], function() {
  gulp.src('src/css/vendor/**/*.min.css')
  .pipe(gulp.dest('dist/css/vendor'));
  gulp.src('src/js/vendor/**/modernizr-*.min.js')
  .pipe(rename(function (path) {
    path.dirname  = 'modernizr';
    path.basename = "modernizr.min";
    path.extname  = ".js";
  }))
  .pipe(gulp.dest('dist/js/vendor'));
  gulp.src(['src/js/vendor/**/*.min.js', '!src/js/**/test/**'])
  .pipe(gulp.dest('dist/js/vendor'));
});

// optimize images when copying to dist
gulp.task('optimize-images-dist', function() {
  return gulp.src('src/img/**/*.{gif,jpg,png,svg}')
    .pipe(imagemin({
      progressive: true,
      svgoPlugins: [{removeViewBox: false}],
      optimizationLevel: 3
    }))
    .pipe(gulp.dest('dist/img/'));
});

// reload and rebuild from source directory
gulp.task('watch', function() {
  gulp.watch('./src/scss/*.scss', ['sass']);
  gulp.watch('./src/*.html', notifyLiveReload);
  gulp.watch('./src/js/*.js', notifyLiveReload);
  gulp.watch('./src/css/*.css', notifyLiveReload);
});

// preview dist directory
gulp.task('preview', ['dist'], function() {
  var port     = 3033,
      url      = 'http://127.0.0.1:' + port.toString(),
      livePort = 3002,
      docRoot  = 'dist',
      reload   = '';
  util.log('Serving directory', util.colors.magenta(docRoot), 'on', util.colors.magenta(url));
  nodemon({
    script: 'server.js',
    args: ['--harmony', port.toString(), livePort.toString(), docRoot, reload],
    ext: 'js',
    env: { 'NODE_ENV': 'development' }
  });
});

// run dev server
gulp.task('serve', function() {
  var port     = 3000,
      url      = 'http://127.0.0.1:' + port.toString(),
      livePort = 3002,
      docRoot  = 'src',
      reload   = 'reload';
  util.log('Serving directory', util.colors.magenta(docRoot), 'on', util.colors.magenta(url));
  nodemon({
    script: 'server.js',
    args: ['--harmony', port.toString(), livePort.toString(), docRoot, reload],
    ext: 'js',
    env: { 'NODE_ENV': 'development' }
  });
});

// lint javascript
gulp.task('lint', function() {
  return gulp.src([
      'gulpfile.js',
      'server.js',
      'src/js/*.js'
    ]).pipe(jshint())
    .pipe(jshint.reporter(stylish));
});

// run tests once and exit (for ci)
gulp.task('test', function(done) {
  karma.start({
    configFile: __dirname + '/karma.conf.js',
    singleRun: true
  }, function() {
    done();
  });
});

// sync with remote dir
gulp.task('rsync', function() {
  return gulp.src('dist/**/*.*')
  .pipe(rsync({
    root: 'dist',
    username: 'deploy',
    hostname: '1.2.3.4',
    destination: '/srv/www/site/'
  }));
});

// run install pipeline to dist directory (prepare for deployment)
gulp.task('dist', ['sass', 'assets', 'assets-dist', 'html'], function() {});

// default, run dev server with live reload / rebuild
gulp.task('default', ['serve', 'sass', 'lint', 'livereload', 'watch', 'assets'], function() {});
<commit_msg>add build task<commit_after>/*jslint node: true */
'use strict';

var del          = require('del'),
    gulp         = require('gulp'),
    gulpif       = require('gulp-if'),
    imagemin     = require('gulp-imagemin'),
    jshint       = require('gulp-jshint'),
    karma        = require('karma').server,
    minifyCss    = require('gulp-minify-css'),
    nodemon      = require('gulp-nodemon'),
    rename       = require('gulp-rename'),
    rsync        = require('gulp-rsync'),
    sass         = require('gulp-sass'),
    stylish      = require('jshint-stylish'),
    taskListing  = require('gulp-task-listing'),
    uglify       = require('gulp-uglify'),
    useref       = require('gulp-useref'),
    util         = require('gulp-util'),
    tinylr;

function notifyLiveReload(event) {
  var fileName = require('path').relative(__dirname + '/dist', event.path);
  tinylr.changed({
    body: {
      files: [fileName]
    }
  });
}

gulp.task('help', taskListing);

gulp.task('clean', function() {
    del(['dist/']);
});

// start livereload
gulp.task('livereload', function() {
  tinylr = require('tiny-lr')();
  tinylr.listen(3002);
});

// compile sass in source directory
gulp.task('sass', function () {
  gulp.src(['./src/scss/*.scss'])
  .pipe(sass({ style: 'expanded' }).on('error', sass.logError))
  .pipe(gulp.dest('./src/css'));
});

// install vendor assets in source directory
gulp.task('assets', function() {
  gulp.src('bower_components/**/*.{js,map}')
  .pipe(gulp.dest('src/js/vendor'));
  gulp.src('bower_components/**/modernizr-*.min.js')
  .pipe(rename(function (path) {
    path.dirname  = 'modernizr';
    path.basename = "modernizr.min";
    path.extname  = ".js";
  }))
  .pipe(gulp.dest('src/js/vendor'));
  gulp.src('bower_components/**/*.{css,map}')
  .pipe(gulp.dest('src/css/vendor'));
});

// minify and concatenate linked assets, fix paths in html and install
// to dist directory
gulp.task('html', function () {
  var assets = useref.assets();
  return gulp.src('src/*.html')
  .pipe(assets)
  .pipe(gulpif('*.js', uglify()))
  .pipe(gulpif('*.css', minifyCss()))
  .pipe(assets.restore())
  .pipe(useref())
  .pipe(gulp.dest('dist'));
});

// copy minified vendor libs from source to dist
gulp.task('assets-dist', ['optimize-images-dist'], function() {
  gulp.src('src/css/vendor/**/*.min.css')
  .pipe(gulp.dest('dist/css/vendor'));
  gulp.src('src/js/vendor/**/modernizr-*.min.js')
  .pipe(rename(function (path) {
    path.dirname  = 'modernizr';
    path.basename = "modernizr.min";
    path.extname  = ".js";
  }))
  .pipe(gulp.dest('dist/js/vendor'));
  gulp.src(['src/js/vendor/**/*.min.js', '!src/js/**/test/**'])
  .pipe(gulp.dest('dist/js/vendor'));
});

// optimize images when copying to dist
gulp.task('optimize-images-dist', function() {
  return gulp.src('src/img/**/*.{gif,jpg,png,svg}')
    .pipe(imagemin({
      progressive: true,
      svgoPlugins: [{removeViewBox: false}],
      optimizationLevel: 3
    }))
    .pipe(gulp.dest('dist/img/'));
});

// reload and rebuild from source directory
gulp.task('watch', function() {
  gulp.watch('./src/scss/*.scss', ['sass']);
  gulp.watch('./src/*.html', notifyLiveReload);
  gulp.watch('./src/js/*.js', notifyLiveReload);
  gulp.watch('./src/css/*.css', notifyLiveReload);
});

// preview dist directory
gulp.task('preview', ['dist'], function() {
  var port     = 3033,
      url      = 'http://127.0.0.1:' + port.toString(),
      livePort = 3002,
      docRoot  = 'dist',
      reload   = '';
  util.log('Serving directory', util.colors.magenta(docRoot), 'on', util.colors.magenta(url));
  nodemon({
    script: 'server.js',
    args: ['--harmony', port.toString(), livePort.toString(), docRoot, reload],
    ext: 'js',
    env: { 'NODE_ENV': 'development' }
  });
});

// run dev server
gulp.task('serve', function() {
  var port     = 3000,
      url      = 'http://127.0.0.1:' + port.toString(),
      livePort = 3002,
      docRoot  = 'src',
      reload   = 'reload';
  util.log('Serving directory', util.colors.magenta(docRoot), 'on', util.colors.magenta(url));
  nodemon({
    script: 'server.js',
    args: ['--harmony', port.toString(), livePort.toString(), docRoot, reload],
    ext: 'js',
    env: { 'NODE_ENV': 'development' }
  });
});

// lint javascript
gulp.task('lint', function() {
  return gulp.src([
      'gulpfile.js',
      'server.js',
      'src/js/*.js'
    ]).pipe(jshint())
    .pipe(jshint.reporter(stylish));
});

// run tests once and exit (for ci)
gulp.task('test', function(done) {
  karma.start({
    configFile: __dirname + '/karma.conf.js',
    singleRun: true
  }, function() {
    done();
  });
});

// sync with remote dir
gulp.task('rsync', function() {
  return gulp.src('dist/**/*.*')
  .pipe(rsync({
    root: 'dist',
    username: 'deploy',
    hostname: '1.2.3.4',
    destination: '/srv/www/site/'
  }));
});

// run install pipeline to dist directory (prepare for deployment)
gulp.task('dist', ['sass', 'assets', 'assets-dist', 'html'], function() {});

// compile css, copy vendor deps and lint
gulp.task('build', ['sass', 'assets', 'lint'], function() {});

// default, run dev server with live reload / rebuild
gulp.task('default', ['sass', 'lint', 'livereload', 'watch', 'assets', 'serve'], function() {});
<|endoftext|>


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

'use strict';

/* ==========================================================================
   § Gulp Tools
   ========================================================================== */

// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var autoprefixer = require('autoprefixer-core');
var cp = require('child_process');
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var pagespeed = require('psi');
var reload = browserSync.reload;
var path = require('path');

/* ==========================================================================
   § Gulp Variables
   ========================================================================== */

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

var messages = {
    jekyllBuild: 'Running: $ jekyll build'
};

var processors = [
  autoprefixer(AUTOPREFIXER_BROWSERS)
];

/* ==========================================================================
   § Assets
   ========================================================================== */

gulp.task('assets' ,function () {
  var assets = $.useref.assets({searchPath: '.tmp'});

  return gulp.src('.tmp/**/*.html')
    .pipe(assets)
    // Concatenate And Minify JavaScript
    .pipe($.if('*.js', $.uglify({preserveComments: 'some'})))
    // Remove Any Unused CSS
    // Note: If not using the Style Guide, you can delete it from
    // the next line to only include styles your project uses.
    .pipe($.if('*.css', $.uncss({
      html: [
        '.tmp/index.html',
        '.tmp/sign-up/index.html',
        '.tmp/privacy-policy/index.html',
        '.tmp/plans-pricing/index.html',
        '.tmp/terms-of-service/index.html',
        '.tmp/updates/index.html',
        '.tmp/updates/chrome-extension-for-basecamp.html',
        '.tmp/customers/cr-studios/index.html'
      ],
      // CSS Selectors for UnCSS to ignore
      ignore: [
        // for mobile
        /video, embed, object, img, picture/,
        /img/,
        // application styles
        /.app-bar.open/,
        /.ibutton-*/,
        /#header/,

      ]
    })))
    // Concatenate And Minify Styles
    // In case you are still using useref build blocks
    .pipe($.if('*.css', $.csso()))
    .pipe(assets.restore())
    .pipe($.useref())
    // Update Production Style Guide Paths
    //.pipe($.replace('components/components.css', 'components/main.min.css'))
    // Minify Any HTML
    // Output Files
    .pipe(gulp.dest('.tmp'))
    .pipe($.size({title: 'html'}));
});

/*
   §§ Assets - Inline
   ========================================================================== */

gulp.task('assets:inline', function () {
    return gulp.src('./.tmp/**/*.html')
        .pipe($.inlineSource())
        .pipe(gulp.dest('./.tmp'));
});

/* ==========================================================================
   § Bump Versions
   ========================================================================== */

/*
   §§ Bump Major
   ========================================================================== */

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

/*
   §§ Bump Minor
   ========================================================================== */

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

/*
   §§ Bump Patch
   ========================================================================== */

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

/* ==========================================================================
   § Clean
   ========================================================================== */

gulp.task('clean', del.bind(null, ['.tmp', 'dist/*', '!dist/.git']));
gulp.task('clean:gh-pages', del.bind(null, ['.tmp', 'gh-pages/*', '!gh-pages/.git']));

/* ==========================================================================
   § Copy
   ========================================================================== */

gulp.task('copy', function () {
  return gulp.src([
    '.tmp/*',
    '!.tmp/*.html',
    'node_modules/apache-server-configs/dist/.htaccess'
  ], {
    dot: true
  }).pipe(gulp.dest('dist'))
    .pipe($.size({title: 'copy'}));
});

/* ==========================================================================
   § Fonts
   ========================================================================== */

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

/* ==========================================================================
   § Hologram
   ========================================================================== */

gulp.task('hologram', function () {
  gulp.src('hologram/hologram_config.yml')
    .pipe($.hologram({bundler:true, logging:true}));
});

/* ==========================================================================
   § Images
   ========================================================================== */

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

/* ==========================================================================
   § Jekyll
   ========================================================================== */

gulp.task('jekyll', function (done) {
  browserSync.notify(messages.jekyllBuild);
  return cp.spawn('jekyll', ['build', '--config', '_config.yml,_config_dev.yml'], {stdio: 'inherit'})
          .on('close', done);
});

gulp.task('jekyll:production', function (done) {
  browserSync.notify(messages.jekyllBuild);
  return cp.spawn('jekyll', ['build', '--config', '_config.yml'], {stdio: 'inherit'})
          .on('close', done);
});

gulp.task('jekyll:gh-pages', function (done) {
  browserSync.notify(messages.jekyllBuild);
  return cp.spawn('jekyll', ['build', '--config', '_config.yml,_config_ghpages.yml'], {stdio: 'inherit'})
          .on('close', done);
});

gulp.task('jekyll:rebuild', ['jekyll'], function () {
    reload();
});

/* ==========================================================================
   § JSHINT
   ========================================================================== */

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

/* ==========================================================================
   § Pagespeed
     Run PageSpeed Insights
     Update `url` below to the public URL for your site
   ========================================================================== */

gulp.task('pagespeed', pagespeed.bind(null, {
  // By default, we use the PageSpeed Insights
  // free (no API key) tier. You can use a Google
  // Developer API key if you have one. See
  // http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
  url: 'http://getroadmap.github.io/roadmap-site/',
  strategy: 'mobile'
}));

/* ==========================================================================
   § Rev
   ========================================================================== */

/*
   §§ Rev - Default
   ========================================================================== */

gulp.task('rev', function () {
  return gulp.src(['.tmp/**', ])
    .pipe($.revAll({
      base: '.tmp/',
      ignore: [
        /^\/favicon.ico$/g,
        '.html',
        '.php'
      ],
    }))
    .pipe(gulp.dest('dist'));
});

/*
   §§ Rev - GH-Pages
   ========================================================================== */
gulp.task('rev:gh-pages', function () {
  return gulp.src(['.tmp/**', ])
    .pipe($.revAll({
        ignore: [
          /^\/favicon.ico$/g,
          '.html',
          '.php'
        ],
        transformFilename: function (file, hash) {
          var ext = path.extname(file.path);
          return path.basename(file.path, ext) + ext; // no transform
        },
        prefix: '/roadmap-site/'
    }))
    .pipe(gulp.dest('gh-pages'));
});

/* ==========================================================================
   § Styles
   ========================================================================== */

gulp.task('styles', function () {
  // For best performance, don't add Sass partials to `gulp.src`
  return gulp.src('app/sass/*.scss')
    .pipe($.plumber())
    .pipe($.sourcemaps.init())
    .pipe($.sass({
      includePaths: [
        'bower_components'
      ]
    }))
    .pipe($.postcss(processors))
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest('.tmp/styles'))
    .pipe(reload({stream:true}))
    .pipe(gulp.dest('app/jekyll/styles'))
    .pipe($.size({title: 'styles'}));
});

/*
   §§ Styles - Combine Media Queries
   ========================================================================== */

gulp.task('styles:cmq', function () {
  gulp.src('./dist/styles/*.css')
    .pipe($.combineMediaQueries({
          log: true
    }))
    // Concatenate And Minify Styles
    .pipe($.csso())
    .pipe(gulp.dest('dist/styles'))
    .pipe($.size({title: 'Media Queries'}));
});

/* ==========================================================================
   § Serve
   ========================================================================== */

/*
   §§ Serve - Default
   ========================================================================== */
gulp.task('serve', ['jekyll', 'styles'], function () {
  browserSync({
    notify: false,
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: {
      baseDir: ['.tmp'],
      routes: {
        '/bower_components': 'bower_components'
      }
    }
  });
});

/*
   §§ Serve - Dist
   ========================================================================== */
gulp.task('serve:dist', ['build'], function () {
  browserSync({
    notify: false,
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: ['dist']
  });
});

/*
   §§ Serve - GH-Pages
   ========================================================================== */
gulp.task('serve:gh-pages', ['build:gh-pages'], function () {
  browserSync({
    notify: false,
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: {
      baseDir: ['gh-pages'],
      routes: {
        '/roadmap-site': '.'
      }
    }
  });
});

/* ==========================================================================
   § Watch
   ========================================================================== */

/*
   §§ Watch - Default
   ========================================================================== */
gulp.task('watch', ['serve','jekyll','styles'], function () {
  gulp.watch(['app/jekyll/**/*.{html,md,markdown}'], ['jekyll:rebuild']);
  gulp.watch(['app/sass/**/*.{scss,css}'], ['styles']);
  gulp.watch(['app/scripts/**/*.js'], ['jshint']);
  gulp.watch(['app/images/**/*'], ['images']);
  gulp.watch(['.tmp/**'], reload({once: true}));
});

/*
   §§ Watch - Hologram
   ========================================================================== */

gulp.task('watch:hologram', ['serve', 'styles', 'hologram'], function () {
  gulp.watch(['app/styles/**/*.{scss,css}'], ['styles']);
  gulp.watch(['.tmp/styles/**/*.{scss,css}'], ['hologram']);
});

/* ==========================================================================
   § Build
   ========================================================================== */

/*
   §§ Build - Default
   ========================================================================== */
gulp.task('build', ['clean'], function (cb) {
  runSequence('jekyll:production','styles', 'styles:cmq', ['jshint', 'images', 'fonts', 'copy'], 'assets', 'assets:inline', 'rev', cb);
});

/*
   §§ Build - GH-Pages
   ========================================================================== */
gulp.task('build:gh-pages', ['clean:gh-pages'], function (cb) {
  runSequence('jekyll:gh-pages',
              'styles',
              'styles:cmq',
              'hologram',
              ['jshint', 'images', 'fonts', 'copy'],
              'assets',
              'assets:inline',
              'rev:gh-pages', cb);
});

/* ==========================================================================
   § Default
   ========================================================================== */

gulp.task('default', ['clean'], function () {
  gulp.start('watch');
});

// Load custom tasks from the `tasks` directory
try { require('require-dir')('tasks'); } catch (err) {}
<commit_msg>remove hologram<commit_after>/**
 *
 *  Web Starter Kit
 *  Copyright 2014 Google Inc. All rights reserved.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License
 *
 */

'use strict';

/* ==========================================================================
   § Gulp Tools
   ========================================================================== */

// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var autoprefixer = require('autoprefixer-core');
var cp = require('child_process');
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var pagespeed = require('psi');
var reload = browserSync.reload;
var path = require('path');

/* ==========================================================================
   § Gulp Variables
   ========================================================================== */

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

var messages = {
    jekyllBuild: 'Running: $ jekyll build'
};

var processors = [
  autoprefixer(AUTOPREFIXER_BROWSERS)
];

/* ==========================================================================
   § Assets
   ========================================================================== */

gulp.task('assets' ,function () {
  var assets = $.useref.assets({searchPath: '.tmp'});

  return gulp.src('.tmp/**/*.html')
    .pipe(assets)
    // Concatenate And Minify JavaScript
    .pipe($.if('*.js', $.uglify({preserveComments: 'some'})))
    // Remove Any Unused CSS
    // Note: If not using the Style Guide, you can delete it from
    // the next line to only include styles your project uses.
    .pipe($.if('*.css', $.uncss({
      html: [
        '.tmp/index.html',
        '.tmp/sign-up/index.html',
        '.tmp/privacy-policy/index.html',
        '.tmp/plans-pricing/index.html',
        '.tmp/terms-of-service/index.html',
        '.tmp/updates/index.html',
        '.tmp/updates/chrome-extension-for-basecamp.html',
        '.tmp/customers/cr-studios/index.html'
      ],
      // CSS Selectors for UnCSS to ignore
      ignore: [
        // for mobile
        /video, embed, object, img, picture/,
        /img/,
        // application styles
        /.app-bar.open/,
        /.ibutton-*/,
        /#header/,

      ]
    })))
    // Concatenate And Minify Styles
    // In case you are still using useref build blocks
    .pipe($.if('*.css', $.csso()))
    .pipe(assets.restore())
    .pipe($.useref())
    // Update Production Style Guide Paths
    //.pipe($.replace('components/components.css', 'components/main.min.css'))
    // Minify Any HTML
    // Output Files
    .pipe(gulp.dest('.tmp'))
    .pipe($.size({title: 'html'}));
});

/*
   §§ Assets - Inline
   ========================================================================== */

gulp.task('assets:inline', function () {
    return gulp.src('./.tmp/**/*.html')
        .pipe($.inlineSource())
        .pipe(gulp.dest('./.tmp'));
});

/* ==========================================================================
   § Bump Versions
   ========================================================================== */

/*
   §§ Bump Major
   ========================================================================== */

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

/*
   §§ Bump Minor
   ========================================================================== */

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

/*
   §§ Bump Patch
   ========================================================================== */

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

/* ==========================================================================
   § Clean
   ========================================================================== */

gulp.task('clean', del.bind(null, ['.tmp', 'dist/*', '!dist/.git']));
gulp.task('clean:gh-pages', del.bind(null, ['.tmp', 'gh-pages/*', '!gh-pages/.git']));

/* ==========================================================================
   § Copy
   ========================================================================== */

gulp.task('copy', function () {
  return gulp.src([
    '.tmp/*',
    '!.tmp/*.html',
    'node_modules/apache-server-configs/dist/.htaccess'
  ], {
    dot: true
  }).pipe(gulp.dest('dist'))
    .pipe($.size({title: 'copy'}));
});

/* ==========================================================================
   § Fonts
   ========================================================================== */

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

/* ==========================================================================
   § Hologram
   ========================================================================== */

gulp.task('hologram', function () {
  gulp.src('hologram/hologram_config.yml')
    .pipe($.hologram({bundler:true, logging:true}));
});

/* ==========================================================================
   § Images
   ========================================================================== */

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

/* ==========================================================================
   § Jekyll
   ========================================================================== */

gulp.task('jekyll', function (done) {
  browserSync.notify(messages.jekyllBuild);
  return cp.spawn('jekyll', ['build', '--config', '_config.yml,_config_dev.yml'], {stdio: 'inherit'})
          .on('close', done);
});

gulp.task('jekyll:production', function (done) {
  browserSync.notify(messages.jekyllBuild);
  return cp.spawn('jekyll', ['build', '--config', '_config.yml'], {stdio: 'inherit'})
          .on('close', done);
});

gulp.task('jekyll:gh-pages', function (done) {
  browserSync.notify(messages.jekyllBuild);
  return cp.spawn('jekyll', ['build', '--config', '_config.yml,_config_ghpages.yml'], {stdio: 'inherit'})
          .on('close', done);
});

gulp.task('jekyll:rebuild', ['jekyll'], function () {
    reload();
});

/* ==========================================================================
   § JSHINT
   ========================================================================== */

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

/* ==========================================================================
   § Pagespeed
     Run PageSpeed Insights
     Update `url` below to the public URL for your site
   ========================================================================== */

gulp.task('pagespeed', pagespeed.bind(null, {
  // By default, we use the PageSpeed Insights
  // free (no API key) tier. You can use a Google
  // Developer API key if you have one. See
  // http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
  url: 'http://getroadmap.github.io/roadmap-site/',
  strategy: 'mobile'
}));

/* ==========================================================================
   § Rev
   ========================================================================== */

/*
   §§ Rev - Default
   ========================================================================== */

gulp.task('rev', function () {
  return gulp.src(['.tmp/**', ])
    .pipe($.revAll({
      base: '.tmp/',
      ignore: [
        /^\/favicon.ico$/g,
        '.html',
        '.php'
      ],
    }))
    .pipe(gulp.dest('dist'));
});

/*
   §§ Rev - GH-Pages
   ========================================================================== */
gulp.task('rev:gh-pages', function () {
  return gulp.src(['.tmp/**', ])
    .pipe($.revAll({
        ignore: [
          /^\/favicon.ico$/g,
          '.html',
          '.php'
        ],
        transformFilename: function (file, hash) {
          var ext = path.extname(file.path);
          return path.basename(file.path, ext) + ext; // no transform
        },
        prefix: '/roadmap-site/'
    }))
    .pipe(gulp.dest('gh-pages'));
});

/* ==========================================================================
   § Styles
   ========================================================================== */

gulp.task('styles', function () {
  // For best performance, don't add Sass partials to `gulp.src`
  return gulp.src('app/sass/*.scss')
    .pipe($.plumber())
    .pipe($.sourcemaps.init())
    .pipe($.sass({
      includePaths: [
        'bower_components'
      ]
    }))
    .pipe($.postcss(processors))
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest('.tmp/styles'))
    .pipe(reload({stream:true}))
    .pipe(gulp.dest('app/jekyll/styles'))
    .pipe($.size({title: 'styles'}));
});

/*
   §§ Styles - Combine Media Queries
   ========================================================================== */

gulp.task('styles:cmq', function () {
  gulp.src('./dist/styles/*.css')
    .pipe($.combineMediaQueries({
          log: true
    }))
    // Concatenate And Minify Styles
    .pipe($.csso())
    .pipe(gulp.dest('dist/styles'))
    .pipe($.size({title: 'Media Queries'}));
});

/* ==========================================================================
   § Serve
   ========================================================================== */

/*
   §§ Serve - Default
   ========================================================================== */
gulp.task('serve', ['jekyll', 'styles'], function () {
  browserSync({
    notify: false,
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: {
      baseDir: ['.tmp'],
      routes: {
        '/bower_components': 'bower_components'
      }
    }
  });
});

/*
   §§ Serve - Dist
   ========================================================================== */
gulp.task('serve:dist', ['build'], function () {
  browserSync({
    notify: false,
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: ['dist']
  });
});

/*
   §§ Serve - GH-Pages
   ========================================================================== */
gulp.task('serve:gh-pages', ['build:gh-pages'], function () {
  browserSync({
    notify: false,
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: {
      baseDir: ['gh-pages'],
      routes: {
        '/roadmap-site': '.'
      }
    }
  });
});

/* ==========================================================================
   § Watch
   ========================================================================== */

/*
   §§ Watch - Default
   ========================================================================== */
gulp.task('watch', ['serve','jekyll','styles'], function () {
  gulp.watch(['app/jekyll/**/*.{html,md,markdown}'], ['jekyll:rebuild']);
  gulp.watch(['app/sass/**/*.{scss,css}'], ['styles']);
  gulp.watch(['app/scripts/**/*.js'], ['jshint']);
  gulp.watch(['app/images/**/*'], ['images']);
  gulp.watch(['.tmp/**'], reload({once: true}));
});

/*
   §§ Watch - Hologram
   ========================================================================== */

gulp.task('watch:hologram', ['serve', 'styles', 'hologram'], function () {
  gulp.watch(['app/styles/**/*.{scss,css}'], ['styles']);
  gulp.watch(['.tmp/styles/**/*.{scss,css}'], ['hologram']);
});

/* ==========================================================================
   § Build
   ========================================================================== */

/*
   §§ Build - Default
   ========================================================================== */
gulp.task('build', ['clean'], function (cb) {
  runSequence('jekyll:production','styles', 'styles:cmq', ['jshint', 'images', 'fonts', 'copy'], 'assets', 'assets:inline', 'rev', cb);
});

/*
   §§ Build - GH-Pages
   ========================================================================== */
gulp.task('build:gh-pages', ['clean:gh-pages'], function (cb) {
  runSequence('jekyll:gh-pages',
              'styles',
              'styles:cmq',
              ['jshint', 'images', 'fonts', 'copy'],
              'assets',
              'assets:inline',
              'rev:gh-pages', cb);
});

/* ==========================================================================
   § Default
   ========================================================================== */

gulp.task('default', ['clean'], function () {
  gulp.start('watch');
});

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


<commit_before>var gulp = require('gulp');
var concat = require('gulp-concat');
var git = require('gulp-git');
var del = require('del');
var run = require('gulp-run');

gulp.task('build-wrappers', function() {
  del(['temp']).then(paths => {
    git.clone('https://github.com/crossrails/javascriptcore.swift.git', {args: 'temp'}, (err) => {
      if (err) {
        throw err;
      } else {
          gulp.src('temp/Source/*.swift')
          .pipe(concat('javascriptcore.swift'))
          .pipe(gulp.dest('src/swift/'))
          .on('end', function() {
            del(['temp']);
          })
      }
    })
  });
});

gulp.task('gen-markdown', function() {
  return run('cd wiki && javac Wiki.java && java Wiki && git clone https://github.com/crossrails/compiler.wiki.git && mv wiki.md compiler.wiki/compiler-options.md && cd compiler.wiki/ && git add compiler-options.md && git commit -m "Updated compiler options" && git push && cd .. && rm -R compiler.wiki/ ').exec();
});
<commit_msg>moved gradle java test execution to neat gulp task<commit_after>var gulp = require('gulp');
var concat = require('gulp-concat');
var git = require('gulp-git');
var del = require('del');
var run = require('gulp-run');

gulp.task('build-wrappers', function() {
  del(['temp']).then(paths => {
    git.clone('https://github.com/crossrails/javascriptcore.swift.git', {args: 'temp'}, (err) => {
      if (err) {
        throw err;
      } else {
          gulp.src('temp/Source/*.swift')
          .pipe(concat('javascriptcore.swift'))
          .pipe(gulp.dest('src/swift/'))
          .on('end', function() {
            del(['temp']);
          })
      }
    })
  });
});

gulp.task('gen-markdown', function() {
  return run('cd wiki && javac Wiki.java && java Wiki && git clone https://github.com/crossrails/compiler.wiki.git && mv wiki.md compiler.wiki/compiler-options.md && cd compiler.wiki/ && git add compiler-options.md && git commit -m "Updated compiler options" && git push && cd .. && rm -R compiler.wiki/ ').exec();
});

gulp.task('run-java-tests', function() {
  return run('cd tests/java/ && gradle test').exec();
});
  <|endoftext|>


<commit_before>var gulp = require('gulp'),
    gutil = require('gulp-util'),
    size = require('gulp-size'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    minify = require('gulp-minify'),
    path = require('path'),
    karma = require('karma'),
    karmaParseConfig = require('karma/lib/config').parseConfig;

function runKarma(configFilePath, options, cb) {

    configFilePath = path.resolve(configFilePath);

    var log = gutil.log, colors = gutil.colors;
    var config = karmaParseConfig(configFilePath, {});

    Object.keys(options).forEach(function (key) {
        config[key] = options[key];
    });

    var server = new karma.Server(config, function (exitCode) {
        log('Karma has exited with ' + colors.red(exitCode));
        cb();
        process.exit(exitCode);
    });

    server.start();
}

/**
 * single run test
 */
gulp.task('test', function (cb) {
    runKarma('karma.conf.js', {
        autoWatch: false,
        singleRun: true
    }, cb);
});

/** continuous ... using karma to watch */
gulp.task('test-watch', function (cb) {
    runKarma('karma.conf.js', {
        autoWatch: true,
        singleRun: false
    }, cb);
});

//clean dist
gulp.task('clean', function() {
    return gulp.src(['dist/**/*.js'], {read: false})
        .pipe(clean());
});

//create dist files
gulp.task('scripts', function () {
    var js = gulp.src(['src/**/*.js'])
        .pipe(concat('netlicensing-client-js.js'))
        .pipe(size({
            title: 'The size of a library'
        }))
        .pipe(gulp.dest('dist'));

    var min = gulp.src(['src/**/*.js'])
        .pipe(concat('netlicensing-client-js.min.js'))
        .pipe(uglify())
        .pipe(size({
            title: 'The size of a minimized library'
        }))
        .pipe(gulp.dest('dist'));
});

//test + create dist files
gulp.task('production',['test','scripts']);
<commit_msg>Fix gulpfile.js<commit_after>var gulp = require('gulp'),
    gutil = require('gulp-util'),
    size = require('gulp-size'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    path = require('path'),
    karma = require('karma'),
    karmaParseConfig = require('karma/lib/config').parseConfig;

function runKarma(configFilePath, options, cb) {

    configFilePath = path.resolve(configFilePath);

    var log = gutil.log, colors = gutil.colors;
    var config = karmaParseConfig(configFilePath, {});

    Object.keys(options).forEach(function (key) {
        config[key] = options[key];
    });

    var server = new karma.Server(config, function (exitCode) {
        log('Karma has exited with ' + colors.red(exitCode));
        cb();
        process.exit(exitCode);
    });

    server.start();
}

/**
 * single run test
 */
gulp.task('test', function (cb) {
    runKarma('karma.conf.js', {
        autoWatch: false,
        singleRun: true
    }, cb);
});

/** continuous ... using karma to watch */
gulp.task('test-watch', function (cb) {
    runKarma('karma.conf.js', {
        autoWatch: true,
        singleRun: false
    }, cb);
});

//clean dist
gulp.task('clean', function() {
    return gulp.src(['dist/**/*.js'], {read: false})
        .pipe(clean());
});

//create dist files
gulp.task('scripts', function () {
    var js = gulp.src(['src/**/*.js'])
        .pipe(concat('netlicensing-client-js.js'))
        .pipe(size({
            title: 'The size of a library'
        }))
        .pipe(gulp.dest('dist'));

    var min = gulp.src(['src/**/*.js'])
        .pipe(concat('netlicensing-client-js.min.js'))
        .pipe(uglify())
        .pipe(size({
            title: 'The size of a minimized library'
        }))
        .pipe(gulp.dest('dist'));
});

//test + create dist files
gulp.task('production',['test','scripts']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var jshint = require('gulp-jshint');
var fixmyjs = require('gulp-fixmyjs');
var stylish = require('jshint-stylish');
var esformatter = require('gulp-esformatter');
var os = require('os');

var paths = {
    'js': ['*.js', '**/*.js', '!node_modules/**/*.js']
};

gulp.task('default', function() {
    return gulp.src(paths.js)
    .pipe(jshint())
    .pipe(jshint.reporter('default'))
    .pipe(esformatter({
        indent: {
            value: '    '
        },
        lineBreak: {
            value: os.EOL,
        }
    }))
    .pipe(gulp.dest('.'));
});

// Not a good idea...
// gulp.task('watch', function() {
//     gulp.watch(paths.js, ['default']);
// });
<commit_msg>dont change line endings<commit_after>var gulp = require('gulp');
var jshint = require('gulp-jshint');
var fixmyjs = require('gulp-fixmyjs');
var stylish = require('jshint-stylish');
var esformatter = require('gulp-esformatter');
var os = require('os');

var paths = {
    'js': ['*.js', '**/*.js', '!node_modules/**/*.js']
};

gulp.task('default', function() {
    return gulp.src(paths.js)
    .pipe(jshint())
    .pipe(jshint.reporter('default'))
    .pipe(esformatter({
        indent: {
            value: '    '
        }
    }))
    .pipe(gulp.dest('.'));
});

// Not a good idea...
// gulp.task('watch', function() {
//     gulp.watch(paths.js, ['default']);
// });
<|endoftext|>


<commit_before>var $      = require('gulp-load-plugins')();
var argv   = require('yargs').argv;
var gulp   = require('gulp');
var rimraf = require('rimraf');
var panini = require('panini');
var sequence = require('run-sequence');

// Check for --production flag
var isProduction = !!(argv.production);

// File paths to various assets are defined here.
var paths = {
  assets: [
    'src/assets/**/*',
    '!src/assets/{!img,js,scss}/**/*'
  ],
  sass: [
    'node_modules/foundation-sites/scss'
  ],
  javascript: [
    'node_modules/jquery/dist/jquery.js',
    'node_modules/foundation-sites/dist/foundation.js',
    'src/assets/js/**/*.js',
    'src/assets/js/app.js'
  ]
}

// Delete the "dist" folder
// This happens every time a build starts
gulp.task('clean', function(done) {
  rimraf('./dist', done);
});

// Copy files out of the assets folder
// This task skips over the "img", "js", and "scss" folders, which are parsed separately
gulp.task('copy', function(done) {
  gulp.src(paths.assets)
    .pipe(gulp.dist('./dist/assets'));
});

// Copy page templates into finished HTML files
gulp.task('pages', function() {
  gulp.src('./src/pages/**/*.html')
    .pipe(panini({
      layouts: './src/layouts/',
      partials: './src/partials/**/*.html',
      data: './src/data/**/*.{json,yml}'
    }))
    .pipe(gulp.dest('./dist'));
});

// Compile Sass into CSS
// In production, the CSS is compressed
gulp.task('sass', function() {
  var uncss = $.if(isProduction, $.uncss({
    html: ['src/**/*.html'],
    ignore: [
      new RegExp('^meta\..*'),
      new RegExp('^\.is-.*')
    ]
  }));

  return gulp.src('./src/assets/scss/app.scss')
    .pipe($.sass({
      includePaths: paths.sass,
      outputStyle: (isProduction ? 'compressed' : 'nested'),
      errLogToConsole: true
    }))
    .pipe($.autoprefixer({
      browsers: ['last 2 versions', 'ie >= 9']
    }))
    .pipe(uncss)
    .pipe(gulp.dest('./dist/assets/css'));
});

// Combine JavaScript into one file
// In production, the file is minified
gulp.task('javascript', function() {
  var uglify = $.if(isProduction, $.uglify()
    .on('error', function (e) {
      console.log(e);
    }));

  return gulp.src(paths.javascript)
    .pipe($.concat('app.js'))
    .pipe(uglify)
    .pipe(gulp.dest('./dist/assets/js'));
});

// Copy images to the "dist" folder
// In production, the images are compressed
gulp.task('images', function() {
  var imagemin = $.if(isProduction, $.imagemin({
    progressive: true
  }));

  return gulp.src('./src/assets/img/**/*')
    .pipe(imagemin)
    .pipe(gulp.dest('./dist/assets/img'));
});

// Build the "dist" folder by running all of the above tasks
gulp.task('build', function(done) {
  sequence('clean', ['pages', 'sass', 'javascript', 'images'], done);
});

// Start a server with LiveReload to preview the site in
gulp.task('server', ['build'], function() {
  return gulp.src('./dist')
    .pipe($.webserver({
      host: 'localhost',
      port: 8000,
      livereload: true,
      open: true
    }));
});

// Build the site, run the server, and watch for file changes
gulp.task('default', ['build', 'server'], function() {
  gulp.watch(paths.assets, ['copy']);
  gulp.watch(['./src/pages/**/*.html'], ['pages']);
  gulp.watch(['./src/assets/scss/**/*.scss'], ['sass']);
  gulp.watch(['./src/assets/js/**/*.js'], ['javascript']);
  gulp.watch(['./src/assets/img/**/*'], ['images']);
});
<commit_msg>Add missing semicolon<commit_after>var $      = require('gulp-load-plugins')();
var argv   = require('yargs').argv;
var gulp   = require('gulp');
var rimraf = require('rimraf');
var panini = require('panini');
var sequence = require('run-sequence');

// Check for --production flag
var isProduction = !!(argv.production);

// File paths to various assets are defined here.
var paths = {
  assets: [
    'src/assets/**/*',
    '!src/assets/{!img,js,scss}/**/*'
  ],
  sass: [
    'node_modules/foundation-sites/scss'
  ],
  javascript: [
    'node_modules/jquery/dist/jquery.js',
    'node_modules/foundation-sites/dist/foundation.js',
    'src/assets/js/**/*.js',
    'src/assets/js/app.js'
  ]
};

// Delete the "dist" folder
// This happens every time a build starts
gulp.task('clean', function(done) {
  rimraf('./dist', done);
});

// Copy files out of the assets folder
// This task skips over the "img", "js", and "scss" folders, which are parsed separately
gulp.task('copy', function(done) {
  gulp.src(paths.assets)
    .pipe(gulp.dist('./dist/assets'));
});

// Copy page templates into finished HTML files
gulp.task('pages', function() {
  gulp.src('./src/pages/**/*.html')
    .pipe(panini({
      layouts: './src/layouts/',
      partials: './src/partials/**/*.html',
      data: './src/data/**/*.{json,yml}'
    }))
    .pipe(gulp.dest('./dist'));
});

// Compile Sass into CSS
// In production, the CSS is compressed
gulp.task('sass', function() {
  var uncss = $.if(isProduction, $.uncss({
    html: ['src/**/*.html'],
    ignore: [
      new RegExp('^meta\..*'),
      new RegExp('^\.is-.*')
    ]
  }));

  return gulp.src('./src/assets/scss/app.scss')
    .pipe($.sass({
      includePaths: paths.sass,
      outputStyle: (isProduction ? 'compressed' : 'nested'),
      errLogToConsole: true
    }))
    .pipe($.autoprefixer({
      browsers: ['last 2 versions', 'ie >= 9']
    }))
    .pipe(uncss)
    .pipe(gulp.dest('./dist/assets/css'));
});

// Combine JavaScript into one file
// In production, the file is minified
gulp.task('javascript', function() {
  var uglify = $.if(isProduction, $.uglify()
    .on('error', function (e) {
      console.log(e);
    }));

  return gulp.src(paths.javascript)
    .pipe($.concat('app.js'))
    .pipe(uglify)
    .pipe(gulp.dest('./dist/assets/js'));
});

// Copy images to the "dist" folder
// In production, the images are compressed
gulp.task('images', function() {
  var imagemin = $.if(isProduction, $.imagemin({
    progressive: true
  }));

  return gulp.src('./src/assets/img/**/*')
    .pipe(imagemin)
    .pipe(gulp.dest('./dist/assets/img'));
});

// Build the "dist" folder by running all of the above tasks
gulp.task('build', function(done) {
  sequence('clean', ['pages', 'sass', 'javascript', 'images'], done);
});

// Start a server with LiveReload to preview the site in
gulp.task('server', ['build'], function() {
  return gulp.src('./dist')
    .pipe($.webserver({
      host: 'localhost',
      port: 8000,
      livereload: true,
      open: true
    }));
});

// Build the site, run the server, and watch for file changes
gulp.task('default', ['build', 'server'], function() {
  gulp.watch(paths.assets, ['copy']);
  gulp.watch(['./src/pages/**/*.html'], ['pages']);
  gulp.watch(['./src/assets/scss/**/*.scss'], ['sass']);
  gulp.watch(['./src/assets/js/**/*.js'], ['javascript']);
  gulp.watch(['./src/assets/img/**/*'], ['images']);
});
<|endoftext|>


<commit_before>
var gulp = require('gulp');
var sass = require('gulp-sass');

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

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

var spawn = require('child_process').spawn;

var jsxDir = './app/jsx';

var port = process.env.PORT || 7070;

// Define paths for all source files here
var paths = {
    client: ['./app/jsx/*.jsx', './app/common/ajax-functions.js'],
    sass: ['./scss/*.*'],

    server: './server.js',
    serverIgnore: ['./app/jsx', './app/common/ajax-functions.js'],

    tags: ['./app/**/*', './pug/**/*', './scss/**/*'],

};

gulp.task('build', function() {
    return browserify({entries: jsxDir + '/app.jsx',
        extensions: ['.jsx'], debug: true})
        .transform(babelify)
        .bundle()
        .pipe(source('./bundle.js'))
        .pipe(gulp.dest('build'));
});

gulp.task('build-test', function() {
    return browserify({entries:
        ['./app/common/ajax-functions.js', 'tests/ajax-functions.js'],
        extensions: ['.js'], debug: true})
        .transform(babelify)
        .bundle()
        .pipe(source('./bundleTests.js'))
        .pipe(gulp.dest('build'));
});

gulp.task('sass', function() {
    console.log('Watching folder ./scss for changes.');
	return gulp.src('./sass/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./build'));

});

gulp.task('serve', function(cb) {
    var called = false;
    nodemon({
        script: paths.server,
        ext: '.js',
        ignore: paths.serverIgnore,
        //exec: 'node',
        env: {
            NODE_ENV: process.env.NODE_ENV || 'development',
            DEBUG: process.env.DEBUG || 0,
            PORT: port
        }
    })
    .on('start', function() {
        if (!called) {
            console.log('Server started on port ' + port);
            called = true;
            cb();
        }
    })
    .on('restart', function(files) {
        if (files) {
            console.log('Nodemon will restart due to changes in: ', files);
        }
    });
});

// Bit unusual task. Builds ctags-file for easier src navigation in Vim
gulp.task('tags', function() {
    console.log('Building ctags for the project.');
    spawn('ctags', ['-R', 'app/', 'pug/', 'scss/']);
});

var watchDependents = [
  'build',
  'tags',
  'sass',
  'serve'
];

gulp.task('watch', watchDependents, function() {
    gulp.watch(paths.client, ['build']);
    gulp.watch(paths.server, ['serve']);
    gulp.watch(paths.sass, ['sass']);
    gulp.watch(paths.tags, ['tags']);
});

gulp.task('default', ['watch']);

<commit_msg>Added more paths to serverIgnore.<commit_after>
var gulp = require('gulp');
var sass = require('gulp-sass');

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

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

var spawn = require('child_process').spawn;

var jsxDir = './app/jsx';

var port = process.env.PORT || 7070;

// Define paths for all source files here
var paths = {
    client: ['./app/jsx/*.jsx', './app/common/ajax-functions.js'],
    sass: ['./scss/*.*'],

    server: './server.js',
    serverIgnore: ['./gulpfile.js', './scss', './pug', './public', './build',
        './app/jsx', './app/common/ajax-functions.js'],

    tags: ['./app/**/*', './pug/**/*', './scss/**/*'],

};

gulp.task('build', function() {
    return browserify({entries: jsxDir + '/app.jsx',
        extensions: ['.jsx'], debug: true})
        .transform(babelify)
        .bundle()
        .pipe(source('./bundle.js'))
        .pipe(gulp.dest('build'));
});

gulp.task('build-test', function() {
    return browserify({entries:
        ['./app/common/ajax-functions.js', 'tests/ajax-functions.js'],
        extensions: ['.js'], debug: true})
        .transform(babelify)
        .bundle()
        .pipe(source('./bundleTests.js'))
        .pipe(gulp.dest('build'));
});

gulp.task('sass', function() {
    console.log('Watching folder ./scss for changes.');
	return gulp.src('./sass/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./build'));

});

/* Task for starting/restarting server on any changes.*/
gulp.task('serve', function(cb) {
    var called = false;
    nodemon({
        script: paths.server,
        ext: '.js',
        ignore: paths.serverIgnore,
        //exec: 'node',
        env: {
            NODE_ENV: process.env.NODE_ENV || 'development',
            DEBUG: process.env.DEBUG || 0,
            PORT: port
        }
    })
    .on('start', function() {
        if (!called) {
            console.log('Server started on port ' + port);
            called = true;
            cb();
        }
    })
    .on('restart', function(files) {
        if (files) {
            console.log('Nodemon will restart due to changes in: ', files);
        }
    });
});

// Bit unusual task. Builds ctags-file for easier src navigation in Vim
gulp.task('tags', function() {
    console.log('Building ctags for the project.');
    spawn('ctags', ['-R', 'app/', 'pug/', 'scss/']);
});

var watchDependents = [
  'build',
  'tags',
  'sass',
  'serve'
];

gulp.task('watch', watchDependents, function() {
    gulp.watch(paths.client, ['build']);
    gulp.watch(paths.server, ['serve']);
    gulp.watch(paths.sass, ['sass']);
    gulp.watch(paths.tags, ['tags']);
});

gulp.task('default', ['watch']);

<|endoftext|>


<commit_before>// ===================================================
// Settin'
// ===================================================

var gulp            = require('gulp'),
    gulpLoadPlugins = require('gulp-load-plugins'),
    $               = gulpLoadPlugins({
                        rename: {
                          'gulp-sourcemaps'  : 'sourcemaps',
                          'gulp-minify-css'  : 'mincss',
                          'gulp-minify-html' : 'minhtml',
                          'gulp-gh-pages'    : 'ghPages',
                          'gulp-foreach'     : 'foreach',
                          'gulp-mocha'       : 'mocha',
                          'gulp-if'          : 'if'
                        }
                      }),
    assemble        = require('assemble'),
    del             = require('del'),
    merge           = require('merge-stream'),
    basename        = require('path').basename,
    extname         = require('path').extname;

$.exec   = require('child_process').exec;
$.fs     = require('fs');

// ===================================================
// Configin'
// ===================================================

var env_flag = true;

var asset_dir = {
  site: 'site',
  templates : 'templates',
  data: 'data',
  dist: 'dist',
  js: 'js',
  css: 'css',
  sass: 'src'
};

var path = {
  site: asset_dir.site,
  data: asset_dir.data,
  templates: asset_dir.site + '/' + asset_dir.templates,
  dist: asset_dir.dist,
  js: asset_dir.site + '/' + asset_dir.js,
  css: asset_dir.site + '/' + asset_dir.css,
  sass: asset_dir.site + '/' + asset_dir.css + '/' + asset_dir.sass
};

var glob = {
  html: path.site + '/*.html',
  css: path.css + '/*.css',
  sass: path.sass + '/**/*.scss',
  js: path.js + '/src/**/*.js',
  jslibs : path.js + '/lib/**/*.js',
  layouts: path.templates + '/layouts/*.{md,hbs}',
  pages: path.templates + '/pages/**/*.{md,hbs}',
  includes: path.templates + '/includes/**/*.{md,hbs}',
  data: path.data + '/**/*.{json,yaml}',
  rootData: ['site.yaml', 'package.json']
};

// ===================================================
// Developin'
// ===================================================

gulp.task('serve', ['assemble'], function() {
  $.connect.server({
    root: [path.site],
    port: 5000,
    livereload: true,
    middleware: function(connect) {
      return [
        connect().use(connect.query())
      ];
    }
  });

  $.exec('open http://localhost:5000');
});

// ===================================================
// Previewin'
// ===================================================

gulp.task('preview', function() {
  $.connect.server({
    root: [path.dist],
    port: 5001
  });

  $.exec('open http://localhost:5001');
});

// ===================================================
// Testin'
// ===================================================

gulp.task('mocha', function () {
  return gulp.src('test/*.js', {read: false})
    .pipe($.mocha({ reporter: 'nyan' }));
});

// ===================================================
// Stylin'
// ===================================================

gulp.task('sass', function() {
  var stream = gulp.src(glob.sass)
    .pipe($.if(env_flag === false, $.sourcemaps.init()))
    .pipe($.sass({
      outputStyle: $.if(env_flag === false, 'expanded', 'compressed')
    }))
    .pipe($.if(env_flag === false,
      $.sourcemaps.write({
        debug: true,
        includeContent: false,
        sourceRoot: path.css
      })
    ))
    .pipe($.autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(gulp.dest(path.css))
    .pipe($.connect.reload());

  return stream;
});

// ===================================================
// Templatin'
// ===================================================

// Pull #3. Also see https://github.com/assemble/assemble/issues/715
// create a `categories` object to keep categories in (e.g. 'clients')
// categories: {
//  clients: {
//    "polyon": { ... }
//  }
// };
assemble.set('categories', {});

/**
 Populate categories with pages that specify the categories they belong to.
 When the onLoad middleware runs for a single file, it looks at the file's front-matter (file.data) to see if it contains a categories property. This property can be a string or an array of strings. If it exists, then the middleware updates the categories object for each category in the array. In the case of polyon.hbs, there is only 1 category called client, so the categories object becomes:

categories: {
 clients: {
   "polyon": { ... }
 }
};
 */

assemble.onLoad(/\.hbs/, function(file, next) {
  // if the file doesn't have a data object or
  // doesn't contain `categories` in it's
  // front-matter, move on.
  if (!file.data || !file.data.categories) {
    return next();
  }

  // use the default `renameKey` function to store
  // pages on the `categories` object
  var renameKey = assemble.option('renameKey');

  // get the categories object
  var categories = assemble.get('categories');

  // figure out which categories this file belongs to
  var cats = file.data.categories;
  cats = Array.isArray(cats) ? cats : [cats];

  // add this file's data (file object) to each of
  // it's catogories
  cats.forEach(function(cat) {
    categories[cat] = categories[cat] || [];
    categories[cat][renameKey(file.path)] = file;
  });

  // done
  next();
});

/**
 * Handlebars helper to iterate over an object of pages for a specific category
 *
 * ```
 * {{#category "clients"}}
 *   <li>{{data.summary}}</li>
 * {{/category}}
 * ```
 */

assemble.helper('category', function(category, options) {
  var pages = this.app.get('categories.' + category);
  if (!pages) {
    return '';
  }
  return Object.keys(pages).map(function(page) {
    // this renders the block between `{{#category}}` and `{{category}}` passing the
    // entire page object as the context.
    // If you only want to use the page's front-matter, then change this to something like
    // return options.fn(pages[page].data);
    return options.fn(pages[page]).toLowerCase();
  }).join('\n');
});

/**
 * Load data onto assemble cache.
 * This loads data from `glob.data` and `glob.rootData`.
 * When loading `glob.rootData`, use a custom namespace function
 * to return `pkg` for `package.json`.
 *
 * After all data is loaded, process the data to resolve templates
 * in values.
 * @doowb PR: https://github.com/grayghostvisuals/grayghostvisuals/pull/5
 */

function loadData() {
  assemble.data(glob.data);
  assemble.data(assemble.plasma(glob.rootData, {namespace: function (fp) {
    var name = basename(fp, extname(fp));
    if (name === 'package') return 'pkg';
    return name;
  }}));
  assemble.data(assemble.process(assemble.data()));
}

// Placing assemble setups inside the task allows
// live reloading/monitoring for files changes.
gulp.task('assemble', function() {
  assemble.option('production', env_flag);
  assemble.option('layout', 'default');
  assemble.layouts(glob.layouts);
  assemble.partials(glob.includes);
  loadData();

  var stream = assemble.src(glob.pages)
    .pipe($.extname())
    .pipe(assemble.dest(path.site))
    .pipe($.connect.reload());

  return stream;
});

// ===================================================
// Optimizin'
// ===================================================

gulp.task('svgstore', function() {
  return gulp
    .src(path.site + '/img/icons/linear/*.svg')
    .pipe($.svgmin({
      plugins: [{
        removeDoctype: true
      }]
    }))
    .pipe($.svgstore())
    .pipe($.cheerio(function($) {
      $('svg').attr('style', 'display:none');
    }))
    .pipe(gulp.dest(path.templates + '/includes/atoms/svg-sprite.svg'));
});

// ===================================================
// Buildin'
// ===================================================

/*
 * foreach is because usemin 0.3.11 won't manipulate
 * multiple files as an array.
 */

gulp.task('usemin', ['assemble', 'sass'], function() {
  return gulp.src(glob.html)
    .pipe($.foreach(function(stream, file) {
      return stream
        .pipe($.usemin({
          assetsDir: path.site,
          css: [ $.rev() ],
          html: [ $.minhtml({ empty: false }) ],
          js: [ $.uglify(), $.rev() ]
        }))
        .pipe(gulp.dest(path.dist));
    }));
});

// ===================================================
// Duplicatin'
// ===================================================

gulp.task('copy', ['usemin'], function() {
  return merge(
    gulp.src([path.site + '/{img,bower_components,js/lib}/**/*'])
        .pipe(gulp.dest(path.dist)),

    gulp.src([
        path.site + '/*.{ico,png,txt}',
        path.site + '/CNAME'
      ]).pipe(gulp.dest(path.dist))
  );
});

// ===================================================
// Releasin'
// ===================================================

gulp.task('deploy', function() {
  return gulp.src([path.dist + '/**/*'])
             .pipe($.ghPages(
                $.if(env_flag === false,
                { branch: 'staging' },
                { branch: 'gh-pages'})
             ));
});

// ===================================================
// Cleanin'
// ===================================================

gulp.task('clean', function(cb) {
  del([
    'dist',
    glob.css,
    glob.html
  ], cb);
});

// ===================================================
// Monitorin'
// ===================================================

gulp.task('watch', function() {
  gulp.watch([
    glob.sass
  ], ['sass']);

  gulp.watch([
    glob.includes,
    glob.pages,
    glob.layouts
  ], ['assemble']);
});

// ===================================================
// Taskin'
// ===================================================

gulp.task('build', [ 'copy','usemin' ]);
gulp.task('default', [ 'sass','assemble','serve','watch' ]);<commit_msg>dev env switch<commit_after>// ===================================================
// Settin'
// ===================================================

var gulp            = require('gulp'),
    gulpLoadPlugins = require('gulp-load-plugins'),
    $               = gulpLoadPlugins({
                        rename: {
                          'gulp-sourcemaps'  : 'sourcemaps',
                          'gulp-minify-css'  : 'mincss',
                          'gulp-minify-html' : 'minhtml',
                          'gulp-gh-pages'    : 'ghPages',
                          'gulp-foreach'     : 'foreach',
                          'gulp-mocha'       : 'mocha',
                          'gulp-if'          : 'if'
                        }
                      }),
    assemble        = require('assemble'),
    del             = require('del'),
    merge           = require('merge-stream'),
    basename        = require('path').basename,
    extname         = require('path').extname;

$.exec   = require('child_process').exec;
$.fs     = require('fs');

// ===================================================
// Configin'
// ===================================================

var env_flag = false;

var asset_dir = {
  site: 'site',
  templates : 'templates',
  data: 'data',
  dist: 'dist',
  js: 'js',
  css: 'css',
  sass: 'src'
};

var path = {
  site: asset_dir.site,
  data: asset_dir.data,
  templates: asset_dir.site + '/' + asset_dir.templates,
  dist: asset_dir.dist,
  js: asset_dir.site + '/' + asset_dir.js,
  css: asset_dir.site + '/' + asset_dir.css,
  sass: asset_dir.site + '/' + asset_dir.css + '/' + asset_dir.sass
};

var glob = {
  html: path.site + '/*.html',
  css: path.css + '/*.css',
  sass: path.sass + '/**/*.scss',
  js: path.js + '/src/**/*.js',
  jslibs : path.js + '/lib/**/*.js',
  layouts: path.templates + '/layouts/*.{md,hbs}',
  pages: path.templates + '/pages/**/*.{md,hbs}',
  includes: path.templates + '/includes/**/*.{md,hbs}',
  data: path.data + '/**/*.{json,yaml}',
  rootData: ['site.yaml', 'package.json']
};

// ===================================================
// Developin'
// ===================================================

gulp.task('serve', ['assemble'], function() {
  $.connect.server({
    root: [path.site],
    port: 5000,
    livereload: true,
    middleware: function(connect) {
      return [
        connect().use(connect.query())
      ];
    }
  });

  $.exec('open http://localhost:5000');
});

// ===================================================
// Previewin'
// ===================================================

gulp.task('preview', function() {
  $.connect.server({
    root: [path.dist],
    port: 5001
  });

  $.exec('open http://localhost:5001');
});

// ===================================================
// Testin'
// ===================================================

gulp.task('mocha', function () {
  return gulp.src('test/*.js', {read: false})
    .pipe($.mocha({ reporter: 'nyan' }));
});

// ===================================================
// Stylin'
// ===================================================

gulp.task('sass', function() {
  var stream = gulp.src(glob.sass)
    .pipe($.if(env_flag === false, $.sourcemaps.init()))
    .pipe($.sass({
      outputStyle: $.if(env_flag === false, 'expanded', 'compressed')
    }))
    .pipe($.if(env_flag === false,
      $.sourcemaps.write({
        debug: true,
        includeContent: false,
        sourceRoot: path.css
      })
    ))
    .pipe($.autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(gulp.dest(path.css))
    .pipe($.connect.reload());

  return stream;
});

// ===================================================
// Templatin'
// ===================================================

// Pull #3. Also see https://github.com/assemble/assemble/issues/715
// create a `categories` object to keep categories in (e.g. 'clients')
// categories: {
//  clients: {
//    "polyon": { ... }
//  }
// };
assemble.set('categories', {});

/**
 Populate categories with pages that specify the categories they belong to.
 When the onLoad middleware runs for a single file, it looks at the file's front-matter (file.data) to see if it contains a categories property. This property can be a string or an array of strings. If it exists, then the middleware updates the categories object for each category in the array. In the case of polyon.hbs, there is only 1 category called client, so the categories object becomes:

categories: {
 clients: {
   "polyon": { ... }
 }
};
 */

assemble.onLoad(/\.hbs/, function(file, next) {
  // if the file doesn't have a data object or
  // doesn't contain `categories` in it's
  // front-matter, move on.
  if (!file.data || !file.data.categories) {
    return next();
  }

  // use the default `renameKey` function to store
  // pages on the `categories` object
  var renameKey = assemble.option('renameKey');

  // get the categories object
  var categories = assemble.get('categories');

  // figure out which categories this file belongs to
  var cats = file.data.categories;
  cats = Array.isArray(cats) ? cats : [cats];

  // add this file's data (file object) to each of
  // it's catogories
  cats.forEach(function(cat) {
    categories[cat] = categories[cat] || [];
    categories[cat][renameKey(file.path)] = file;
  });

  // done
  next();
});

/**
 * Handlebars helper to iterate over an object of pages for a specific category
 *
 * ```
 * {{#category "clients"}}
 *   <li>{{data.summary}}</li>
 * {{/category}}
 * ```
 */

assemble.helper('category', function(category, options) {
  var pages = this.app.get('categories.' + category);
  if (!pages) {
    return '';
  }
  return Object.keys(pages).map(function(page) {
    // this renders the block between `{{#category}}` and `{{category}}` passing the
    // entire page object as the context.
    // If you only want to use the page's front-matter, then change this to something like
    // return options.fn(pages[page].data);
    return options.fn(pages[page]).toLowerCase();
  }).join('\n');
});

/**
 * Load data onto assemble cache.
 * This loads data from `glob.data` and `glob.rootData`.
 * When loading `glob.rootData`, use a custom namespace function
 * to return `pkg` for `package.json`.
 *
 * After all data is loaded, process the data to resolve templates
 * in values.
 * @doowb PR: https://github.com/grayghostvisuals/grayghostvisuals/pull/5
 */

function loadData() {
  assemble.data(glob.data);
  assemble.data(assemble.plasma(glob.rootData, {namespace: function (fp) {
    var name = basename(fp, extname(fp));
    if (name === 'package') return 'pkg';
    return name;
  }}));
  assemble.data(assemble.process(assemble.data()));
}

// Placing assemble setups inside the task allows
// live reloading/monitoring for files changes.
gulp.task('assemble', function() {
  assemble.option('production', env_flag);
  assemble.option('layout', 'default');
  assemble.layouts(glob.layouts);
  assemble.partials(glob.includes);
  loadData();

  var stream = assemble.src(glob.pages)
    .pipe($.extname())
    .pipe(assemble.dest(path.site))
    .pipe($.connect.reload());

  return stream;
});

// ===================================================
// Optimizin'
// ===================================================

gulp.task('svgstore', function() {
  return gulp
    .src(path.site + '/img/icons/linear/*.svg')
    .pipe($.svgmin({
      plugins: [{
        removeDoctype: true
      }]
    }))
    .pipe($.svgstore())
    .pipe($.cheerio(function($) {
      $('svg').attr('style', 'display:none');
    }))
    .pipe(gulp.dest(path.templates + '/includes/atoms/svg-sprite.svg'));
});

// ===================================================
// Buildin'
// ===================================================

/*
 * foreach is because usemin 0.3.11 won't manipulate
 * multiple files as an array.
 */

gulp.task('usemin', ['assemble', 'sass'], function() {
  return gulp.src(glob.html)
    .pipe($.foreach(function(stream, file) {
      return stream
        .pipe($.usemin({
          assetsDir: path.site,
          css: [ $.rev() ],
          html: [ $.minhtml({ empty: false }) ],
          js: [ $.uglify(), $.rev() ]
        }))
        .pipe(gulp.dest(path.dist));
    }));
});

// ===================================================
// Duplicatin'
// ===================================================

gulp.task('copy', ['usemin'], function() {
  return merge(
    gulp.src([path.site + '/{img,bower_components,js/lib}/**/*'])
        .pipe(gulp.dest(path.dist)),

    gulp.src([
        path.site + '/*.{ico,png,txt}',
        path.site + '/CNAME'
      ]).pipe(gulp.dest(path.dist))
  );
});

// ===================================================
// Releasin'
// ===================================================

gulp.task('deploy', function() {
  return gulp.src([path.dist + '/**/*'])
             .pipe($.ghPages(
                $.if(env_flag === false,
                { branch: 'staging' },
                { branch: 'gh-pages'})
             ));
});

// ===================================================
// Cleanin'
// ===================================================

gulp.task('clean', function(cb) {
  del([
    'dist',
    glob.css,
    glob.html
  ], cb);
});

// ===================================================
// Monitorin'
// ===================================================

gulp.task('watch', function() {
  gulp.watch([
    glob.sass
  ], ['sass']);

  gulp.watch([
    glob.includes,
    glob.pages,
    glob.layouts
  ], ['assemble']);
});

// ===================================================
// Taskin'
// ===================================================

gulp.task('build', [ 'copy','usemin' ]);
gulp.task('default', [ 'sass','assemble','serve','watch' ]);<|endoftext|>


<commit_before>'use strict';

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

require('gulp-grunt')(gulp);

var errorOccured = false;
var paths = {
  scriptsPromise: './lib/jasstor.js',
  scriptsClbk: './lib/jasstorClbk.js',
  tests: ['./test/jasstorPromiseSpec.js', './test/jasstorClbkSpec.js'],
  dist: './dist/jasstor.js'
};

//Submit coverage report to overalls.io
gulp.task('coveralls', ['test', 'checkError'], function () {
  return gulp.src('./coverage/lcov.info').pipe(plugins.coveralls());
});

//This task is here to exit from process with error code
//This way drone.io (CI server) knows that process failed
//It is needed because gulp-plumber forces 0 error code even when error occurs.
gulp.task('checkError', ['test'], function () {
  if (errorOccured) {
    console.log('Err, distor occured, exitting build process... ');
    process.exit(1);
  }
});

var errorHandler = function () {
  console.log('Error occured... ');
  errorOccured = true;
};

var transpilePipe = lazypipe()
  .pipe(plugins.plumber, {
    errorHandler: errorHandler
  })
  .pipe(plugins.jshint)
  .pipe(plugins.jshint.reporter, plugins.stylish)
  .pipe(plugins.jshint.reporter, 'fail')
  .pipe(plugins.traceur);

var registerBuildTask = function (taskNameSuffix, paths) {
  //Compiles ES6 into ES5
  gulp.task('build' + taskNameSuffix, function () {
    return gulp.src(paths)
      .pipe(plugins.plumber({
        errorHandler: errorHandler
      }))
      .pipe(transpilePipe())
      .pipe(plugins.rename('jasstor.js'))
      .pipe(gulp.dest('dist'));
  });
};

gulp.task('testClbk', ['buildCallback'], function () {
  gulp.src(paths.tests)
    .pipe(plugins.plumber({
      errorHandler: errorHandler
    }))
    .pipe(transpilePipe())
    .pipe(gulp.dest('tmp'))
    .pipe(plugins.mocha());
});

//Transpile to ES5 and runs mocha test
gulp.task('test', ['buildPromise'], function (cb) {
  gulp.src([paths.dist])
    .pipe(plugins.plumber({
      errorHandler: errorHandler
    }))
    .pipe(plugins.istanbul())
    .on('finish', function () {
      gulp.src(paths.tests)
        .pipe(plugins.plumber({
          errorHandler: errorHandler
        }))
        .pipe(transpilePipe())
        .pipe(gulp.dest('tmp'))
        .pipe(plugins.mocha())
        .pipe(plugins.istanbul.writeReports())
        .on('end', cb);
    });
});

gulp.task('watch', function () {
  var filesToWatch = paths.tests.concat(paths.scriptsPromise);
  gulp.watch(filesToWatch, ['test']);
});

registerBuildTask('Promise', paths.scriptsPromise);
registerBuildTask('Callback', paths.scriptsClbk);

gulp.task('default', ['test', 'checkError', 'coveralls']);
gulp.task('build', ['test', 'checkError']);
gulp.task('release', ['build', 'grunt-release']);
<commit_msg>Tidy up comments<commit_after>'use strict';

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

require('gulp-grunt')(gulp);

var errorOccured = false;
var paths = {
  scriptsPromise: './lib/jasstor.js',
  scriptsClbk: './lib/jasstorClbk.js',
  tests: ['./test/jasstorPromiseSpec.js', './test/jasstorClbkSpec.js'],
  dist: './dist/jasstor.js'
};

/**
 * Submit coverage report to overalls.io
 */
gulp.task('coveralls', ['test', 'checkError'], function () {
  return gulp.src('./coverage/lcov.info').pipe(plugins.coveralls());
});

/**
 * This task is here to exit from process with error code.
 * This way CI server knows that process failed.
 * It is needed because gulp-plumber forces 0 error code
 * even when error occurs.
 */
gulp.task('checkError', ['test'], function () {
  if (errorOccured) {
    console.log('Err, distor occured, exitting build process... ');
    process.exit(1);
  }
});

var errorHandler = function () {
  console.log('Error occured... ');
  errorOccured = true;
};

var transpilePipe = lazypipe()
  .pipe(plugins.plumber, {
    errorHandler: errorHandler
  })
  .pipe(plugins.jshint)
  .pipe(plugins.jshint.reporter, plugins.stylish)
  .pipe(plugins.jshint.reporter, 'fail')
  .pipe(plugins.traceur);

var registerBuildTask = function (taskNameSuffix, paths) {
  //Compiles ES6 into ES5
  gulp.task('build' + taskNameSuffix, function () {
    return gulp.src(paths)
      .pipe(plugins.plumber({
        errorHandler: errorHandler
      }))
      .pipe(transpilePipe())
      .pipe(plugins.rename('jasstor.js'))
      .pipe(gulp.dest('dist'));
  });
};

gulp.task('testClbk', ['buildCallback'], function () {
  gulp.src(paths.tests)
    .pipe(plugins.plumber({
      errorHandler: errorHandler
    }))
    .pipe(transpilePipe())
    .pipe(gulp.dest('tmp'))
    .pipe(plugins.mocha());
});

//Transpile to ES5 and runs mocha test
gulp.task('test', ['buildPromise'], function (cb) {
  gulp.src([paths.dist])
    .pipe(plugins.plumber({
      errorHandler: errorHandler
    }))
    .pipe(plugins.istanbul())
    .on('finish', function () {
      gulp.src(paths.tests)
        .pipe(plugins.plumber({
          errorHandler: errorHandler
        }))
        .pipe(transpilePipe())
        .pipe(gulp.dest('tmp'))
        .pipe(plugins.mocha())
        .pipe(plugins.istanbul.writeReports())
        .on('end', cb);
    });
});

gulp.task('watch', function () {
  var filesToWatch = paths.tests.concat(paths.scriptsPromise);
  gulp.watch(filesToWatch, ['test']);
});

registerBuildTask('Promise', paths.scriptsPromise);
registerBuildTask('Callback', paths.scriptsClbk);

gulp.task('default', ['test', 'checkError', 'coveralls']);
gulp.task('build', ['test', 'checkError']);
gulp.task('release', ['build', 'grunt-release']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var watch = require('gulp-watch');
var jslint = require('gulp-jslint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var notify = require('gulp-notify');

gulp.task('js', function() {
  gulp.src([
    'js/main.js',
    'js/library.js'
  ])
  .pipe(watch([
    'js/main.js',
    'js/library.js'
  ]))
  .pipe(jslint({
    reporter: function (evt) {
      var msg = ' ' + evt.file;
      if (evt.pass) {
          msg = '[PASS]' + msg;
      } else {
          msg = '[FAIL]' + msg;
      }
      console.log(msg);
    }
  }))
  .pipe(uglify())
  .pipe(rename({suffix: '.min'}))
  .pipe(gulp.dest('js'))
  .pipe(notify({ message: 'Js task complete' }));
});

gulp.task('default', function() {
  // place code for your default task here
});
<commit_msg>fix - gupfile indentation<commit_after>var gulp = require('gulp');
var watch = require('gulp-watch');
var jslint = require('gulp-jslint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var notify = require('gulp-notify');

gulp.task('js', function() {
  gulp.src([
    'js/main.js',
    'js/library.js'
  ])
    .pipe(watch([
      'js/main.js',
      'js/library.js'
    ]))
    .pipe(jslint({
      reporter: function (evt) {
        var msg = ' ' + evt.file;
        if (evt.pass) {
            msg = '[PASS]' + msg;
        } else {
            msg = '[FAIL]' + msg;
        }
        console.log(msg);
      }
    }))
    .pipe(uglify())
    .pipe(rename({suffix: '.min'}))
    .pipe(gulp.dest('js'))
    .pipe(notify({ message: 'Js task complete' }));
});

gulp.task('default', function() {
  // place code for your default task here
});
<|endoftext|>


<commit_before>#!/usr/bin/env node

const autoprefixer = require('gulp-autoprefixer');
const del = require('del');
const gulp = require('gulp');
const rollup = require('gulp-better-rollup')
const concat = require('gulp-concat');
const cleanCSS = require('gulp-clean-css');
const less = require('gulp-less');
const sourcemaps = require('gulp-sourcemaps');
const tweakdom = require('gulp-tweakdom');
const path = require('path');
const babel = require('rollup-plugin-babel')
const commonJS = require('rollup-plugin-commonjs');
const uglify = require('rollup-plugin-uglify');
const uglifyES = require('uglify-es');

gulp.task('css', function() {
  const browsers = ['last 2 versions', 'not IE <= 11'];
  return gulp.src('*.less')
    .pipe(less())
    .pipe(autoprefixer({browsers}))
    .pipe(cleanCSS())
    .pipe(gulp.dest('./dist'));
});

gulp.task('rollup-nomodule', function() {
  // TODO: bring in fetch polyfill
  const options = {
    // nb. ascii_only so escaped emoji are left alone
    plugins: [
      commonJS(),
      babel(),
      uglify({output: {ascii_only: true}}),
    ],
    cache: false,  // cache clobbers rollup
  };
  return gulp.src(['src/support/*.js', 'src/bundle.js'])
    .pipe(sourcemaps.init())
    .pipe(rollup(options, {format: 'iife'}))
    .pipe(concat('support.min.js'))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./dist'));
})

gulp.task('rollup', function() {
  // nb. this task doesn't really depend on rollup-nomodule, but they can't be run in parallel
  const options = {
    // nb. ascii_only so escaped emoji are left alone
    plugins: [
      uglify({output: {ascii_only: true, ecma: 6}, mangle: {safari10: true}}, uglifyES.minify),
    ],
    cache: false,  // cache clobbers rollup-nomodule
  };
  return gulp.src('src/bundle.js')
    .pipe(sourcemaps.init())
    .pipe(rollup(options, {format: 'es'}))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./dist'));
});

gulp.task('html', function() {
  const mutator = (document, file) => {
    if (path.basename(file) !== 'index.html') { return; }

    // replace lessCSS with actual styles
    document.getElementById('less').remove();
    const link = Object.assign(document.createElement('link'),
        {href: 'styles.css', rel: 'stylesheet'});
    document.head.appendChild(link);

    // fix paths for module/nomodule code
    document.head.querySelector('script[nomodule]').src = 'support.min.js';
    document.head.querySelector('script[src^="src/"]').src = 'bundle.js';
  };
  return gulp.src('*.html')
    .pipe(tweakdom(mutator))
    .pipe(gulp.dest('./dist'));
});

gulp.task('static', function() {
  return gulp.src(['manifest.json', 'opensearch.xml', 'res/*'], {base: '.'})
    .pipe(gulp.dest('./dist'));
});

gulp.task('js', ['rollup', 'rollup-nomodule']);
gulp.task('default', ['css', 'js', 'html', 'static']);

gulp.task('clean', function() {
  return del(['./dist'])
});
<commit_msg>exclude -ms-flexbox<commit_after>#!/usr/bin/env node

const autoprefixer = require('gulp-autoprefixer');
const del = require('del');
const gulp = require('gulp');
const rollup = require('gulp-better-rollup')
const concat = require('gulp-concat');
const cleanCSS = require('gulp-clean-css');
const less = require('gulp-less');
const sourcemaps = require('gulp-sourcemaps');
const tweakdom = require('gulp-tweakdom');
const path = require('path');
const babel = require('rollup-plugin-babel')
const commonJS = require('rollup-plugin-commonjs');
const uglify = require('rollup-plugin-uglify');
const uglifyES = require('uglify-es');

gulp.task('css', function() {
  // exclude IE11's broken flexbox
  const browsers = ['last 2 versions', 'not IE <= 11', 'not IE_mob <= 11'];
  return gulp.src('*.less')
    .pipe(less())
    .pipe(autoprefixer({browsers}))
    .pipe(cleanCSS())
    .pipe(gulp.dest('./dist'));
});

gulp.task('rollup-nomodule', function() {
  // TODO: bring in fetch polyfill
  const options = {
    // nb. ascii_only so escaped emoji are left alone
    plugins: [
      commonJS(),
      babel(),
      uglify({output: {ascii_only: true}}),
    ],
    cache: false,  // cache clobbers rollup
  };
  return gulp.src(['src/support/*.js', 'src/bundle.js'])
    .pipe(sourcemaps.init())
    .pipe(rollup(options, {format: 'iife'}))
    .pipe(concat('support.min.js'))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./dist'));
})

gulp.task('rollup', function() {
  // nb. this task doesn't really depend on rollup-nomodule, but they can't be run in parallel
  const options = {
    // nb. ascii_only so escaped emoji are left alone
    plugins: [
      uglify({output: {ascii_only: true, ecma: 6}, mangle: {safari10: true}}, uglifyES.minify),
    ],
    cache: false,  // cache clobbers rollup-nomodule
  };
  return gulp.src('src/bundle.js')
    .pipe(sourcemaps.init())
    .pipe(rollup(options, {format: 'es'}))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./dist'));
});

gulp.task('html', function() {
  const mutator = (document, file) => {
    if (path.basename(file) !== 'index.html') { return; }

    // replace lessCSS with actual styles
    document.getElementById('less').remove();
    const link = Object.assign(document.createElement('link'),
        {href: 'styles.css', rel: 'stylesheet'});
    document.head.appendChild(link);

    // fix paths for module/nomodule code
    document.head.querySelector('script[nomodule]').src = 'support.min.js';
    document.head.querySelector('script[src^="src/"]').src = 'bundle.js';
  };
  return gulp.src('*.html')
    .pipe(tweakdom(mutator))
    .pipe(gulp.dest('./dist'));
});

gulp.task('static', function() {
  return gulp.src(['manifest.json', 'opensearch.xml', 'res/*'], {base: '.'})
    .pipe(gulp.dest('./dist'));
});

gulp.task('js', ['rollup', 'rollup-nomodule']);
gulp.task('default', ['css', 'js', 'html', 'static']);

gulp.task('clean', function() {
  return del(['./dist'])
});
<|endoftext|>


<commit_before>const gulp = require('gulp');
const sass = require('gulp-sass');
const prefix = require('gulp-autoprefixer');
const babelify = require('babelify');
const browserify = require('browserify');
const vinylSource = require('vinyl-source-stream');
const es = require('event-stream');
const flatten = require('gulp-flatten');
const glob = require('glob');

gulp.task('copyStaticFiles', () => gulp.src([
  './src/**/*.*',
  '!./src/js/**/*.js',
  '!./src/sass/**/*.sass',
])
  .pipe(gulp.dest('./dist')));

gulp.task('build', (done) => {
  glob('./src/js/**/*.js', (err, files) => {
    if (err) done(err);
    const tasks = files.map(entry => browserify({
      entries: [entry],
    })
      .transform(babelify)
      .bundle()
      .pipe(vinylSource(entry))
      .pipe(flatten())
      .pipe(gulp.dest('./dist/js')));
    es.merge(tasks).on('end', done);
  });
});

gulp.task('sass', () => gulp.src('./src/sass/main.sass')
  .pipe(sass())
  .pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
  .pipe(gulp.dest('./dist/css')));

gulp.task('default', () => {
  gulp.watch('./src/js/**/*.js', ['build']);
  gulp.watch(['./src/**/*.*', '!./src/js/**/*.js', '!./src/sass/**/*.sass'], ['copyStaticFiles']);
  gulp.watch(['./src/sass/**/*.sass'], ['sass']);
});
<commit_msg>Update gulpfile<commit_after>const gulp = require('gulp');
const sass = require('gulp-sass');
const prefix = require('gulp-autoprefixer');
const babelify = require('babelify');
const browserify = require('browserify');
const vinylSource = require('vinyl-source-stream');
const es = require('event-stream');
const flatten = require('gulp-flatten');
const glob = require('glob');

gulp.task('copyStaticFiles', () => gulp.src([
  './src/**/*.*',
  '!./src/js/**/*.js',
  '!./src/sass/**/*.sass',
])
  .pipe(gulp.dest('./dist')));

gulp.task('build', (done) => {
  glob('./src/js/*.js', (err, files) => {
    if (err) done(err);
    const tasks = files.map(entry => browserify({
      entries: [entry],
    })
      .transform(babelify)
      .bundle()
      .pipe(vinylSource(entry))
      .pipe(flatten())
      .pipe(gulp.dest('./dist/js')));
    es.merge(tasks).on('end', done);
  });
});

gulp.task('sass', () => gulp.src('./src/sass/main.sass')
  .pipe(sass())
  .pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
  .pipe(gulp.dest('./dist/css')));

gulp.task('default', () => {
  gulp.watch('./src/js/**/*.js', ['build']);
  gulp.watch(['./src/**/*.*', '!./src/js/**/*.js', '!./src/sass/**/*.sass'], ['copyStaticFiles']);
  gulp.watch(['./src/sass/**/*.sass'], ['sass']);
});
<|endoftext|>