<commit_before>var gulp = require('gulp')
	, nodemon = require('gulp-nodemon')
	, rjs = require('gulp-requirejs')
  , minifyCss = require('gulp-minify-css')
  , rename = require('gulp-rename')
  , uglify = require('gulp-uglify')
  , protractor = require('gulp-angular-protractor')
  , del = require('del')
  , shell = require('gulp-shell')
  , gutil = require('gulp-util')
  , rename = require("gulp-rename");

gulp.task('minify-js', function(){
	rjs({
    baseUrl : 'src/static/js',
    mainConfigFile: 'src/static/js/main.js',
    out: 'main.min.js',
    name: 'main',
    paths : {
        'angular': "empty:",
        'angular-route': "empty:",
        'jquery': "empty:",
        'bootstrap': "empty:"
    }
  })
  .pipe(uglify())
  .pipe(gulp.dest('src/static/js'));
});

gulp.task('minify-css', function() {
  return gulp.src('src/static/stylesheets/style.css')
    .pipe(minifyCss())
    .pipe(rename('style.min.css'))
    .pipe(gulp.dest('src/static/stylesheets'));
});

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

gulp.task('start', function () {
  return nodemon({
      script: 'src/node/minutedock.js'
      , ext: 'js html'
      , env: { 'NODE_ENV': 'test', 'NODE_CONFIG_DIR': 'config' }
    }).on('error', function(e) { console.error(e); });
});

gulp.task('start-api-stub', function () {
  return nodemon({
      script: 'test/minutedockStub/stub.js'
      , ext: 'js'
      , env: { 'NODE_ENV': 'test' }
    }).on('error', function(e) { console.error(e); });
});

gulp.task('test', ['build', 'start'], function(){
  return gulp.src(['./test/**/*.js'])
    .pipe(protractor({
        'configFile': 'test/conf.js',
        'args': ['--baseUrl', ''],
        'autoStartStopServer': true,
        'debug': true
    }))
    .on('error', function(e) { console.error(e); process.exit(1); })
    .on('end', function() { console.log("Done."); process.exit(); });
});

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

function string_src(filename, string) {
  var src = require('stream').Readable({ objectMode: true })
  src._read = function () {
    this.push(new gutil.File({ cwd: "", base: "", path: filename, contents: new Buffer(string) }))
    this.push(null)
  }
  return src
}

gulp.task('package-src', function(){
  var distFiles = [
    './LICENSE.txt',
    './src/**/*'];

  return gulp.src(distFiles, { base: './' })
  .pipe(gulp.dest('dist'));
});

gulp.task('package-config', function(){
  var configFiles = [
    'config/default.json',
    'config/production.json'
  ];

  return gulp.src(configFiles, { base: './' })
  .pipe(gulp.dest('dist'));
});

gulp.task('package-README', function(){
  var instructions = "1) Install foreverjs \n2) Set NODE_CONFIG with config vars\n3) Run 'npm start'";
  return string_src('README.txt', instructions)
  .pipe(gulp.dest('dist'));
});

gulp.task('package-dependencies', function(){
  var npm_pkg = require('./package.json');
  delete npm_pkg.scripts.test;
  delete npm_pkg.scripts.postinstall;
  npm_pkg.scripts.start = 'ENV=production forever start -a -l minutedock.log -o ./logs/out.log -e ./logs/err.log src/node/minutedock.js';

  return string_src('_package.json', JSON.stringify(npm_pkg))
  .pipe(rename('package.json'))
  .pipe(gulp.dest('dist'));
});

gulp.task('package', ['package-src', 'package-config', 'package-dependencies', 'package-README'], shell.task(['cd dist && mkdir node_modules && mkdir logs && npm install --production']));

gulp.task('default', ['build', 'start']);
<commit_msg>Remove devDependencies from dist package listing<commit_after>var gulp = require('gulp')
	, nodemon = require('gulp-nodemon')
	, rjs = require('gulp-requirejs')
  , minifyCss = require('gulp-minify-css')
  , rename = require('gulp-rename')
  , uglify = require('gulp-uglify')
  , protractor = require('gulp-angular-protractor')
  , del = require('del')
  , shell = require('gulp-shell')
  , gutil = require('gulp-util')
  , rename = require("gulp-rename");

gulp.task('minify-js', function(){
	rjs({
    baseUrl : 'src/static/js',
    mainConfigFile: 'src/static/js/main.js',
    out: 'main.min.js',
    name: 'main',
    paths : {
        'angular': "empty:",
        'angular-route': "empty:",
        'jquery': "empty:",
        'bootstrap': "empty:"
    }
  })
  .pipe(uglify())
  .pipe(gulp.dest('src/static/js'));
});

gulp.task('minify-css', function() {
  return gulp.src('src/static/stylesheets/style.css')
    .pipe(minifyCss())
    .pipe(rename('style.min.css'))
    .pipe(gulp.dest('src/static/stylesheets'));
});

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

gulp.task('start', function () {
  return nodemon({
      script: 'src/node/minutedock.js'
      , ext: 'js html'
      , env: { 'NODE_ENV': 'test', 'NODE_CONFIG_DIR': 'config' }
    }).on('error', function(e) { console.error(e); });
});

gulp.task('start-api-stub', function () {
  return nodemon({
      script: 'test/minutedockStub/stub.js'
      , ext: 'js'
      , env: { 'NODE_ENV': 'test' }
    }).on('error', function(e) { console.error(e); });
});

gulp.task('test', ['build', 'start'], function(){
  return gulp.src(['./test/**/*.js'])
    .pipe(protractor({
        'configFile': 'test/conf.js',
        'args': ['--baseUrl', ''],
        'autoStartStopServer': true,
        'debug': true
    }))
    .on('error', function(e) { console.error(e); process.exit(1); })
    .on('end', function() { console.log("Done."); process.exit(); });
});

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

function string_src(filename, string) {
  var src = require('stream').Readable({ objectMode: true })
  src._read = function () {
    this.push(new gutil.File({ cwd: "", base: "", path: filename, contents: new Buffer(string) }))
    this.push(null)
  }
  return src
}

gulp.task('package-src', function(){
  var distFiles = [
    './LICENSE.txt',
    './src/**/*'];

  return gulp.src(distFiles, { base: './' })
  .pipe(gulp.dest('dist'));
});

gulp.task('package-config', function(){
  var configFiles = [
    'config/default.json',
    'config/production.json'
  ];

  return gulp.src(configFiles, { base: './' })
  .pipe(gulp.dest('dist'));
});

gulp.task('package-README', function(){
  var instructions = "1) Install foreverjs \n2) Set NODE_CONFIG with config vars\n3) Run 'npm start'";
  return string_src('README.txt', instructions)
  .pipe(gulp.dest('dist'));
});

gulp.task('package-dependencies', function(){
  var npm_pkg = require('./package.json');
  delete npm_pkg.scripts.test;
  delete npm_pkg.scripts.postinstall;
  delete npm_pkg.devDependencies;
  npm_pkg.scripts.start = 'ENV=production forever start -a -l minutedock.log -o ./logs/out.log -e ./logs/err.log src/node/minutedock.js';

  return string_src('_package.json', JSON.stringify(npm_pkg))
  .pipe(rename('package.json'))
  .pipe(gulp.dest('dist'));
});

gulp.task('package', ['package-src', 'package-config', 'package-dependencies', 'package-README'], shell.task(['cd dist && mkdir node_modules && mkdir logs && npm install --production']));

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


<commit_before>/* globals __dirname */
var _ = require('underscore');
var args   = require('yargs').argv;
var clean = require('gulp-clean');
var debug = require('gulp-debug');
var eslint = require('gulp-eslint');
var fs = require('fs');
var gulp = require('gulp');
var gulpif = require('gulp-if');
var istanbul = require('gulp-istanbul');
var merge = require('merge-stream');
var mocha = require('gulp-mocha');
var path = require('path');
var peg = require('gulp-peg');
var rename = require("gulp-rename");
var through = require('through2');
// jshint ignore:line
var Promise = require('bluebird');
var marked = require('marked');
var FileResolver = require('./lib/module-resolvers/file-resolver');

var debugOn = args.env === 'debug';

// juttle spec generate tests from markdown
var juttleSpecConvert = require('./test/spec').juttleSpec.convert;
var jspec = function() {
    // I'd promisify this but its not that simple given that we're returning
    // a gulp stream
    return through.obj(function(file, encoding, callback) {
        var markdown = fs.readFileSync(file.path, { encoding: 'utf8' });
        var js = juttleSpecConvert(markdown, { baseDir: __dirname });
        fs.writeFileSync(file.path.replace(/\.[^.]*$/, '.js'), js);
        return callback();
    });
};

gulp.task('juttle-spec-clean', function() {
    return gulp.src('test/runtime/specs/juttle-spec/**/*.js', { read: false })
        .pipe(clean());
});

gulp.task('juttle-spec', ['juttle-spec-clean'], function() {
    return gulp.src('test/runtime/specs/juttle-spec/**/*.md')
        .pipe(jspec());
});

gulp.task('lint-test', function() {
    return gulp.src([
        'test/**/*.spec.js',
        '!test/runtime/specs/juttle-spec/**/*.js'
    ])
	.pipe(eslint())
	.pipe(eslint.format())
	.pipe(eslint.failAfterError());
});

gulp.task('lint-lib', function() {
    return gulp.src([
        'gulpfile.js',
        'bin/juttle',
        'lib/**/*.js',

        // exclude spec files
        '!lib/**/*.spec.js',

        // exclude generated files
        '!lib/moment/parser.js',
        '!lib/parser/parser.js'
    ])
	.pipe(eslint())
	.pipe(eslint.format())
	.pipe(eslint.failAfterError());
});

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

gulp.task('instrument', function () {
    return gulp.src([
        'lib/**/*.js',

        // exclude generated code
        '!lib/moment/parser.js',
        '!lib/parser/parser.js'
    ])
    .pipe(istanbul({
        includeUntested: true
    }))
    .pipe(istanbul.hookRequire());
});

function gulp_test() {
    return gulp.src('test/**/*.spec.js')
        .pipe(mocha({
            log: true,
            timeout: 10000,
            slow: 3000,
            reporter: 'spec',
            ui: 'bdd',
            ignoreLeaks: true,
            globals: ['should']
        }));
}

gulp.task('test', ['peg', 'juttle-spec'], function() {
    return gulp_test();
});

gulp.task('test-coverage', ['peg', 'juttle-spec', 'instrument'], function() {
    return gulp_test()
        .pipe(istanbul.writeReports())
        .pipe(istanbul.enforceThresholds({
            thresholds: {
                global: {
                    statements: 92,
                    branches: 87,
                    functions: 92,
                    lines: 92
                }
            }
        }));
});

gulp.task('peg-clean', function() {
    return gulp.src([
        // remove all of the pegjs generated files
        'lib/parser/parser.js',
        'lib/moment/parser.js',
        //'extlib/points-parser/points-parser.js'
    ], { read: false })
    .pipe(clean());
});

gulp.task('peg', ['peg-clean'], function() {
    var parserJs = gulp.src('lib/parser/parser.pegjs')
    .pipe(peg({
        allowedStartRules: ['start', 'startFilter', 'startValue'],
        cache: true
    }))
    .pipe(gulp.dest('lib/parser'));

    var pointsParserJs = gulp.src('extlib/points-parser/points-parser.pegjs')
    .pipe(peg())
    .pipe(rename('points-parser.js'))
    .pipe(gulp.dest('extlib/points-parser/'));

    return merge(parserJs, pointsParserJs);
});

gulp.task('clean', ['juttle-spec-clean', 'peg-clean']);

gulp.task('examples-check', ['peg'], function() {
    // juttle compile check of the syntax of juttle examples
    var compiler = require('./lib/compiler');
    var optimize = require('./lib/compiler/optimize');
    var implicit_views = require('./lib/compiler/flowgraph/implicit_views');

    // Override the adapter get method to return a dummy object for all
    // adapter types that are used in the examples.
    var adapters = require('./lib/runtime/adapters');
    adapters.get = function(name) { return {}; };
    adapters.isValid = function(name) { return true; };

    var jcompile = function() {
        return through.obj(function(file, encoding, callback) {
            var juttles = [];
            var ext = path.extname(file.path);
            var contents = fs.readFileSync(file.path, "utf8");
            if (ext === '.juttle') {
                juttles = [contents];
            } else if (ext === '.md') {
                var tokens = marked.lexer(contents);
                juttles = _.pluck(_.filter(tokens, function(t) {
                    return t.type === 'code' && t.lang === 'juttle';
                }), 'text');
            } else {
                callback(new Error('invalid file extension' + ext));
                return;
            }
            var file_resolver = new FileResolver();
            Promise.map(juttles, function(juttle_src) {
                return compiler.compile(juttle_src, {
                    stage: 'compile',
                    moduleResolver: file_resolver.resolve,
                    fg_processors: [implicit_views('table'), optimize]
                });
            })
            .then(function() {
                callback();
            })
            .catch(function(err) {
                callback(new Error('checking ' + file.path + ': ' + err));
            });
        });
    };

    return gulp.src([
        'docs/**/*.md',
        'docs/examples/**/*.juttle',
        '!docs/examples/concepts/import_module_from_url.juttle',
        'examples/*.juttle',
        '!examples/invalid.juttle'
    ])
    .pipe(gulpif(debugOn, debug({title: 'Syntax check: '})))
    .pipe(jcompile());
});
<commit_msg>Revert "updating coverage numbers"<commit_after>/* globals __dirname */
var _ = require('underscore');
var args   = require('yargs').argv;
var clean = require('gulp-clean');
var debug = require('gulp-debug');
var eslint = require('gulp-eslint');
var fs = require('fs');
var gulp = require('gulp');
var gulpif = require('gulp-if');
var istanbul = require('gulp-istanbul');
var merge = require('merge-stream');
var mocha = require('gulp-mocha');
var path = require('path');
var peg = require('gulp-peg');
var rename = require("gulp-rename");
var through = require('through2');
// jshint ignore:line
var Promise = require('bluebird');
var marked = require('marked');
var FileResolver = require('./lib/module-resolvers/file-resolver');

var debugOn = args.env === 'debug';

// juttle spec generate tests from markdown
var juttleSpecConvert = require('./test/spec').juttleSpec.convert;
var jspec = function() {
    // I'd promisify this but its not that simple given that we're returning
    // a gulp stream
    return through.obj(function(file, encoding, callback) {
        var markdown = fs.readFileSync(file.path, { encoding: 'utf8' });
        var js = juttleSpecConvert(markdown, { baseDir: __dirname });
        fs.writeFileSync(file.path.replace(/\.[^.]*$/, '.js'), js);
        return callback();
    });
};

gulp.task('juttle-spec-clean', function() {
    return gulp.src('test/runtime/specs/juttle-spec/**/*.js', { read: false })
        .pipe(clean());
});

gulp.task('juttle-spec', ['juttle-spec-clean'], function() {
    return gulp.src('test/runtime/specs/juttle-spec/**/*.md')
        .pipe(jspec());
});

gulp.task('lint-test', function() {
    return gulp.src([
        'test/**/*.spec.js',
        '!test/runtime/specs/juttle-spec/**/*.js'
    ])
	.pipe(eslint())
	.pipe(eslint.format())
	.pipe(eslint.failAfterError());
});

gulp.task('lint-lib', function() {
    return gulp.src([
        'gulpfile.js',
        'bin/juttle',
        'lib/**/*.js',

        // exclude spec files
        '!lib/**/*.spec.js',

        // exclude generated files
        '!lib/moment/parser.js',
        '!lib/parser/parser.js'
    ])
	.pipe(eslint())
	.pipe(eslint.format())
	.pipe(eslint.failAfterError());
});

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

gulp.task('instrument', function () {
    return gulp.src([
        'lib/**/*.js',

        // exclude generated code
        '!lib/moment/parser.js',
        '!lib/parser/parser.js'
    ])
    .pipe(istanbul({
        includeUntested: true
    }))
    .pipe(istanbul.hookRequire());
});

function gulp_test() {
    return gulp.src('test/**/*.spec.js')
        .pipe(mocha({
            log: true,
            timeout: 10000,
            slow: 3000,
            reporter: 'spec',
            ui: 'bdd',
            ignoreLeaks: true,
            globals: ['should']
        }));
}

gulp.task('test', ['peg', 'juttle-spec'], function() {
    return gulp_test();
});

gulp.task('test-coverage', ['peg', 'juttle-spec', 'instrument'], function() {
    return gulp_test()
        .pipe(istanbul.writeReports())
        .pipe(istanbul.enforceThresholds({
            thresholds: {
                global: {
                    statements: 92,
                    branches: 86,
                    functions: 91,
                    lines: 92
                }
            }
        }));
});

gulp.task('peg-clean', function() {
    return gulp.src([
        // remove all of the pegjs generated files
        'lib/parser/parser.js',
        'lib/moment/parser.js',
        //'extlib/points-parser/points-parser.js'
    ], { read: false })
    .pipe(clean());
});

gulp.task('peg', ['peg-clean'], function() {
    var parserJs = gulp.src('lib/parser/parser.pegjs')
    .pipe(peg({
        allowedStartRules: ['start', 'startFilter', 'startValue'],
        cache: true
    }))
    .pipe(gulp.dest('lib/parser'));

    var pointsParserJs = gulp.src('extlib/points-parser/points-parser.pegjs')
    .pipe(peg())
    .pipe(rename('points-parser.js'))
    .pipe(gulp.dest('extlib/points-parser/'));

    return merge(parserJs, pointsParserJs);
});

gulp.task('clean', ['juttle-spec-clean', 'peg-clean']);

gulp.task('examples-check', ['peg'], function() {
    // juttle compile check of the syntax of juttle examples
    var compiler = require('./lib/compiler');
    var optimize = require('./lib/compiler/optimize');
    var implicit_views = require('./lib/compiler/flowgraph/implicit_views');

    // Override the adapter get method to return a dummy object for all
    // adapter types that are used in the examples.
    var adapters = require('./lib/runtime/adapters');
    adapters.get = function(name) { return {}; };
    adapters.isValid = function(name) { return true; };

    var jcompile = function() {
        return through.obj(function(file, encoding, callback) {
            var juttles = [];
            var ext = path.extname(file.path);
            var contents = fs.readFileSync(file.path, "utf8");
            if (ext === '.juttle') {
                juttles = [contents];
            } else if (ext === '.md') {
                var tokens = marked.lexer(contents);
                juttles = _.pluck(_.filter(tokens, function(t) {
                    return t.type === 'code' && t.lang === 'juttle';
                }), 'text');
            } else {
                callback(new Error('invalid file extension' + ext));
                return;
            }
            var file_resolver = new FileResolver();
            Promise.map(juttles, function(juttle_src) {
                return compiler.compile(juttle_src, {
                    stage: 'compile',
                    moduleResolver: file_resolver.resolve,
                    fg_processors: [implicit_views('table'), optimize]
                });
            })
            .then(function() {
                callback();
            })
            .catch(function(err) {
                callback(new Error('checking ' + file.path + ': ' + err));
            });
        });
    };

    return gulp.src([
        'docs/**/*.md',
        'docs/examples/**/*.juttle',
        '!docs/examples/concepts/import_module_from_url.juttle',
        'examples/*.juttle',
        '!examples/invalid.juttle'
    ])
    .pipe(gulpif(debugOn, debug({title: 'Syntax check: '})))
    .pipe(jcompile());
});
<|endoftext|>


<commit_before>import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import Caret from '../Caret';

class Breadcrumb extends Component {
  render() {
    const { url, label } = this.props;

    return (
      <Link to={url} className="breadcrumb" title={label ? '« #{label}' : null}>
        <Caret left />
        {label ? {label} : null}
      </Link>
    );
  }
}

export default Breadcrumb;
<commit_msg>Fix string template format in header breadcrumb<commit_after>import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import Caret from '../Caret';

class Breadcrumb extends Component {
  render() {
    const { url, label } = this.props;

    return (
      <Link to={url} className="breadcrumb" title={label ? `« ${label}` : null}>
        <Caret left />
        {label ? {label} : null}
      </Link>
    );
  }
}

export default Breadcrumb;
<|endoftext|>


<commit_before>var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var autoprefixer = require('autoprefixer');
var scss = require('postcss-scss');
var stylelint = require('stylelint');
var browserSync = require('browser-sync').create();
var config = {
	'src': './',
	'dest': 'dist/',
	'minify': true,
	'sourcemaps': false,
	'browsers': [
		'last 2 versions',
		'android >= 2.3',
		'safari >= 6',
		'ie >= 9'
	]
};

// HTML
gulp.task('html', function() {
	return gulp.src('*.html')
		.pipe(browserSync.stream());
});

// Compile and autoprefix stylesheets
gulp.task('styles', function() {
	return gulp.src(config.src + 'scss/**/*.scss')
		.pipe($.if(config.sourcemaps, $.sourcemaps.init()))
		.pipe($.sass({
			precision: 8,
			outputStyle: 'expanded'
		}).on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe($.postcss([
			autoprefixer({
				browsers: config.browsers
			})
		]))
		.pipe(gulp.dest(config.dest + 'css'))
		.pipe(browserSync.stream())
		.pipe($.cleanCss({compatibility: 'ie8'}))
		.pipe($.if(config.sourcemaps, $.sourcemaps.write()))
		.pipe($.rename({suffix: '.min'}))
		.pipe($.if(config.minify, gulp.dest(config.dest + 'css')))
		.pipe(browserSync.stream());
});

// Lint stylesheets
gulp.task('stylelint', function() {
	return gulp.src(config.src + 'scss/**/*.scss')
		.pipe($.postcss([
			stylelint()
		], {
			syntax: scss
		}));
});

// Compile javascript
gulp.task('scripts', function() {
	return gulp.src(config.src + 'js/*.js')
		.pipe($.include().on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe(gulp.dest(config.dest + 'js'))
		.pipe(browserSync.stream())
		.pipe($.if(config.sourcemaps, $.sourcemaps.init()))
		.pipe($.uglify().on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe($.if(config.sourcemaps, $.sourcemaps.write()))
		.pipe($.rename({suffix: '.min'}))
		.pipe($.if(config.minify, gulp.dest(config.dest + 'js')))
		.pipe(browserSync.stream());
});

// Optimize images
gulp.task('images', function() {
	return gulp.src(config.src + 'img/**/*.{gif,jpg,png,svg}')
		.pipe($.cache($.imagemin()))
		.pipe(gulp.dest(config.dest + 'img'))
		.pipe(browserSync.stream());
});

// Build production files
gulp.task('build', ['html', 'styles', 'scripts', 'images']);

// Serve compiled files
gulp.task('serve', ['build'], function() {
	browserSync.init({
		server: true,
		notify: false,
		snippetOptions: {
			rule: {
				match: /<\/body>/i
			}
		}
	});
});

// Watch files for changes
gulp.task('watch', function() {
	gulp.watch('*.html', ['html']);
	gulp.watch(config.src + 'scss/**/*.scss', ['styles']);
	gulp.watch(config.src + 'js/**/*.js', ['scripts']);
	gulp.watch(config.src + 'img/**/*.{gif,jpg,png,svg}', ['images']);
});

// Run all tasks
gulp.task('default', ['serve', 'watch']);
<commit_msg>Simplify stylelint task<commit_after>var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var autoprefixer = require('autoprefixer');
var browserSync = require('browser-sync').create();
var config = {
	'src': './',
	'dest': 'dist/',
	'minify': true,
	'sourcemaps': false,
	'browsers': [
		'last 2 versions',
		'android >= 2.3',
		'safari >= 6',
		'ie >= 9'
	]
};

// HTML
gulp.task('html', function() {
	return gulp.src('*.html')
		.pipe(browserSync.stream());
});

// Compile and autoprefix stylesheets
gulp.task('styles', function() {
	return gulp.src(config.src + 'scss/**/*.scss')
		.pipe($.if(config.sourcemaps, $.sourcemaps.init()))
		.pipe($.sass({
			precision: 8,
			outputStyle: 'expanded'
		}).on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe($.postcss([
			autoprefixer({
				browsers: config.browsers
			})
		]))
		.pipe(gulp.dest(config.dest + 'css'))
		.pipe(browserSync.stream())
		.pipe($.cleanCss({compatibility: 'ie8'}))
		.pipe($.if(config.sourcemaps, $.sourcemaps.write()))
		.pipe($.rename({suffix: '.min'}))
		.pipe($.if(config.minify, gulp.dest(config.dest + 'css')))
		.pipe(browserSync.stream());
});

// Lint stylesheets
gulp.task('stylelint', function() {
	return gulp.src(config.src + 'scss/**/*.scss')
		.pipe($.postcss([
			require('stylelint')
		], {
			syntax: require('postcss-scss')
		}));
});

// Compile javascript
gulp.task('scripts', function() {
	return gulp.src(config.src + 'js/*.js')
		.pipe($.include().on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe(gulp.dest(config.dest + 'js'))
		.pipe(browserSync.stream())
		.pipe($.if(config.sourcemaps, $.sourcemaps.init()))
		.pipe($.uglify().on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe($.if(config.sourcemaps, $.sourcemaps.write()))
		.pipe($.rename({suffix: '.min'}))
		.pipe($.if(config.minify, gulp.dest(config.dest + 'js')))
		.pipe(browserSync.stream());
});

// Optimize images
gulp.task('images', function() {
	return gulp.src(config.src + 'img/**/*.{gif,jpg,png,svg}')
		.pipe($.cache($.imagemin()))
		.pipe(gulp.dest(config.dest + 'img'))
		.pipe(browserSync.stream());
});

// Build production files
gulp.task('build', ['html', 'styles', 'scripts', 'images']);

// Serve compiled files
gulp.task('serve', ['build'], function() {
	browserSync.init({
		server: true,
		notify: false,
		snippetOptions: {
			rule: {
				match: /<\/body>/i
			}
		}
	});
});

// Watch files for changes
gulp.task('watch', function() {
	gulp.watch('*.html', ['html']);
	gulp.watch(config.src + 'scss/**/*.scss', ['styles']);
	gulp.watch(config.src + 'js/**/*.js', ['scripts']);
	gulp.watch(config.src + 'img/**/*.{gif,jpg,png,svg}', ['images']);
});

// Run all tasks
gulp.task('default', ['serve', 'watch']);
<|endoftext|>


<commit_before>'use strict';

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

var Config = require('./tasks/config');

require('./tasks/lint');
require('./tasks/html');
require('./tasks/images');
require('./tasks/swagger');
require('./tasks/s3');
require('./tasks/tests');
require('./tasks/ci');
require('./tasks/28');
require('./tasks/netdna');

gulp.task('watch', function() {
    return gulp.watch(Config.paths.less, ['less']);
});

gulp.task('install', function() {
  return bower.commands.install()
    .on('log', function(data) {
      $.gutil.log('bower', $.gutil.colors.cyan(data.id), data.message);
    });
});

gulp.task('fonts', function(){
    return gulp.src('bower_components/font-awesome/fonts/*', { dot: true }).pipe(gulp.dest(Config.paths.dist + '/fonts'));
});

gulp.task('copy-swagger', function(){
    return gulp.src('swagger/*', { dot: true }).pipe(gulp.dest(Config.paths.dist + '/swagger'));
});

gulp.task('copy-svg', function(){
    return gulp.src(Config.paths.svgs, { dot: true }).pipe(gulp.dest(Config.paths.dist + '/images'));
});

gulp.task('extras', function () {
    var extras = Config.paths.html.concat(Config.paths.fonts);
    return gulp.src(extras, { dot: true })
        .pipe(gulp.dest(Config.paths.dist));
});

gulp.task('clean', function () {
    return gulp.src([Config.paths.tmp, Config.paths.dist], { read: false }).pipe($.clean());
});

gulp.task('build', ['clean', 'swagger'], function(done){
    $.runSequence(['load-config', 'lint', 'html', 'images', 'fonts', 'copy-swagger', 'copy-svg', 'extras'], done);
});

gulp.task('server', ['less', 'swagger', 'decrypt'], function(done){
    $.runSequence('server:dev', done);
});

gulp.task('server:prod', ['build'], function(done){
    $.runSequence('server:dist', done);
});

gulp.task('test', ['server:prod'], function (done) {
    $.runSequence('test:e2e', done);
});

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

gulp.task('setup', function(done){
    $.runSequence('build', 's3-setup', '28:setup', 'server:dist', 'test:unit', 'test:e2e', 'server:stop', done);
});

gulp.task('28:setup', ['load-config'], function(done){
    $.runSequence('28:login', '28:remove-project', '28:create-project', '28:setup-datasource', '28:upload', '28:init', '28:test', done);
});

gulp.task('teardown', ['load-config'], function(done){
    $.runSequence('28:login', '28:remove-project', 's3-teardown', done);
});
<commit_msg>Remove unused task<commit_after>'use strict';

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

var Config = require('./tasks/config');

require('./tasks/lint');
require('./tasks/html');
require('./tasks/images');
require('./tasks/swagger');
require('./tasks/s3');
require('./tasks/tests');
require('./tasks/ci');
require('./tasks/28');
require('./tasks/netdna');

gulp.task('watch', function() {
    return gulp.watch(Config.paths.less, ['less']);
});

gulp.task('fonts', function(){
    return gulp.src('bower_components/font-awesome/fonts/*', { dot: true }).pipe(gulp.dest(Config.paths.dist + '/fonts'));
});

gulp.task('copy-swagger', function(){
    return gulp.src('swagger/*', { dot: true }).pipe(gulp.dest(Config.paths.dist + '/swagger'));
});

gulp.task('copy-svg', function(){
    return gulp.src(Config.paths.svgs, { dot: true }).pipe(gulp.dest(Config.paths.dist + '/images'));
});

gulp.task('extras', function () {
    var extras = Config.paths.html.concat(Config.paths.fonts);
    return gulp.src(extras, { dot: true })
        .pipe(gulp.dest(Config.paths.dist));
});

gulp.task('clean', function () {
    return gulp.src([Config.paths.tmp, Config.paths.dist], { read: false }).pipe($.clean());
});

gulp.task('build', ['clean', 'swagger'], function(done){
    $.runSequence(['load-config', 'lint', 'html', 'images', 'fonts', 'copy-swagger', 'copy-svg', 'extras'], done);
});

gulp.task('server', ['less', 'swagger', 'decrypt'], function(done){
    $.runSequence('server:dev', done);
});

gulp.task('server:prod', ['build'], function(done){
    $.runSequence('server:dist', done);
});

gulp.task('test', ['server:prod'], function (done) {
    $.runSequence('test:e2e', done);
});

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

gulp.task('setup', function(done){
    $.runSequence('build', 's3-setup', '28:setup', 'server:dist', 'test:unit', 'test:e2e', 'server:stop', done);
});

gulp.task('28:setup', ['load-config'], function(done){
    $.runSequence('28:login', '28:remove-project', '28:create-project', '28:setup-datasource', '28:upload', '28:init', '28:test', done);
});

gulp.task('teardown', ['load-config'], function(done){
    $.runSequence('28:login', '28:remove-project', 's3-teardown', done);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var watch = require('gulp-watch');
var gutil = require('gulp-util');
var taskListing = require('gulp-task-listing');
var path = require('canonical-path');
var del = require('del');
var _ = require('lodash');
var Git = require("nodegit");
var argv = require('yargs').argv;
var Q = require("q");
// delPromise is a 'promise' version of del
var delPromise =  Q.denodeify(del);
var Minimatch = require("minimatch").Minimatch;
var Dgeni = require('dgeni');
var fsExtra = require('fs-extra');
var fs = fsExtra;
var exec = require('child_process').exec;
var execPromise = Q.denodeify(exec);
var prompt = require('prompt');

// TODO:
//  1. Think about using runSequence
//  2. Think about using spawn instead of exec in case of long error messages.

var docShredder = require('./public/doc-shredder/doc-shredder');

var _devguideShredOptions =  {
  examplesDir: './public/docs/_examples',
  fragmentsDir: './public/docs/_fragments'
};

var _apiShredOptions =  {
  examplesDir: '../angular/modules/angular2/examples',
  fragmentsDir: './public/docs/_fragments/_api'
};

var _excludePatterns = ["**/node_modules/**", "**/typings/**"];

var _excludeMatchers = _excludePatterns.map(function(excludePattern){
  return new Minimatch(excludePattern)
});

gulp.task('help', taskListing.withFilters(function(taskName) {
  var isSubTask = taskName.substr(0,1) == "_";
  return isSubTask;
}, function(taskName) {
  var shouldRemove = taskName === 'default';
  return shouldRemove;
}));

gulp.task('serve-and-sync', ['build-docs'], function (cb) {

  // execCommands(['harp server'], {}, cb);
  execCommands(['npm run harp -- server .'], {}, cb);

  var browserSync = require('browser-sync').create();
  browserSync.init({
    proxy: 'localhost:9000',
    files: ["public/docs/**/*/**/*" ],
    logFileChanges: true,
    reloadDelay: 500
  });

  devGuideExamplesWatch(_devguideShredOptions, function() {
    browserSync.reload();
  });

  apiSourceWatch(function() {
    browserSync.reload();
  });

});

gulp.task('serve-and-watch', function (cb) {
  execCommands(['npm run harp -- server .'], {}, cb);
  devGuideExamplesWatch(_devguideShredOptions);
});

gulp.task('build-docs', ['_shred-devguide-examples', 'build-api-docs'], function() {
  return buildShredMaps(true);
});

gulp.task('build-devguide-docs', ['_shred-devguide-examples'], function() {
  return buildShredMaps(true);
});

gulp.task('build-api-docs', ['_shred-api-examples'], function() {
  if (!fs.existsSync('../angular')) {
    throw new Error('build-api-docs task requires the angular2 repo to be at ' + path.resolve('../angular'));
  }
  return buildApiDocs();
});

gulp.task('_shred-devguide-examples', ['_shred-clean-devguide'], function() {
  return docShredder.shred( _devguideShredOptions);
});

gulp.task('_shred-clean-devguide', function(cb) {
  var cleanPath = path.join(_devguideShredOptions.fragmentsDir, '**/*.*')
  return delPromise([ cleanPath, '!**/*.ovr.*', '!**/_api/**']);
});

gulp.task('_shred-api-examples', ['_shred-clean-api'], function() {
  return docShredder.shred( _apiShredOptions);
});

gulp.task('_shred-clean-api', function(cb) {
  var cleanPath = path.join(_apiShredOptions.fragmentsDir, '**/*.*')
  return delPromise([ cleanPath, '!**/*.ovr.*' ]);
});

gulp.task('_build-shred-maps', function() {
  return build-shred-maps(true);
});

gulp.task('git-changed-examples', ['_shred-devguide-examples'], function(){
  var after, sha, messageSuffix;
  if (argv.after) {
    try {
      after = new Date(argv.after);
      messageSuffix = ' after: ' + argv.after;
    } catch (e) {
      throw argv.after + " is not a valid date.";
    }
  } else if (argv.sha) {
    sha = argv.sha;
    messageSuffix = ' on commit: ' + (argv.sha.length ? argv.sha : '[last commit]');
  } else {
    console.log('git-changed-examples may be called with either an "--sha" argument like this:');
    console.log('   gulp git-changed-examples --sha=4d2ac96fa247306ddd2d4c4e0c8dee2223502eb2');
    console.log('or with an "--after" argument like this')
    console.log('   gulp git-changed-examples --after="August 1, 2015"');
    return;
  }
  var jadeShredMap;
  return buildShredMaps(false).then(function(docs) {
    jadeShredMap = docs[0];
    if (after) {
      return getChangedExamplesAfter(after);
    } else if (sha) {
      return getChangedExamples(sha);
    } else {
      console.log('git-changed-examples may be called with either an "--sha" argument like this:');
      console.log('   gulp git-changed-examples --sha=4d2ac96fa247306ddd2d4c4e0c8dee2223502eb2');
      console.log('or with an "--after" argument like this')
      console.log('   gulp git-changed-examples --after="August 1, 2015"');
    }
  }).then(function(examplePaths) {
    examplePaths = filterOutExcludedPatterns(examplePaths, _excludeMatchers);
    console.log('\nExamples changed ' + messageSuffix);
    console.log(examplePaths)
    console.log("\nJade files affected by changed example files " + messageSuffix);
    var jadeExampleMap = jadeShredMapToJadeExampleMap(jadeShredMap, examplePaths);
    console.log(JSON.stringify(jadeExampleMap, null, "  "));
    console.log("-----");
  }).catch(function(err) {
    console.log(err);
    throw err;
  });
});

gulp.task('check-deploy', function() {
  console.log('running harp compile...');
  return execPromise('npm run harp -- compile . ./www', {}).then(function() {
    execPromise('npm run live-server ./www');
    return askDeploy();
  }).then(function(shouldDeploy) {
    if (shouldDeploy) {
      console.log('deploying...');
      return execPromise('firebase deploy');
    } else {
      return ['Not deploying'];
    }
  }).then(function(s) {
    console.log(s.join(''));
  });
});

// returns a promise;
function askDeploy() {

  prompt.start();
  var schema = {
    name: 'shouldDeploy',
    description: 'Deploy to Firebase? (y/n): ',
    type: 'string',
    pattern: /Y|N|y|n/,
    message: "Respond with either a 'y' or 'n'",
    required: true
  }
  var getPromise = Q.denodeify(prompt.get);
  return getPromise([schema]).then(function(result) {
    return result.shouldDeploy.toLowerCase() === 'y';
  });
}

gulp.task('test-api-builder', function (cb) {
  execCommands(['npm run test-api-builder'], {}, cb);
});

function filterOutExcludedPatterns(fileNames, excludeMatchers) {
  return fileNames.filter(function(fileName) {
    return !excludeMatchers.some(function(excludeMatcher) {
      return excludeMatcher.match(fileName);
    });
  });
}

function apiSourceWatch(postShredAction) {
  var srcPattern = ['../angular/modules/angular2/src/**/*.*'];
  watch(srcPattern, function (event, done) {
    console.log('Event type: ' + event.event); // added, changed, or deleted
    console.log('Event path: ' + event.path); // The path of the modified file
    // need to run just build
    buildApiDocs().then(done);
  });
  var examplesPattern = ['../angular/modules/angular2/examples/**/*.*'];
  watch(examplesPattern, function (event, done) {
    console.log('Event type: ' + event.event); // added, changed, or deleted
    console.log('Event path: ' + event.path); // The path of the modified file
    // need to run shredder
    var cleanPath = path.join(_apiShredOptions.fragmentsDir, '**/*.*');
    return delPromise([ cleanPath, '!**/*.ovr.*' ]).then(function() {
      return docShredder.shred(_apiShredOptions);
    }).then(function() {
      postShredAction && postShredAction();
    });
  });

}

function buildApiDocs() {
  try {
    var dgeni = new Dgeni([require('./public/api-builder/angular.io-package')]);
    return dgeni.generate().then(function() {
      return gulp.src('./public/docs/js/latest/api/**/*.*')
        .pipe(gulp.dest('./public/docs/ts/latest/api'));
    })
  } catch(err) {
    console.log(err);
    console.log(err.stack);
    throw err;
  }
}

function devGuideExamplesWatch(shredOptions, postShredAction) {
  var pattern = path.join(shredOptions.examplesDir, "**/*.*");
  watch([pattern], function (event, done) {
    console.log('Event type: ' + event.event); // added, changed, or deleted
    console.log('Event path: ' + event.path); // The path of the modified file
    docShredder.shredSingleDir(shredOptions, event.path).then(function () {
      postShredAction && postShredAction();
    });
  });
}

function buildShredMaps(shouldWrite) {
  var options = {
    devguideExamplesDir: _devguideShredOptions.examplesDir,
    apiExamplesDir: _apiShredOptions.examplesDir,
    fragmentsDir: _devguideShredOptions.fragmentsDir,
    jadeDir: './public/docs',
    outputDir: './public/docs',
    writeFilesEnabled: shouldWrite
  };
  return docShredder.buildShredMap(options).then(function(docs) {
    return docs;
  });
}

// returns a promise containing filePaths with any changed or added examples;
function getChangedExamples(sha) {
  var examplesPath = _devguideShredOptions.examplesDir;
  var relativePath = path.relative(process.cwd(), examplesPath);
  return Git.Repository.open(".").then(function(repo) {
    if (sha.length) {
      return repo.getCommit(sha);
    } else {
      return repo.getHeadCommit();
    }
  }).then(function(commit) {
    return getChangedExamplesForCommit(commit, relativePath);
  }).catch(function(err) {

  });
}

function getChangedExamplesAfter(date, relativePath) {
  var examplesPath = _devguideShredOptions.examplesDir;
  var relativePath = path.relative(process.cwd(), examplesPath);
  return Git.Repository.open(".").then(function(repo) {
    return repo.getHeadCommit();
  }).then(function(commit) {
    var repo = commit.owner();
    var revWalker = repo.createRevWalk();
    revWalker.sorting(Git.Revwalk.SORT.TIME);
    revWalker.push(commit.id());
    return revWalker.getCommitsUntil(function (commit) {
      return commit.date().getTime() > date.getTime();
    });
  }).then(function(commits) {
    return Q.all(commits.map(function(commit) {
      return getChangedExamplesForCommit(commit, relativePath);
    }));
  }).then(function(arrayOfPaths) {
    var pathMap = {};
    arrayOfPaths.forEach(function(paths) {
      paths.forEach(function(path) {
        pathMap[path] = true;
      });
    });
    var uniqPaths = _.keys(pathMap);
    return uniqPaths;
  }).catch(function(err) {
    var x = err;
  });

}

function getChangedExamplesForCommit(commit, relativePath) {
  return commit.getDiff().then(function(diffList) {
    var filePaths = [];
    diffList.forEach(function (diff) {
      diff.patches().forEach(function (patch) {
        if (patch.isAdded() || patch.isModified) {
          var filePath = path.normalize(patch.newFile().path());
          var isExample = filePath.indexOf(relativePath) >= 0;
          // console.log(filePath + " isExample: " + isExample);
          if (isExample) {
            filePaths.push(filePath);
          }
        }
      });
    });
    return filePaths;
  });
}

function jadeShredMapToJadeExampleMap(jadeShredMap, examplePaths) {
  // remove dups in examplePaths
  var exampleSet = {};
  examplePaths.forEach(function(examplePath) {
    exampleSet[examplePath] = examplePath;
  });
  var basePath = path.resolve(".");
  var jadeToFragMap = jadeShredMap.jadeToFragMap;
  var jadeExampleMap = {};
  for (var jadePath in jadeToFragMap) {
    var relativeJadePath = path.relative(basePath, jadePath);
    var vals = jadeToFragMap[jadePath];
    vals.forEach(function(val) {
      var relativeExamplePath = path.relative(basePath, val.examplePath);
      if (exampleSet[relativeExamplePath] != null) {
        addKeyValue(jadeExampleMap, relativeJadePath, relativeExamplePath);
      }
    });
  }
  return jadeExampleMap;
}

function jadeShredMapToExampleJadeMap(jadeShredMap) {

  var jadeToFragMap = jadeShredMap.jadeToFragMap;
  var exampleJadeMap = {};
  for (var jadePath in jadeToFragMap) {
    var vals = jadeToFragMap[jadePath];
    vals.forEach(function(val) {
      var examplePath = val.examplePath;
      addKeyValue(exampleJadeMap, examplePath, jadePath);
    });
  }
  return exampleJadeMap;
}

function addKeyValue(map, key, value) {
  var vals = map[key];
  if (vals) {
    if (vals.indexOf(value) == -1) {
      vals.push(value);
    }
  } else {
    map[key] = [value];
  }
}

// Synchronously execute a chain of commands.
// cmds: an array of commands
// options: { shouldLog: true,  shouldThrow: true }
// cb: function(err, stdout, stderr)
function execCommands(cmds, options, cb) {
  options = options || {};
  options.shouldThrow = options.shouldThrow == null ? true : options.shouldThrow;
  options.shouldLog = options.shouldLog == null ? true : options.shouldLog;
  if (!cmds || cmds.length == 0) cb(null, null, null);
  var exec = require('child_process').exec;  // just to make it more portable.
  exec(cmds[0], options, function(err, stdout, stderr) {
    if (err == null) {
      if (options.shouldLog) {
        gutil.log('cmd: ' + cmds[0]);
        gutil.log('stdout: ' + stdout);
      }
      if (cmds.length == 1) {
        cb(err, stdout, stderr);
      } else {
        execCommands(cmds.slice(1), options, cb);
      }
    } else {
      if (options.shouldLog) {
        gutil.log('exec error on cmd: ' + cmds[0]);
        gutil.log('exec error: ' + err);
        if (stdout) gutil.log('stdout: ' + stdout);
        if (stderr) gutil.log('stderr: ' + stderr);
      }
      if (err && options.shouldThrow) throw err;
      cb(err, stdout, stderr);
    }
  });
}

gulp.task('default', ['help']);<commit_msg>check-deploy gulp task now builds all docs before deploying.<commit_after>var gulp = require('gulp');
var watch = require('gulp-watch');
var gutil = require('gulp-util');
var taskListing = require('gulp-task-listing');
var path = require('canonical-path');
var del = require('del');
var _ = require('lodash');
var Git = require("nodegit");
var argv = require('yargs').argv;
var Q = require("q");
// delPromise is a 'promise' version of del
var delPromise =  Q.denodeify(del);
var Minimatch = require("minimatch").Minimatch;
var Dgeni = require('dgeni');
var fsExtra = require('fs-extra');
var fs = fsExtra;
var exec = require('child_process').exec;
var execPromise = Q.denodeify(exec);
var prompt = require('prompt');

// TODO:
//  1. Think about using runSequence
//  2. Think about using spawn instead of exec in case of long error messages.

var docShredder = require('./public/doc-shredder/doc-shredder');

var _devguideShredOptions =  {
  examplesDir: './public/docs/_examples',
  fragmentsDir: './public/docs/_fragments'
};

var _apiShredOptions =  {
  examplesDir: '../angular/modules/angular2/examples',
  fragmentsDir: './public/docs/_fragments/_api'
};

var _excludePatterns = ["**/node_modules/**", "**/typings/**"];

var _excludeMatchers = _excludePatterns.map(function(excludePattern){
  return new Minimatch(excludePattern)
});

gulp.task('help', taskListing.withFilters(function(taskName) {
  var isSubTask = taskName.substr(0,1) == "_";
  return isSubTask;
}, function(taskName) {
  var shouldRemove = taskName === 'default';
  return shouldRemove;
}));

gulp.task('serve-and-sync', ['build-docs'], function (cb) {

  // execCommands(['harp server'], {}, cb);
  execCommands(['npm run harp -- server .'], {}, cb);

  var browserSync = require('browser-sync').create();
  browserSync.init({
    proxy: 'localhost:9000',
    files: ["public/docs/**/*/**/*" ],
    logFileChanges: true,
    reloadDelay: 500
  });

  devGuideExamplesWatch(_devguideShredOptions, function() {
    browserSync.reload();
  });

  apiSourceWatch(function() {
    browserSync.reload();
  });

});

gulp.task('serve-and-watch', function (cb) {
  execCommands(['npm run harp -- server .'], {}, cb);
  devGuideExamplesWatch(_devguideShredOptions);
});

gulp.task('build-docs', ['_shred-devguide-examples', 'build-api-docs'], function() {
  return buildShredMaps(true);
});

gulp.task('build-devguide-docs', ['_shred-devguide-examples'], function() {
  return buildShredMaps(true);
});

gulp.task('build-api-docs', ['_shred-api-examples'], function() {
  if (!fs.existsSync('../angular')) {
    throw new Error('build-api-docs task requires the angular2 repo to be at ' + path.resolve('../angular'));
  }
  return buildApiDocs();
});

gulp.task('_shred-devguide-examples', ['_shred-clean-devguide'], function() {
  return docShredder.shred( _devguideShredOptions);
});

gulp.task('_shred-clean-devguide', function(cb) {
  var cleanPath = path.join(_devguideShredOptions.fragmentsDir, '**/*.*')
  return delPromise([ cleanPath, '!**/*.ovr.*', '!**/_api/**']);
});

gulp.task('_shred-api-examples', ['_shred-clean-api'], function() {
  return docShredder.shred( _apiShredOptions);
});

gulp.task('_shred-clean-api', function(cb) {
  var cleanPath = path.join(_apiShredOptions.fragmentsDir, '**/*.*')
  return delPromise([ cleanPath, '!**/*.ovr.*' ]);
});

gulp.task('_build-shred-maps', function() {
  return build-shred-maps(true);
});

gulp.task('git-changed-examples', ['_shred-devguide-examples'], function(){
  var after, sha, messageSuffix;
  if (argv.after) {
    try {
      after = new Date(argv.after);
      messageSuffix = ' after: ' + argv.after;
    } catch (e) {
      throw argv.after + " is not a valid date.";
    }
  } else if (argv.sha) {
    sha = argv.sha;
    messageSuffix = ' on commit: ' + (argv.sha.length ? argv.sha : '[last commit]');
  } else {
    console.log('git-changed-examples may be called with either an "--sha" argument like this:');
    console.log('   gulp git-changed-examples --sha=4d2ac96fa247306ddd2d4c4e0c8dee2223502eb2');
    console.log('or with an "--after" argument like this')
    console.log('   gulp git-changed-examples --after="August 1, 2015"');
    return;
  }
  var jadeShredMap;
  return buildShredMaps(false).then(function(docs) {
    jadeShredMap = docs[0];
    if (after) {
      return getChangedExamplesAfter(after);
    } else if (sha) {
      return getChangedExamples(sha);
    } else {
      console.log('git-changed-examples may be called with either an "--sha" argument like this:');
      console.log('   gulp git-changed-examples --sha=4d2ac96fa247306ddd2d4c4e0c8dee2223502eb2');
      console.log('or with an "--after" argument like this')
      console.log('   gulp git-changed-examples --after="August 1, 2015"');
    }
  }).then(function(examplePaths) {
    examplePaths = filterOutExcludedPatterns(examplePaths, _excludeMatchers);
    console.log('\nExamples changed ' + messageSuffix);
    console.log(examplePaths)
    console.log("\nJade files affected by changed example files " + messageSuffix);
    var jadeExampleMap = jadeShredMapToJadeExampleMap(jadeShredMap, examplePaths);
    console.log(JSON.stringify(jadeExampleMap, null, "  "));
    console.log("-----");
  }).catch(function(err) {
    console.log(err);
    throw err;
  });
});

gulp.task('check-deploy', ['build-docs'], function() {
  console.log('running harp compile...');
  return execPromise('npm run harp -- compile . ./www', {}).then(function() {
    execPromise('npm run live-server ./www');
    return askDeploy();
  }).then(function(shouldDeploy) {
    if (shouldDeploy) {
      console.log('deploying...');
      return execPromise('firebase deploy');
    } else {
      return ['Not deploying'];
    }
  }).then(function(s) {
    console.log(s.join(''));
  });
});

// returns a promise;
function askDeploy() {

  prompt.start();
  var schema = {
    name: 'shouldDeploy',
    description: 'Deploy to Firebase? (y/n): ',
    type: 'string',
    pattern: /Y|N|y|n/,
    message: "Respond with either a 'y' or 'n'",
    required: true
  }
  var getPromise = Q.denodeify(prompt.get);
  return getPromise([schema]).then(function(result) {
    return result.shouldDeploy.toLowerCase() === 'y';
  });
}

gulp.task('test-api-builder', function (cb) {
  execCommands(['npm run test-api-builder'], {}, cb);
});

function filterOutExcludedPatterns(fileNames, excludeMatchers) {
  return fileNames.filter(function(fileName) {
    return !excludeMatchers.some(function(excludeMatcher) {
      return excludeMatcher.match(fileName);
    });
  });
}

function apiSourceWatch(postShredAction) {
  var srcPattern = ['../angular/modules/angular2/src/**/*.*'];
  watch(srcPattern, function (event, done) {
    console.log('Event type: ' + event.event); // added, changed, or deleted
    console.log('Event path: ' + event.path); // The path of the modified file
    // need to run just build
    buildApiDocs().then(done);
  });
  var examplesPattern = ['../angular/modules/angular2/examples/**/*.*'];
  watch(examplesPattern, function (event, done) {
    console.log('Event type: ' + event.event); // added, changed, or deleted
    console.log('Event path: ' + event.path); // The path of the modified file
    // need to run shredder
    var cleanPath = path.join(_apiShredOptions.fragmentsDir, '**/*.*');
    return delPromise([ cleanPath, '!**/*.ovr.*' ]).then(function() {
      return docShredder.shred(_apiShredOptions);
    }).then(function() {
      postShredAction && postShredAction();
    });
  });

}

function buildApiDocs() {
  try {
    var dgeni = new Dgeni([require('./public/api-builder/angular.io-package')]);
    return dgeni.generate().then(function() {
      return gulp.src('./public/docs/js/latest/api/**/*.*')
        .pipe(gulp.dest('./public/docs/ts/latest/api'));
    })
  } catch(err) {
    console.log(err);
    console.log(err.stack);
    throw err;
  }
}

function devGuideExamplesWatch(shredOptions, postShredAction) {
  var pattern = path.join(shredOptions.examplesDir, "**/*.*");
  watch([pattern], function (event, done) {
    console.log('Event type: ' + event.event); // added, changed, or deleted
    console.log('Event path: ' + event.path); // The path of the modified file
    docShredder.shredSingleDir(shredOptions, event.path).then(function () {
      postShredAction && postShredAction();
    });
  });
}

function buildShredMaps(shouldWrite) {
  var options = {
    devguideExamplesDir: _devguideShredOptions.examplesDir,
    apiExamplesDir: _apiShredOptions.examplesDir,
    fragmentsDir: _devguideShredOptions.fragmentsDir,
    jadeDir: './public/docs',
    outputDir: './public/docs',
    writeFilesEnabled: shouldWrite
  };
  return docShredder.buildShredMap(options).then(function(docs) {
    return docs;
  });
}

// returns a promise containing filePaths with any changed or added examples;
function getChangedExamples(sha) {
  var examplesPath = _devguideShredOptions.examplesDir;
  var relativePath = path.relative(process.cwd(), examplesPath);
  return Git.Repository.open(".").then(function(repo) {
    if (sha.length) {
      return repo.getCommit(sha);
    } else {
      return repo.getHeadCommit();
    }
  }).then(function(commit) {
    return getChangedExamplesForCommit(commit, relativePath);
  }).catch(function(err) {

  });
}

function getChangedExamplesAfter(date, relativePath) {
  var examplesPath = _devguideShredOptions.examplesDir;
  var relativePath = path.relative(process.cwd(), examplesPath);
  return Git.Repository.open(".").then(function(repo) {
    return repo.getHeadCommit();
  }).then(function(commit) {
    var repo = commit.owner();
    var revWalker = repo.createRevWalk();
    revWalker.sorting(Git.Revwalk.SORT.TIME);
    revWalker.push(commit.id());
    return revWalker.getCommitsUntil(function (commit) {
      return commit.date().getTime() > date.getTime();
    });
  }).then(function(commits) {
    return Q.all(commits.map(function(commit) {
      return getChangedExamplesForCommit(commit, relativePath);
    }));
  }).then(function(arrayOfPaths) {
    var pathMap = {};
    arrayOfPaths.forEach(function(paths) {
      paths.forEach(function(path) {
        pathMap[path] = true;
      });
    });
    var uniqPaths = _.keys(pathMap);
    return uniqPaths;
  }).catch(function(err) {
    var x = err;
  });

}

function getChangedExamplesForCommit(commit, relativePath) {
  return commit.getDiff().then(function(diffList) {
    var filePaths = [];
    diffList.forEach(function (diff) {
      diff.patches().forEach(function (patch) {
        if (patch.isAdded() || patch.isModified) {
          var filePath = path.normalize(patch.newFile().path());
          var isExample = filePath.indexOf(relativePath) >= 0;
          // console.log(filePath + " isExample: " + isExample);
          if (isExample) {
            filePaths.push(filePath);
          }
        }
      });
    });
    return filePaths;
  });
}

function jadeShredMapToJadeExampleMap(jadeShredMap, examplePaths) {
  // remove dups in examplePaths
  var exampleSet = {};
  examplePaths.forEach(function(examplePath) {
    exampleSet[examplePath] = examplePath;
  });
  var basePath = path.resolve(".");
  var jadeToFragMap = jadeShredMap.jadeToFragMap;
  var jadeExampleMap = {};
  for (var jadePath in jadeToFragMap) {
    var relativeJadePath = path.relative(basePath, jadePath);
    var vals = jadeToFragMap[jadePath];
    vals.forEach(function(val) {
      var relativeExamplePath = path.relative(basePath, val.examplePath);
      if (exampleSet[relativeExamplePath] != null) {
        addKeyValue(jadeExampleMap, relativeJadePath, relativeExamplePath);
      }
    });
  }
  return jadeExampleMap;
}

function jadeShredMapToExampleJadeMap(jadeShredMap) {

  var jadeToFragMap = jadeShredMap.jadeToFragMap;
  var exampleJadeMap = {};
  for (var jadePath in jadeToFragMap) {
    var vals = jadeToFragMap[jadePath];
    vals.forEach(function(val) {
      var examplePath = val.examplePath;
      addKeyValue(exampleJadeMap, examplePath, jadePath);
    });
  }
  return exampleJadeMap;
}

function addKeyValue(map, key, value) {
  var vals = map[key];
  if (vals) {
    if (vals.indexOf(value) == -1) {
      vals.push(value);
    }
  } else {
    map[key] = [value];
  }
}

// Synchronously execute a chain of commands.
// cmds: an array of commands
// options: { shouldLog: true,  shouldThrow: true }
// cb: function(err, stdout, stderr)
function execCommands(cmds, options, cb) {
  options = options || {};
  options.shouldThrow = options.shouldThrow == null ? true : options.shouldThrow;
  options.shouldLog = options.shouldLog == null ? true : options.shouldLog;
  if (!cmds || cmds.length == 0) cb(null, null, null);
  var exec = require('child_process').exec;  // just to make it more portable.
  exec(cmds[0], options, function(err, stdout, stderr) {
    if (err == null) {
      if (options.shouldLog) {
        gutil.log('cmd: ' + cmds[0]);
        gutil.log('stdout: ' + stdout);
      }
      if (cmds.length == 1) {
        cb(err, stdout, stderr);
      } else {
        execCommands(cmds.slice(1), options, cb);
      }
    } else {
      if (options.shouldLog) {
        gutil.log('exec error on cmd: ' + cmds[0]);
        gutil.log('exec error: ' + err);
        if (stdout) gutil.log('stdout: ' + stdout);
        if (stderr) gutil.log('stderr: ' + stderr);
      }
      if (err && options.shouldThrow) throw err;
      cb(err, stdout, stderr);
    }
  });
}

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


<commit_before> // The build task ultimately serves up content from the root of timer-app, for
 // dev.
 //
 // The build task involves downloading the appropriate version of atom-shell
 // to the build inside the project, and running atom-shell against the
 // timer-app directory.
 //
 // The dist process invovles the following:
 //   1. Download appropriate atom-shell version.
 //   2. Vulcanize index.html.
 //   3. Copy static assets to dist (images/* and audio/*)
 //   4. Create asar file for application.
 //   5. Zip the whole onsight-timer directory in dist/
 //      (zip currently not working)
 //
 // The dist task produces the following structure:
 //  dist/
 //    Atom/*
 //    timer-app/ (or timer-app.asar)
 //      index.html (vulcanized)
 //      images/*
 //      audio/*
 //    run.bat
 //    run.command

// Set atom shell version
var atomShellVersion = '0.19.0';

// Require various gulp and node plugins
var gulp              = require('gulp');
var shell             = require('gulp-shell');
var downloadatomshell = require('gulp-download-atom-shell');
var del               = require('del');
var os                = require('os');
var path              = require('path');
var vulcanize         = require('gulp-vulcanize');
var zip               = require('gulp-zip');

// Determine platform, as running the applicaiton requires a different
// command for mac vs. windows
var platform = os.platform();

// Declare some variables for building run commands
var runBuildCmd;
var runDistCmd;

// Build the commands that will run the app, accounting for platform differences
// and whether we want to run from the dev form (timer-app folder) or dist form
// (.asar archive)
switch(platform) {
  case 'darwin':
    runBuildCmd = 'build/Atom.app/Contents/MacOS/Atom timer-app';
    runDistCmd = 'dist/Atom.app/Contents/MacOS/Atom dist/timer-app.asar';
    break;
  case 'win32':
    runBuildCmd = 'build\\atom.exe timer-app';
    runDistCmd =  'dist\\atom.exe dist\\timer-app.asar';
    break;
  default:
    console.log("Platform not supported. Needs to run on windows or mac.");
    process.exit(1);
    break;
}

// Download atom-shell local to the project - to the build folder for dev
gulp.task('downloadatomshell-build', function(cb) {
    downloadatomshell({
        version: atomShellVersion,
        outputDir: 'build'
    }, cb);
});

// Download atom-shell local to the project - to dist folder for distributables
gulp.task('downloadatomshell-dist', function(cb) {
    downloadatomshell({
        version: atomShellVersion,
        outputDir: 'dist'
    }, cb);
});

// The timer-app/components directory is pretty large given the items pulled in
// for polymer components. This allows the components directory to have whatever
// is useful for development, but vulcanize includes only the items required.
// Inline is used here to include everything necessary in the one index.html
// FIXME: vulcanize seems to break data binding with curly braces?
// Before vulcanizing, setting c_time and t_time in the settings tab works fine
// but afterward, c_time and t_time are undefined no matter what you do with
// the settings dialog
gulp.task('vulcanize', ['downloadatomshell-dist'], function () {
  gulp.src('timer-app/index.html')
    .pipe(vulcanize({
      dest: 'dist/timer-app',
      inline: true
    }))
});

// Copy other files needed.
gulp.task('copy-static-assets-1', ['vulcanize'], function () {
  gulp.src(['timer-app/images/**',
            'timer-app/audio/**',
            'timer-app/main.js',
            'timer-app/package.json'], {base: "."})
    .pipe(gulp.dest('dist'));
});

// Move the batch files up a level
gulp.task('copy-static-assets-2', ['copy-static-assets-1'], function () {
  gulp.src(['timer-app/bin/**'])
    .pipe(gulp.dest('dist'));
});

// Generic dev build task
gulp.task('build',['downloadatomshell-build']);

// Create the .asar file.  Assumes you've done npm install -g asar
// FIXME: Note that asar format can't be generated on windows as of 10/23/2014, so
// dist and run-dist will not work for windows.
gulp.task('dist', ['copy-static-assets-2'], shell.task([
  path.normalize('asar pack dist/timer-app dist/timer-app.asar')
]));

// Run the local build.  In development using this approach, you can just make
// changes to the application, and hit command-R or ctrl-R to refresh without
// having to put a watch on files or re-run the build task
gulp.task('run-build', ['downloadatomshell-build'], shell.task([ runBuildCmd ]));

// Run the local dist (.asar approach)
// FIXME: Note that asar format can't be generated on windows as of 11/23/2014,
// and so dist and run-dist will not work on that OS.
gulp.task('run-dist', ['dist'], shell.task([ runDistCmd ]));

// Delete the build and dist folder
gulp.task('clean', function(cb) {
  del(['build', 'dist'], cb);
});

gulp.task('default', ['build']);
<commit_msg>Updated to atom-shell 0.19.1<commit_after> // The build task ultimately serves up content from the root of timer-app, for
 // dev.
 //
 // The build task involves downloading the appropriate version of atom-shell
 // to the build inside the project, and running atom-shell against the
 // timer-app directory.
 //
 // The dist process invovles the following:
 //   1. Download appropriate atom-shell version.
 //   2. Vulcanize index.html.
 //   3. Copy static assets to dist (images/* and audio/*)
 //   4. Create asar file for application.
 //   5. Zip the whole onsight-timer directory in dist/
 //      (zip currently not working)
 //
 // The dist task produces the following structure:
 //  dist/
 //    Atom/*
 //    timer-app/ (or timer-app.asar)
 //      index.html (vulcanized)
 //      images/*
 //      audio/*
 //    run.bat
 //    run.command

// Set atom shell version
var atomShellVersion = '0.19.1';

// Require various gulp and node plugins
var gulp              = require('gulp');
var shell             = require('gulp-shell');
var downloadatomshell = require('gulp-download-atom-shell');
var del               = require('del');
var os                = require('os');
var path              = require('path');
var vulcanize         = require('gulp-vulcanize');
var zip               = require('gulp-zip');

// Determine platform, as running the applicaiton requires a different
// command for mac vs. windows
var platform = os.platform();

// Declare some variables for building run commands
var runBuildCmd;
var runDistCmd;

// Build the commands that will run the app, accounting for platform differences
// and whether we want to run from the dev form (timer-app folder) or dist form
// (.asar archive)
switch(platform) {
  case 'darwin':
    runBuildCmd = 'build/Atom.app/Contents/MacOS/Atom timer-app';
    runDistCmd = 'dist/Atom.app/Contents/MacOS/Atom dist/timer-app.asar';
    break;
  case 'win32':
    runBuildCmd = 'build\\atom.exe timer-app';
    runDistCmd =  'dist\\atom.exe dist\\timer-app.asar';
    break;
  default:
    console.log("Platform not supported. Needs to run on windows or mac.");
    process.exit(1);
    break;
}

// Download atom-shell local to the project - to the build folder for dev
gulp.task('downloadatomshell-build', function(cb) {
    downloadatomshell({
        version: atomShellVersion,
        outputDir: 'build'
    }, cb);
});

// Download atom-shell local to the project - to dist folder for distributables
gulp.task('downloadatomshell-dist', function(cb) {
    downloadatomshell({
        version: atomShellVersion,
        outputDir: 'dist'
    }, cb);
});

// The timer-app/components directory is pretty large given the items pulled in
// for polymer components. This allows the components directory to have whatever
// is useful for development, but vulcanize includes only the items required.
// Inline is used here to include everything necessary in the one index.html
// FIXME: Vulcanize changes the path in image tags, and for now, need to update
// dist/timer-app/index.html to be relative again and then asar the folder. So
// implication is that gulp-dist does not work once you want to .zip the
// atom.app, timer-app.asar, run.command and move it.
gulp.task('vulcanize', ['downloadatomshell-dist'], function () {
  gulp.src('timer-app/index.html')
    .pipe(vulcanize({
      dest: 'dist/timer-app',
      inline: true
    }))
});

// Copy other files needed.
gulp.task('copy-static-assets-1', ['vulcanize'], function () {
  gulp.src(['timer-app/images/**',
            'timer-app/audio/**',
            'timer-app/main.js',
            'timer-app/package.json'], {base: "."})
    .pipe(gulp.dest('dist'));
});

// Move the batch files up a level
gulp.task('copy-static-assets-2', ['copy-static-assets-1'], function () {
  gulp.src(['timer-app/bin/**'])
    .pipe(gulp.dest('dist'));
});

// Generic dev build task
gulp.task('build',['downloadatomshell-build']);

// Create the .asar file.  Assumes you've done npm install -g asar
// FIXME: Note that asar format can't be generated on windows as of 10/23/2014, so
// dist and run-dist will not work for windows.
gulp.task('dist', ['copy-static-assets-2'], shell.task([
  path.normalize('asar pack dist/timer-app dist/timer-app.asar')
]));

// Run the local build.  In development using this approach, you can just make
// changes to the application, and hit command-R or ctrl-R to refresh without
// having to put a watch on files or re-run the build task
gulp.task('run-build', ['downloadatomshell-build'], shell.task([ runBuildCmd ]));

// Run the local dist (.asar approach)
// FIXME: Note that asar format can't be generated on windows as of 11/23/2014,
// and so dist and run-dist will not work on that OS.
gulp.task('run-dist', ['dist'], shell.task([ runDistCmd ]));

// Delete the build and dist folder
gulp.task('clean', function(cb) {
  del(['build', 'dist'], cb);
});

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


<commit_before>'use strict';
const gulp = require('gulp'),
    gulpJsdoc2md = require('gulp-jsdoc-to-markdown'),
    rename = require('gulp-rename'),
    istanbul = require('gulp-istanbul'),
    istanbulHarmony = require('istanbul-harmony'),
    mocha = require('gulp-mocha'),
    eslint = require('gulp-eslint'),
    git = require('gulp-git'),
    concat = require('gulp-concat');

const sockFiles = ['*.js', '!./gulpfile.js', 'plugins/**/*.js'],
    sockDocs = ['README.md', 'docs/**/*.md'],
    sockTests = ['test/**/*.js'],
    sockReadme = ['docs/badges.md.tmpl', 'docs/index.md', 'docs/Special Thanks.md'];

const JobNumber = process.env.TRAVIS_JOB_NUMBER,
    runDocs = !!JobNumber || /[.]1$/.test(JobNumber);

gulp.task('readme', () => {
    gulp.src(sockReadme)
        .pipe(concat('README.md'))
        .pipe(gulp.dest('.'));
});

gulp.task('docs', ['gitBranch'], function (done) {
    if (!runDocs) {
        return done();
    }
    gulp.src(sockFiles)
        .pipe(gulpJsdoc2md({}))
        .on('error', done)
        .pipe(rename((path) => {
            path.extname = '.md';
        }))
        .pipe(gulp.dest('docs/api'))
        .on('finish', done);
});

gulp.task('lint', (done) => {
    gulp.src(sockFiles)
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError())
        .on('error', done);
});

gulp.task('gitConfig', (done) => {
    if (!JobNumber) {
        return done();
    }
    git.exec({
        args: 'config user.name "Travis-CI"'
    }, () => {
        git.exec({
            args: 'config user.email "Travis-CI@servercooties.com"'
        }, () => {
            done();
        });
    });
});

gulp.task('gitBranch', (done) => {
    if (!runDocs) {
        return done();
    }
    const branch = process.env.TRAVIS_BRANCH;
    if (!branch) {
        return done();
    }
    git.checkout(branch, () => {
        git.pull('origin', branch,()=>done());
        done();
    });
});

gulp.task('commitDocs', (done) => {
    gulp.src(sockDocs)
        .pipe(git.add())
        .pipe(git.commit('Automatically push updated documentation'))
        .on('error', (err) => {
            if (err) {
                console.log(err); //eslint-disable-line no-console
            }
        })
        .on('finish', done);
});
gulp.task('pushDocs', ['gitConfig', 'commitDocs'], (done) => {
    if (!runDocs) {
        return done();
    }
    const username = process.env.GITHUB_USERNAME,
        token = process.env.GITHUB_TOKEN;
    git.addRemote('github', 'https://' + username + ':' + token +
        '@github.com/SockDrawer/SockBot.git', (e) => {
            if (e) {
                console.log(e); //eslint-disable-line no-console
            }
            git.push('github', 'es6-dev', {
                args: ['-q']
            }, (err) => {
                if (err) {
                    console.log(err); //eslint-disable-line no-console
                }
                done();
            });
        });
});

gulp.task('test', (done) => {
    gulp.src(sockFiles).pipe(istanbul({
            instrumenter: istanbulHarmony.Instrumenter
        }))
        .pipe(istanbul.hookRequire())
        .on('finish', () => {
            gulp.src(sockTests)
                .pipe(mocha())
                .pipe(istanbul.writeReports())
                .on('finish', done);
        });
});

gulp.task('buildDocs', ['readme', 'docs'], () => 0);
gulp.task('preBuild', ['buildDocs', 'lint'], () => 0);
gulp.task('postBuild', ['pushDocs'], () => 0);
gulp.task('default', ['lint'], () => 0);<commit_msg>attempt to fix leaked api key the third<commit_after>'use strict';
const gulp = require('gulp'),
    gulpJsdoc2md = require('gulp-jsdoc-to-markdown'),
    rename = require('gulp-rename'),
    istanbul = require('gulp-istanbul'),
    istanbulHarmony = require('istanbul-harmony'),
    mocha = require('gulp-mocha'),
    eslint = require('gulp-eslint'),
    git = require('gulp-git'),
    concat = require('gulp-concat');

const sockFiles = ['*.js', '!./gulpfile.js', 'plugins/**/*.js'],
    sockDocs = ['README.md', 'docs/**/*.md'],
    sockTests = ['test/**/*.js'],
    sockReadme = ['docs/badges.md.tmpl', 'docs/index.md', 'docs/Special Thanks.md'];

const JobNumber = process.env.TRAVIS_JOB_NUMBER,
    runDocs = !!JobNumber || /[.]1$/.test(JobNumber);

gulp.task('readme', () => {
    gulp.src(sockReadme)
        .pipe(concat('README.md'))
        .pipe(gulp.dest('.'));
});

gulp.task('docs', ['gitBranch'], function (done) {
    if (!runDocs) {
        return done();
    }
    gulp.src(sockFiles)
        .pipe(gulpJsdoc2md({}))
        .on('error', done)
        .pipe(rename((path) => {
            path.extname = '.md';
        }))
        .pipe(gulp.dest('docs/api'))
        .on('finish', done);
});

gulp.task('lint', (done) => {
    gulp.src(sockFiles)
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError())
        .on('error', done);
});

gulp.task('gitConfig', (done) => {
    if (!JobNumber) {
        return done();
    }
    git.exec({
        args: 'config user.name "Travis-CI"'
    }, () => {
        git.exec({
            args: 'config user.email "Travis-CI@servercooties.com"'
        }, () => {
            done();
        });
    });
});

gulp.task('gitBranch', (done) => {
    let complete = false;
    if (!runDocs) {
        return done();
    }
    const branch = process.env.TRAVIS_BRANCH;
    if (!branch) {
        return done();
    }
    git.checkout(branch, () => {
        git.pull('origin', branch, () => {
            complete || done();
            complete = true;
        });
    });
});

gulp.task('commitDocs', (done) => {
    gulp.src(sockDocs)
        .pipe(git.add())
        .pipe(git.commit('Automatically push updated documentation'))
        .on('error', (err) => {
            if (err) {
                console.log(err); //eslint-disable-line no-console
            }
        })
        .on('finish', done);
});
gulp.task('pushDocs', ['gitConfig', 'commitDocs'], (done) => {
    if (!runDocs) {
        return done();
    }
    const username = process.env.GITHUB_USERNAME,
        token = process.env.GITHUB_TOKEN;
    git.addRemote('github', 'https://' + username + ':' + token +
        '@github.com/SockDrawer/SockBot.git', (e) => {
            if (e) {
                console.log(e); //eslint-disable-line no-console
            }
            git.push('github', 'es6-dev', {
                args: ['-q']
            }, (err) => {
                if (err) {
                    console.log(err); //eslint-disable-line no-console
                }
                done();
            });
        });
});

gulp.task('test', (done) => {
    gulp.src(sockFiles).pipe(istanbul({
            instrumenter: istanbulHarmony.Instrumenter
        }))
        .pipe(istanbul.hookRequire())
        .on('finish', () => {
            gulp.src(sockTests)
                .pipe(mocha())
                .pipe(istanbul.writeReports())
                .on('finish', done);
        });
});

gulp.task('buildDocs', ['readme', 'docs'], () => 0);
gulp.task('preBuild', ['buildDocs', 'lint'], () => 0);
gulp.task('postBuild', ['pushDocs'], () => 0);
gulp.task('default', ['lint'], () => 0);<|endoftext|>


<commit_before>var gulp   = require('gulp');
var Server = require('karma').Server;
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var clean  = require('gulp-clean');

gulp.task('compress', function() {
    gulp.src(['static/js/helper.js', 'static/js/timer.js', 'static/js/anims.js'])
        .pipe(uglify())
        .pipe(concat('production.min.js'))
        .pipe(gulp.dest('static/'));
});

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

gulp.task('clean', function() {
    gulp.src(['node_modules/', 'static/bower_components'], {read: false})
        .pipe(clean());
});
<commit_msg>Now cleans up production.min.js<commit_after>var gulp   = require('gulp');
var Server = require('karma').Server;
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var clean  = require('gulp-clean');

gulp.task('compress', function() {
    gulp.src(['static/js/helper.js', 'static/js/timer.js', 'static/js/anims.js'])
        .pipe(uglify())
        .pipe(concat('production.min.js'))
        .pipe(gulp.dest('static/'));
});

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

gulp.task('clean', function() {
    gulp.src(['node_modules/', 'static/bower_components', 'static/js/production.min.js'], {read: false})
        .pipe(clean());
});
<|endoftext|>


<commit_before>'use strict';

// modules
var gulp          = require('gulp');
var gutil         = require('gulp-util');
var gulpif        = require('gulp-if');
var del           = require('del');
var csso          = require('gulp-csso');
var rename        = require('gulp-rename');
var assemble      = require('fabricator-assemble');
var webpack       = require('webpack');
var runSequence   = require('run-sequence');
var browserSync   = require('browser-sync');
var coffee        = require("gulp-coffee");
var include       = require('gulp-include');
var concat        = require('gulp-concat');
var uglify        = require('gulp-uglify');
var addsrc        = require('gulp-add-src');
var imagemin      = require('gulp-imagemin');
var svgSymbols    = require('gulp-svg-symbols');
var sass          = require('gulp-sass');
var sourcemaps    = require('gulp-sourcemaps');
var bourbon       = require('node-bourbon').includePaths;
var neat          = require('bourbon-neat').includePaths;
var autoprefixer  = require('gulp-autoprefixer');
var notify        = require('gulp-notify');
var sftp          = require('gulp-sftp');
var ghPages       = require('gulp-gh-pages');
var postcss     	= require('gulp-postcss');
var postcss_syntax_scss = require('postcss-scss');
var reporter    	= require('postcss-reporter');
var stylelint   	= require('stylelint');
var doiuse        = require('doiuse');
var metadata      = require('./package.json');

// configuration
// ----------------------------------------
var config = {
  dev: gutil.env.dev === true ? true : false,
  src: {
    scripts: {
      fabricator: [
        './src/_styleguide/fabricator/scripts/fabricator.js',
        './src/_styleguide/fabricator/scripts/partystreusel.js'
      ],
      application: './src/application.coffee',
      vendor:      './src/vendor/*.js',
      polyfills:   'src/vendor/polyfills/*'
    },
    styles: {
      fabricator: 'src/_styleguide/fabricator/styles/fabricator.scss',
      fabricatorpartials: 'src/_styleguide/**/*.scss',
      application: 'src/application.scss',
      applicationpartials: 'src/materials/**/*.scss'
    },
    fonts:  'src/materials/atoms/fonts/*.{eot,woff,woff2,ttf,svg}',
    imagesfolder: 'src/images/',
    images: [
      'src/images/**/*',
      '!src/images/icons/*'
    ],
    icons:  'src/images/icons/',
    iconsystem:  'src/materials/atoms/icons'
  },
  dest: 'dist',
  remotePath:   '/home/www-data/REPLACEME/',
  browsers: ['last 2 versions', 'ie >= 10', '> 1% in CH']
};

// webpack
// ----------------------------------------
var webpackConfig = require('./webpack.config')(config);
var webpackCompiler = webpack(webpackConfig);

// clean
// ----------------------------------------
gulp.task('clean', function () {
  return del([config.dest]);
});

// STYLES
// ----------------------------------------

gulp.task('styles:fabricator', function () {
  return gulp.src(config.src.styles.fabricator)
    .pipe(sass({
      includePaths: [neat, bourbon]
    }).on('error', notify.onError()))
    .pipe(autoprefixer(config.browsers))
    .pipe(gulpif(!config.dev, csso()))
    .pipe(rename('p.css'))
    .pipe(gulp.dest(config.dest + '/assets/partystreusel/styles'))
    .pipe(gulpif(config.dev, browserSync.stream({match: '**/*.css'})));
});

gulp.task('styles:application', function () {
  return gulp.src(config.src.styles.application)
    .pipe(gulpif(config.dev, sourcemaps.init()))
    .pipe(sass({
      includePaths: [neat, bourbon]
    }).on('error', notify.onError()))
    .pipe(autoprefixer(config.browsers))
    .pipe(gulpif(!config.dev, csso()))
    .pipe(gulpif(config.dev, sourcemaps.write('./')))
    .pipe(gulp.dest(config.dest + '/assets/styles'))
    .pipe(gulpif(config.dev, browserSync.stream({match: '**/*.css'})));
});

//lint styles
gulp.task("styles:lint", function() {
  var processors = [
    stylelint(),
    // Pretty reporting config
    reporter({
      clearMessages: true,
      throwError: false
    })
  ];

  return gulp.src(
      ['src/**/*.scss',
      // Ignore linting vendor assets:
      '!src/_styleguide/**/*.scss',
      '!src/vendor/*']
    )
    .pipe(postcss(processors, {syntax: postcss_syntax_scss}));
});

gulp.task('styles', ['styles:lint', 'styles:fabricator', 'styles:application']);

//check styles wit caniuse/doiuse
gulp.task("styles:doiuse", function() {
  var processors = [
    doiuse({
      browsers: config.browsers,
      ignore: ['rem', 'flexbox']
    }),
    // Pretty reporting config
    reporter({
      clearMessages: true,
      throwError: false
    })
  ];

  return gulp.src(
      ['src/**/*.scss',
      '!src/_styleguide/**/*.scss',
      '!src/vendor/*']
    )
    .pipe(postcss(processors, {syntax: postcss_syntax_scss}));
});

// SCRIPTS
// ----------------------------------------
gulp.task('scripts', function (done) {
  webpackCompiler.run(function (error, result) {
    if (error) {
      gutil.log(gutil.colors.red(error));
      notify.onError()
    }
    result = result.toJson();
    if (result.errors.length) {
      result.errors.forEach(function (error) {
        gutil.log(gutil.colors.red(error));
      });
    }
    done();
  });
});

gulp.task('coffee', function() {
  gulp.src(config.src.scripts.application)
    .pipe(include())
    .pipe(coffee())
    .pipe(addsrc.prepend(config.src.scripts.vendor))
    .pipe(concat("application.js"))
    .pipe(gulpif(!config.dev, uglify()))
    .pipe(gulp.dest(config.dest + '/assets/scripts'))
    .pipe(browserSync.reload({stream: true}))
});

gulp.task('polyfills', function() {
  gulp.src(config.src.scripts.polyfills)
    .pipe(gulp.dest(config.dest + '/assets/scripts/polyfills'))
});

// IMAGES
// ----------------------------------------
gulp.task('images', function () {
  return gulp.src(config.src.images)
    .pipe(imagemin([
      imagemin.jpegtran({progressive: true})
    ]))
    .pipe(gulp.dest(config.src.imagesfolder))
    .pipe(gulp.dest(config.dest + '/assets/images'));
});

// ICONS
// ----------------------------------------

gulp.task('svgmin', function () {
  return gulp.src(config.src.icons + '*.svg')
    .pipe(imagemin([
      imagemin.svgo({
        plugins: [
          { removeViewBox: false },
          { removeDesc: true },
          { removeTitle: true }
        ]
      })
    ]))
    .pipe(gulp.dest(config.src.icons));
});

gulp.task('svgsprite', ['svgmin'], function () {
  gulp.src(config.src.icons + '*.svg')
    .pipe(svgSymbols({
      id:     'icon--%f',
      title:  'icon %f',
      templates: [
        config.src.iconsystem + '/_icon-sprite-template.svg',
        config.src.iconsystem + '/_icons-preview-template.html'
      ]
    }))
    .pipe(gulpif( /[.]svg$/, rename('icon-sprite.svg')))
    .pipe(gulpif( /[.]svg$/, gulp.dest(config.dest + '/assets/images/icons')))
    .pipe(gulpif( /[.]html$/, rename('all-icons.html')))
    .pipe(gulpif( /[.]html$/, gulp.dest(config.src.iconsystem)));
});

// Icon workflow
gulp.task('icons', ['svgmin', 'svgsprite']);

// Fonts
// ----------------------------------------
gulp.task('fonts', function() {
  return gulp.src(config.src.fonts)
   .pipe(gulp.dest(config.dest + '/assets/fonts'));
});

// assemble
// ----------------------------------------
gulp.task('assemble', function (done) {
  assemble({
    logErrors: config.dev,
    layout: 'partystreusel',
    layouts: 'src/materials/templates/*.html',
    layoutIncludes: 'src/_styleguide/fabricator/layouts/includes/*',
    views: ['src/_styleguide/fabricator/views/**/*', 'src/pages/**/*'],
    materials: 'src/materials/**/!(_)*.html',
    data: 'src/materials/**/*.{json,yml}',
    docs: ['docs/**/*.md', 'src/materials/**/*.md'],
    helpers: {
      currentVersion: function() {
        return metadata.version;
      }
    }
  });
  done();
});

// DEPLOY
// ----------------------------------------
  gulp.task('deploy:remote', function () {
  return gulp.src('dist/**/*')
    .pipe(sftp({
      host: 'php1.brandleadership.ch',
      user: 'www-data',
      remotePath: config.remotePath
    }));
});

gulp.task('deploy:github', function() {
  return gulp.src('./dist/**/*')
    .pipe(ghPages());
});

gulp.task('deploy', function() {
  runSequence(
    'clean',
    [
      'styles',
      'scripts',
      'coffee',
      'polyfills',
      'fonts',
      'images',
      'icons',
      'assemble'
    ],
    'deploy:github'
  );
});

// SERVER
// ----------------------------------------
gulp.task('serve', function () {

  browserSync({
    server: {
      baseDir: config.dest
    },
    notify: false,
    logPrefix: 'FABRICATOR'
  });

  /**
   * Because webpackCompiler.watch() isn't being used
   * manually remove the changed file path from the cache
   */
  function webpackCache(e) {
    var keys = Object.keys(webpackConfig.cache);
    var key, matchedKey;
    for (var keyIndex = 0; keyIndex < keys.length; keyIndex++) {
      key = keys[keyIndex];
      if (key.indexOf(e.path) !== -1) {
        matchedKey = key;
        break;
      }
    }
    if (matchedKey) {
      delete webpackConfig.cache[matchedKey];
    }
  }

  gulp.task('assemble:watch', ['assemble'], browserSync.reload);
  gulp.watch(['docs/*.md','src/**/*.{html,md,json,yml}'], ['assemble:watch']);

  gulp.task('styles:fabricator:watch', ['styles:fabricator']);
  gulp.watch(config.src.styles.fabricatorpartials, ['styles:fabricator:watch']);

  gulp.task('styles:application:watch', ['styles:application']);
  gulp.watch(config.src.styles.applicationpartials, ['styles:application:watch']);

  gulp.task('scripts:watch', ['scripts'], browserSync.reload);
  gulp.watch('src/_styleguide/fabricator/scripts/**/*.js', ['scripts:watch']).on('change', webpackCache);

  gulp.task('coffee:watch', ['coffee'], browserSync.reload);
  gulp.watch('src/materials/**/*.coffee', ['coffee:watch']);

  gulp.task('images:watch', ['images'], browserSync.reload);
  gulp.watch(config.src.images, ['images:watch']);

});

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

// DEFAULT BUILD TASK
// ----------------------------------------
gulp.task('default', ['clean'], function () {
  // define build tasks
  var tasks = [
    'styles',
    'scripts',
    'coffee',
    'polyfills',
    'fonts',
    'images',
    'icons',
    'assemble'
  ];

  // run build
  runSequence(tasks, function () {
    if (config.dev) {
      gulp.start('serve');
    }
  });

});
<commit_msg>update deployment tasks (gulp)<commit_after>'use strict';

// modules
var gulp          = require('gulp');
var gutil         = require('gulp-util');
var gulpif        = require('gulp-if');
var del           = require('del');
var csso          = require('gulp-csso');
var rename        = require('gulp-rename');
var assemble      = require('fabricator-assemble');
var webpack       = require('webpack');
var runSequence   = require('run-sequence');
var browserSync   = require('browser-sync');
var coffee        = require("gulp-coffee");
var include       = require('gulp-include');
var concat        = require('gulp-concat');
var uglify        = require('gulp-uglify');
var addsrc        = require('gulp-add-src');
var imagemin      = require('gulp-imagemin');
var svgSymbols    = require('gulp-svg-symbols');
var sass          = require('gulp-sass');
var sourcemaps    = require('gulp-sourcemaps');
var bourbon       = require('node-bourbon').includePaths;
var neat          = require('bourbon-neat').includePaths;
var autoprefixer  = require('gulp-autoprefixer');
var notify        = require('gulp-notify');
var ghPages       = require('gulp-gh-pages');
var postcss     	= require('gulp-postcss');
var postcss_syntax_scss = require('postcss-scss');
var reporter    	= require('postcss-reporter');
var stylelint   	= require('stylelint');
var doiuse        = require('doiuse');
var metadata      = require('./package.json');

// configuration
// ----------------------------------------
var config = {
  dev: gutil.env.dev === true ? true : false,
  src: {
    scripts: {
      fabricator: [
        './src/_styleguide/fabricator/scripts/fabricator.js',
        './src/_styleguide/fabricator/scripts/partystreusel.js'
      ],
      application: './src/application.coffee',
      vendor:      './src/vendor/*.js',
      polyfills:   'src/vendor/polyfills/*'
    },
    styles: {
      fabricator: 'src/_styleguide/fabricator/styles/fabricator.scss',
      fabricatorpartials: 'src/_styleguide/**/*.scss',
      application: 'src/application.scss',
      applicationpartials: 'src/materials/**/*.scss'
    },
    fonts:  'src/materials/atoms/fonts/*.{eot,woff,woff2,ttf,svg}',
    imagesfolder: 'src/images/',
    images: [
      'src/images/**/*',
      '!src/images/icons/*'
    ],
    icons:  'src/images/icons/',
    iconsystem:  'src/materials/atoms/icons'
  },
  dest: 'dist',
  browsers: ['last 2 versions', 'ie >= 10', '> 1% in CH']
};

// webpack
// ----------------------------------------
var webpackConfig = require('./webpack.config')(config);
var webpackCompiler = webpack(webpackConfig);

// clean
// ----------------------------------------
gulp.task('clean', function () {
  return del([config.dest]);
});

// STYLES
// ----------------------------------------

gulp.task('styles:fabricator', function () {
  return gulp.src(config.src.styles.fabricator)
    .pipe(sass({
      includePaths: [neat, bourbon]
    }).on('error', notify.onError()))
    .pipe(autoprefixer(config.browsers))
    .pipe(gulpif(!config.dev, csso()))
    .pipe(rename('p.css'))
    .pipe(gulp.dest(config.dest + '/assets/partystreusel/styles'))
    .pipe(gulpif(config.dev, browserSync.stream({match: '**/*.css'})));
});

gulp.task('styles:application', function () {
  return gulp.src(config.src.styles.application)
    .pipe(gulpif(config.dev, sourcemaps.init()))
    .pipe(sass({
      includePaths: [neat, bourbon]
    }).on('error', notify.onError()))
    .pipe(autoprefixer(config.browsers))
    .pipe(gulpif(!config.dev, csso()))
    .pipe(gulpif(config.dev, sourcemaps.write('./')))
    .pipe(gulp.dest(config.dest + '/assets/styles'))
    .pipe(gulpif(config.dev, browserSync.stream({match: '**/*.css'})));
});

//lint styles
gulp.task("styles:lint", function() {
  var processors = [
    stylelint(),
    // Pretty reporting config
    reporter({
      clearMessages: true,
      throwError: false
    })
  ];

  return gulp.src(
      ['src/**/*.scss',
      // Ignore linting vendor assets:
      '!src/_styleguide/**/*.scss',
      '!src/vendor/*']
    )
    .pipe(postcss(processors, {syntax: postcss_syntax_scss}));
});

gulp.task('styles', ['styles:lint', 'styles:fabricator', 'styles:application']);

//check styles wit caniuse/doiuse
gulp.task("styles:doiuse", function() {
  var processors = [
    doiuse({
      browsers: config.browsers,
      ignore: ['rem', 'flexbox']
    }),
    // Pretty reporting config
    reporter({
      clearMessages: true,
      throwError: false
    })
  ];

  return gulp.src(
      ['src/**/*.scss',
      '!src/_styleguide/**/*.scss',
      '!src/vendor/*']
    )
    .pipe(postcss(processors, {syntax: postcss_syntax_scss}));
});

// SCRIPTS
// ----------------------------------------
gulp.task('scripts', function (done) {
  webpackCompiler.run(function (error, result) {
    if (error) {
      gutil.log(gutil.colors.red(error));
      notify.onError()
    }
    result = result.toJson();
    if (result.errors.length) {
      result.errors.forEach(function (error) {
        gutil.log(gutil.colors.red(error));
      });
    }
    done();
  });
});

gulp.task('coffee', function() {
  gulp.src(config.src.scripts.application)
    .pipe(include())
    .pipe(coffee())
    .pipe(addsrc.prepend(config.src.scripts.vendor))
    .pipe(concat("application.js"))
    .pipe(gulpif(!config.dev, uglify()))
    .pipe(gulp.dest(config.dest + '/assets/scripts'))
    .pipe(browserSync.reload({stream: true}))
});

gulp.task('polyfills', function() {
  gulp.src(config.src.scripts.polyfills)
    .pipe(gulp.dest(config.dest + '/assets/scripts/polyfills'))
});

// IMAGES
// ----------------------------------------
gulp.task('images', function () {
  return gulp.src(config.src.images)
    .pipe(imagemin([
      imagemin.jpegtran({progressive: true})
    ]))
    .pipe(gulp.dest(config.src.imagesfolder))
    .pipe(gulp.dest(config.dest + '/assets/images'));
});

// ICONS
// ----------------------------------------

gulp.task('svgmin', function () {
  return gulp.src(config.src.icons + '*.svg')
    .pipe(imagemin([
      imagemin.svgo({
        plugins: [
          { removeViewBox: false },
          { removeDesc: true },
          { removeTitle: true }
        ]
      })
    ]))
    .pipe(gulp.dest(config.src.icons));
});

gulp.task('svgsprite', ['svgmin'], function () {
  gulp.src(config.src.icons + '*.svg')
    .pipe(svgSymbols({
      id:     'icon--%f',
      title:  'icon %f',
      templates: [
        config.src.iconsystem + '/_icon-sprite-template.svg',
        config.src.iconsystem + '/_icons-preview-template.html'
      ]
    }))
    .pipe(gulpif( /[.]svg$/, rename('icon-sprite.svg')))
    .pipe(gulpif( /[.]svg$/, gulp.dest(config.dest + '/assets/images/icons')))
    .pipe(gulpif( /[.]html$/, rename('all-icons.html')))
    .pipe(gulpif( /[.]html$/, gulp.dest(config.src.iconsystem)));
});

// Icon workflow
gulp.task('icons', ['svgmin', 'svgsprite']);

// Fonts
// ----------------------------------------
gulp.task('fonts', function() {
  return gulp.src(config.src.fonts)
   .pipe(gulp.dest(config.dest + '/assets/fonts'));
});

// assemble
// ----------------------------------------
gulp.task('assemble', function (done) {
  assemble({
    logErrors: config.dev,
    layout: 'partystreusel',
    layouts: 'src/materials/templates/*.html',
    layoutIncludes: 'src/_styleguide/fabricator/layouts/includes/*',
    views: ['src/_styleguide/fabricator/views/**/*', 'src/pages/**/*'],
    materials: 'src/materials/**/!(_)*.html',
    data: 'src/materials/**/*.{json,yml}',
    docs: ['docs/**/*.md', 'src/materials/**/*.md'],
    helpers: {
      currentVersion: function() {
        return metadata.version;
      }
    }
  });
  done();
});

// DEPLOY
// ----------------------------------------
gulp.task('deploy:github', function() {
  return gulp.src('./dist/**/*')
    .pipe(ghPages());
});

gulp.task('deploy', function() {
  runSequence(
    'clean',
    [
      'styles',
      'scripts',
      'coffee',
      'polyfills',
      'fonts',
      'images',
      'icons',
      'assemble'
    ],
    'deploy:github'
  );
});

// // Install & require 'gulp-sftp' for this task
// gulp.task('deploy:remote', function () {
//   return gulp.src('dist/**/*')
//     .pipe(sftp({
//       host: 'php1.brandleadership.ch',
//       user: 'www-data',
//       remotePath: '/home/www-data/REPLACEME/'
//     }));
// });

// SERVER
// ----------------------------------------
gulp.task('serve', function () {

  browserSync({
    server: {
      baseDir: config.dest
    },
    notify: false,
    logPrefix: 'FABRICATOR'
  });

  /**
   * Because webpackCompiler.watch() isn't being used
   * manually remove the changed file path from the cache
   */
  function webpackCache(e) {
    var keys = Object.keys(webpackConfig.cache);
    var key, matchedKey;
    for (var keyIndex = 0; keyIndex < keys.length; keyIndex++) {
      key = keys[keyIndex];
      if (key.indexOf(e.path) !== -1) {
        matchedKey = key;
        break;
      }
    }
    if (matchedKey) {
      delete webpackConfig.cache[matchedKey];
    }
  }

  gulp.task('assemble:watch', ['assemble'], browserSync.reload);
  gulp.watch(['docs/*.md','src/**/*.{html,md,json,yml}'], ['assemble:watch']);

  gulp.task('styles:fabricator:watch', ['styles:fabricator']);
  gulp.watch(config.src.styles.fabricatorpartials, ['styles:fabricator:watch']);

  gulp.task('styles:application:watch', ['styles:application']);
  gulp.watch(config.src.styles.applicationpartials, ['styles:application:watch']);

  gulp.task('scripts:watch', ['scripts'], browserSync.reload);
  gulp.watch('src/_styleguide/fabricator/scripts/**/*.js', ['scripts:watch']).on('change', webpackCache);

  gulp.task('coffee:watch', ['coffee'], browserSync.reload);
  gulp.watch('src/materials/**/*.coffee', ['coffee:watch']);

  gulp.task('images:watch', ['images'], browserSync.reload);
  gulp.watch(config.src.images, ['images:watch']);

});

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

// DEFAULT BUILD TASK
// ----------------------------------------
gulp.task('default', ['clean'], function () {
  // define build tasks
  var tasks = [
    'styles',
    'scripts',
    'coffee',
    'polyfills',
    'fonts',
    'images',
    'icons',
    'assemble'
  ];

  // run build
  runSequence(tasks, function () {
    if (config.dev) {
      gulp.start('serve');
    }
  });

});
<|endoftext|>