<commit_before>//****************************************************************************************************
//
// .. VARIABLES
//
//****************************************************************************************************
var gulp = require('gulp'), // Сообственно Gulp JS
    jade = require('gulp-jade'), // Плагин для Jade
    htmlhint = require('gulp-htmlhint'),
    prettify = require('gulp-html-prettify'),
    htmlreplace = require('gulp-html-replace'),
    stylus = require('gulp-stylus'), // Плагин для Stylus
    autoprefixer = require('gulp-autoprefixer'), // Расстановка префиксов
    csso = require('gulp-csso'), // Минификация CSS
    imagemin = require('gulp-imagemin'), // Минификация изображений
    svgmin = require('gulp-svgmin'), // Минификация svg
    rename = require('gulp-rename'),
    clean = require('gulp-clean'),
    ignore = require('gulp-ignore'),
    uglify = require('gulp-uglify'), // Минификация JS
    concat = require('gulp-concat'), // Склейка файлов
    browserSync = require('browser-sync'); // livereload
    zip = require('gulp-zip'); // Архив собранного проекта

//****************************************************************************************************
//
// .. TASKS
//
//****************************************************************************************************

var paths = {
    layouts: {
        src: ['./assets/template/*.jade', '!assets/template/_*.jade'],
        dest: './build'
    },
    html: {
        src: ['./assets/**/*.html'],
        dest: './build'
    },
    stylesheets: {
        src: './assets/styles/**/*.styl',
        dest: './build/(-;/css'
    },
    copycss: {
        src: './assets/styles/**/*.css',
        dest: './build/(-;/css'
    },
    copyjs: {
        src: './assets/js/libs/*',
        dest: './build/(-;/js/libs'
    },
    javascripts: {
        src: ['./assets/js/**/*.js', '!assets/js/libs/**/*.js'],
        dest: './build/(-;/js'
    },
    images: {
        src: ['./assets/img/**/*', '!assets/img/**/*.svg'],
        dest: './build/(-;/img'
    },
    svg: {
        src: './assets/img/**/*.svg',
        dest: './build/(-;/img'
    },
    fonts: {
        src: './assets/fonts/**/*',
        dest: './build/(-;/fonts'
    },
    files: {
        src: './assets/static/**/*',
        dest: './build'
    },
    zip: {
        src: './assets/*',
        dest: './build'
    }
};

// Собираем Stylus
gulp.task('stylus', function() {
    gulp.src(paths.stylesheets.src)
        .pipe(stylus({set:['linenos']})) // собираем stylus
    .on('error', console.log) // Если есть ошибки, выводим и продолжаем
    .pipe(autoprefixer("last 1 version", "> 1%", "ie 8", "ie 7"))
    .pipe(gulp.dest(paths.stylesheets.dest)); // записываем css
});

gulp.task('stylus:build', function() {
    gulp.src(paths.stylesheets.src)
        .pipe(stylus()) // собираем stylus
    .on('error', console.log) // Если есть ошибки, выводим и продолжаем
    .pipe(autoprefixer("last 1 version", "> 1%", "ie 8", "ie 7"))
    .pipe(gulp.dest(paths.stylesheets.dest))
    .pipe(rename("style.min.css"))
    .pipe(csso()) // минимизируем css
    .pipe(gulp.dest(paths.stylesheets.dest)); // записываем css
});

// css
//gulp.task('cssmin', function() {
//    gulp.src('./assets/styles/mincss/*')
//    .pipe(csso())
//    .pipe(gulp.dest('./public/css/min'));
//});

// html
gulp.task('html', function(){
    gulp.src(paths.html.src)
        .pipe(htmlhint({
            "tag-pair": true,
            "style-disabled": true,
            "img-alt-require": true,
            "tagname-lowercase": true,
            "src-not-empty": true,
            "id-unique": true,
            "spec-char-escape": true
        }))
        .pipe(htmlhint.reporter())
        .pipe(prettify({
            indent_char: ' ',
            indent_size: 4
        }))
        .pipe(gulp.dest(paths.html.dest));
});

// Собираем html из Jade
gulp.task('jade', function() {
    gulp.src(paths.layouts.src)
        .pipe(jade({
            pretty: true
        }))  // Собираем Jade только в папке ./assets/template/ исключая файлы с _*
        .on('error', console.log) // Если есть ошибки, выводим и продолжаем
    .pipe(htmlhint({
        "tag-pair": true,
        "style-disabled": true,
        "img-alt-require": true,
        "tagname-lowercase": true,
        "src-not-empty": true,
        "id-unique": true,
        "spec-char-escape": true
    }))
    .pipe(htmlhint.reporter())
    .pipe(prettify({
        indent_char: ' ',
        indent_size: 4
    }))
    .pipe(gulp.dest(paths.layouts.dest));
});

// Собираем JS
gulp.task('js', function() {
    gulp.src(paths.javascripts.src)
        .pipe(concat('index.js')) // Собираем все JS, кроме тех которые находятся в ./assets/js/vendor/**
        //.pipe(uglify()) // минификация
        .pipe(gulp.dest(paths.javascripts.dest));
});

gulp.task('js:build', function() {
    gulp.src(paths.javascripts.src)
        .pipe(concat('index.js')) // Собираем все JS, кроме тех которые находятся в ./assets/js/vendor/**
        //.pipe(uglify()) // минификация
        .pipe(gulp.dest(paths.javascripts.dest));
});

// Копируем и минимизируем изображения
gulp.task('images', function() {
    gulp.src(paths.images.src)
        .pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
        .pipe(gulp.dest(paths.images.dest));
});

gulp.task('svgmin', function() {
    gulp.src(paths.svg.src)
        .pipe(svgmin())
        .pipe(gulp.dest(paths.svg.dest));
});

gulp.task('zip', function () {
    gulp.src(paths.zip.src)
        .pipe(zip('archive.zip'))
        .pipe(gulp.dest(paths.zip.dest));
});

//
// .. Clean
//
gulp.task('clean', function() {
  return gulp.src('./build', {read: false})
    .pipe(clean());
});

// Browser-sync
gulp.task('browser-sync', function(){
    browserSync.init(['./build/*'], {
        server: {
            host: '127.0.0.1',
            port: '9000',
            baseDir: './build'
        }
    });
});

//
// .. Copy
//
gulp.task('copy:css', function() {
  gulp.src(paths.copycss.src)
    .pipe(gulp.dest(paths.copycss.dest));
});

gulp.task('copy:js', function() {
  gulp.src(paths.copyjs.src)
    .pipe(gulp.dest(paths.copyjs.dest));
});

//gulp.task('copy:images', function() {
//  gulp.src('./assets/img/**/*')
//    .pipe(gulp.dest('./public/img/'));
//});

gulp.task('copy:fonts', function() {
  gulp.src(paths.fonts.src)
    .pipe(gulp.dest(paths.fonts.dest));
});

gulp.task('copy:files', function() {
  gulp.src(paths.files.src)
    .pipe(gulp.dest(paths.files.dest));
});

// Gulp watch with browser-sync
gulp.task('watch', function(){

    // Копируем, что не должно компилиться
    //gulp.src('./assets/styles/**/*.css').pipe(gulp.dest('./public/css/'));
    //gulp.src('./assets/js/libs/*').pipe(gulp.dest('./public/js/libs/'));
    //gulp.src('./assets/static/**/*').pipe(gulp.dest('./public/'));
    //gulp.src('./assets/img/**/*').pipe(gulp.dest('./public/img/'));

    // At start
    gulp.start('stylus');
    gulp.start('html');
    gulp.start('jade');
    gulp.start('images');
    //gulp.start('svgmin');
    gulp.start('js');
    gulp.start('copy:css');
    gulp.start('copy:js');
    //gulp.start('copy:images');
    gulp.start('copy:fonts');
    gulp.start('copy:files');
    gulp.start('browser-sync');

    gulp.watch(paths.stylesheets.src, ['stylus']);
    gulp.watch(paths.html.src, ['html']);
    gulp.watch(paths.layouts.src, ['jade']);
    gulp.watch(paths.javascripts.src, ['js']);
    gulp.watch(paths.copycss.src, ['copy:css']);
    gulp.watch(paths.copyjs.src, ['copy:js']);
    gulp.watch(paths.images.src, ['images']);
    gulp.watch(paths.fonts.src, ['copy:fonts']);
    gulp.watch(paths.files.src, ['copy:files']);
    //gulp.watch('./assets/img/**/*.svg', ['svgmin']);
});

//****************************************************************************************************
//
// .. RUN
//
//****************************************************************************************************
gulp.task('default', ['connect', 'watch']);

gulp.task('dev', ['clean'], function() {
    gulp.start(
        'stylus',
        'html',
        'jade',
        'js',
        'copy:css',
        'copy:js',
        'copy:images',
        'copy:fonts',
        'copy:files'
    );
});

gulp.task('build', ['clean'], function() {
    gulp.start(
        'stylus:build',
        'html',
        'jade',
        'js:build',
        'images',
        'svgmin',
        'copy:css',
        'copy:js',
        'copy:fonts',
        'copy:files'
    );
});<commit_msg>update config<commit_after>//****************************************************************************************************
//
// .. VARIABLES
//
//****************************************************************************************************
var gulp = require('gulp'), // Сообственно Gulp JS
    jade = require('gulp-jade'), // Плагин для Jade
    htmlhint = require('gulp-htmlhint'),
    prettify = require('gulp-html-prettify'),
    htmlreplace = require('gulp-html-replace'),
    stylus = require('gulp-stylus'), // Плагин для Stylus
    autoprefixer = require('gulp-autoprefixer'), // Расстановка префиксов
    csso = require('gulp-csso'), // Минификация CSS
    imagemin = require('gulp-imagemin'), // Минификация изображений
    svgmin = require('gulp-svgmin'), // Минификация svg
    rename = require('gulp-rename'),
    clean = require('gulp-clean'),
    ignore = require('gulp-ignore'),
    uglify = require('gulp-uglify'), // Минификация JS
    concat = require('gulp-concat'), // Склейка файлов
    browserSync = require('browser-sync'); // livereload
    zip = require('gulp-zip'); // Архив собранного проекта

//****************************************************************************************************
//
// .. TASKS
//
//****************************************************************************************************

var paths = {
    layouts: {
        src: ['./assets/template/*.jade', '!assets/template/_*.jade'],
        dest: './build'
    },
    html: {
        src: ['./assets/**/*.html'],
        dest: './build'
    },
    stylesheets: {
        src: './assets/styles/**/*.styl',
        dest: './build/(-;/css'
    },
    copycss: {
        src: './assets/styles/**/*.css',
        dest: './build/(-;/css'
    },
    copyjs: {
        src: './assets/js/libs/*',
        dest: './build/(-;/js/libs'
    },
    javascripts: {
        src: ['./assets/js/**/*.js', '!assets/js/libs/**/*.js'],
        dest: './build/(-;/js'
    },
    images: {
        src: ['./assets/img/**/*', '!assets/img/**/*.svg'],
        dest: './build/(-;/img'
    },
    svg: {
        src: './assets/img/**/*.svg',
        dest: './build/(-;/img'
    },
    fonts: {
        src: './assets/fonts/**/*',
        dest: './build/(-;/fonts'
    },
    files: {
        src: './assets/static/**/*',
        dest: './build'
    },
    zip: {
        src: './assets/*',
        dest: './build'
    }
};

// Собираем Stylus
gulp.task('stylus', function() {
    gulp.src(paths.stylesheets.src)
        .pipe(stylus({set:['linenos']})) // собираем stylus
    .on('error', console.log) // Если есть ошибки, выводим и продолжаем
    .pipe(autoprefixer("last 1 version", "> 1%", "ie 8", "ie 7"))
    .pipe(gulp.dest(paths.stylesheets.dest)); // записываем css
});

gulp.task('stylus:build', function() {
    gulp.src(paths.stylesheets.src)
        .pipe(stylus()) // собираем stylus
    .on('error', console.log) // Если есть ошибки, выводим и продолжаем
    .pipe(autoprefixer("last 1 version", "> 1%", "ie 8", "ie 7"))
    .pipe(gulp.dest(paths.stylesheets.dest))
    .pipe(rename("style.min.css"))
    .pipe(csso()) // минимизируем css
    .pipe(gulp.dest(paths.stylesheets.dest)); // записываем css
});

// css
//gulp.task('cssmin', function() {
//    gulp.src('./assets/styles/mincss/*')
//    .pipe(csso())
//    .pipe(gulp.dest('./public/css/min'));
//});

// html
gulp.task('html', function(){
    gulp.src(paths.html.src)
        .pipe(htmlhint({
            "tag-pair": true,
            "style-disabled": true,
            "img-alt-require": true,
            "tagname-lowercase": true,
            "src-not-empty": true,
            "id-unique": true,
            "spec-char-escape": true
        }))
        .pipe(htmlhint.reporter())
        .pipe(prettify({
            indent_char: ' ',
            indent_size: 4
        }))
        .pipe(gulp.dest(paths.html.dest));
});

// Собираем html из Jade
gulp.task('jade', function() {
    gulp.src(paths.layouts.src)
        .pipe(jade({
            pretty: true
        }))  // Собираем Jade только в папке ./assets/template/ исключая файлы с _*
        .on('error', console.log) // Если есть ошибки, выводим и продолжаем
    .pipe(htmlhint({
        "tag-pair": true,
        "style-disabled": true,
        "img-alt-require": true,
        "tagname-lowercase": true,
        "src-not-empty": true,
        "id-unique": true,
        "spec-char-escape": true
    }))
    .pipe(htmlhint.reporter())
    .pipe(prettify({
        indent_char: ' ',
        indent_size: 4
    }))
    .pipe(gulp.dest(paths.layouts.dest));
});

// Собираем JS
gulp.task('js', function() {
    gulp.src(paths.javascripts.src)
        .pipe(concat('index.js')) // Собираем все JS, кроме тех которые находятся в ./assets/js/vendor/**
        //.pipe(uglify()) // минификация
        .pipe(gulp.dest(paths.javascripts.dest));
});

gulp.task('js:build', function() {
    gulp.src(paths.javascripts.src)
        .pipe(concat('index.js')) // Собираем все JS, кроме тех которые находятся в ./assets/js/vendor/**
        //.pipe(uglify()) // минификация
        .pipe(gulp.dest(paths.javascripts.dest));
});

// Копируем и минимизируем изображения
gulp.task('images', function() {
    gulp.src(paths.images.src)
        .pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
        .pipe(gulp.dest(paths.images.dest));
});

gulp.task('svgmin', function() {
    gulp.src(paths.svg.src)
        .pipe(svgmin())
        .pipe(gulp.dest(paths.svg.dest));
});

gulp.task('zip', function () {
    gulp.src(paths.zip.src)
        .pipe(zip('archive.zip'))
        .pipe(gulp.dest(paths.zip.dest));
});

//
// .. Clean
//
gulp.task('clean', function() {
  return gulp.src('./build', {read: false})
    .pipe(clean());
});

// Browser-sync
gulp.task('browser-sync', function(){
    browserSync.init(['./build/*'], {
        server: {
            host: '127.0.0.1',
            port: '9000',
            baseDir: './build'
        }
    });
});

//
// .. Copy
//
gulp.task('copy:css', function() {
  gulp.src(paths.copycss.src)
    .pipe(gulp.dest(paths.copycss.dest));
});

gulp.task('copy:js', function() {
  gulp.src(paths.copyjs.src)
    .pipe(gulp.dest(paths.copyjs.dest));
});

//gulp.task('copy:images', function() {
//  gulp.src('./assets/img/**/*')
//    .pipe(gulp.dest('./public/img/'));
//});

gulp.task('copy:fonts', function() {
  gulp.src(paths.fonts.src)
    .pipe(gulp.dest(paths.fonts.dest));
});

gulp.task('copy:files', function() {
  gulp.src(paths.files.src)
    .pipe(gulp.dest(paths.files.dest));
});

// Gulp watch with browser-sync
gulp.task('watch', function(){

    // Копируем, что не должно компилиться
    //gulp.src('./assets/styles/**/*.css').pipe(gulp.dest('./public/css/'));
    //gulp.src('./assets/js/libs/*').pipe(gulp.dest('./public/js/libs/'));
    //gulp.src('./assets/static/**/*').pipe(gulp.dest('./public/'));
    //gulp.src('./assets/img/**/*').pipe(gulp.dest('./public/img/'));

    // At start
    gulp.start('stylus');
    gulp.start('html');
    gulp.start('jade');
    gulp.start('images');
    //gulp.start('svgmin');
    gulp.start('js');
    gulp.start('copy:css');
    gulp.start('copy:js');
    //gulp.start('copy:images');
    gulp.start('copy:fonts');
    gulp.start('copy:files');
    gulp.start('browser-sync');

    gulp.watch(paths.stylesheets.src, ['stylus']);
    gulp.watch(paths.html.src, ['html']);
    gulp.watch(paths.layouts.src, ['jade']);
    gulp.watch(paths.javascripts.src, ['js']);
    gulp.watch(paths.copycss.src, ['copy:css']);
    gulp.watch(paths.copyjs.src, ['copy:js']);
    gulp.watch(paths.images.src, ['images']);
    gulp.watch(paths.fonts.src, ['copy:fonts']);
    gulp.watch(paths.files.src, ['copy:files']);
    //gulp.watch('./assets/img/**/*.svg', ['svgmin']);
});

//****************************************************************************************************
//
// .. RUN
//
//****************************************************************************************************
gulp.task('default', ['connect', 'watch']);

gulp.task('dev', ['clean'], function() {
    gulp.start(
        'stylus',
        'html',
        'jade',
        'js',
        'copy:css',
        'copy:js',
        'images',
        'svgmin',
        'copy:fonts',
        'copy:files'
    );
});

gulp.task('build', ['clean'], function() {
    gulp.start(
        'stylus:build',
        'html',
        'jade',
        'js:build',
        'images',
        'svgmin',
        'copy:css',
        'copy:js',
        'copy:fonts',
        'copy:files'
    );
});<|endoftext|>


<commit_before>var gulp	= require('gulp');
var del 	= require('del');
var sass 	= require('gulp-sass');
var please 	= require('gulp-pleeease');
var concat      = require('gulp-concat');
var uglify 	= require('gulp-uglify');
var jade 	= require('gulp-jade');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload      = browserSync.reload;
//var imagemin = require('gulp-imagemin');
//var pngquant = require('imagemin-pngquant');

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

gulp.task('copy',function () {
	return gulp.src('./src/js/**/*.js', {
		base: 'src'
	}).pipe(gulp.dest('./build'))
	.pipe(reload({stream: true}));
});

gulp.task('sass', function () {
    return gulp.src('./src/scss/**/*.scss')
        .pipe(sass({errLogToConsole: true}))
        .pipe(please({
   	        minifier: false,
        	autoprefixer: {
        		browsers: ['last 2 versions']
        	}
        }))
        .pipe(gulp.dest('./build/css'))
        .pipe(reload({stream: true}));
});

gulp.task('images', function () {
    return gulp.src('./src/img/**/*.*')
        .pipe(imagemin({
            progressive: true,
            use: [pngquant()]
        }))
        .pipe(gulp.dest('./build/img'))
        .pipe(reload({stream: true}));
});

gulp.task('build-js', function () {
	return gulp.src(['./src/js/**/*.js', , '!./src/js/vendor/*.js'])
		.pipe(concat('app.js'))
        .pipe(uglify({preserveComments: 'some'})) // Keep some comments
		.pipe(gulp.dest('./build/js'))
		.pipe(reload({stream: true}));
});

gulp.task('templates', function() {
	'use strict';
	var YOUR_LOCALS = {};
	return gulp.src('./src/jade/*.jade')
		.pipe(jade({
			locals: YOUR_LOCALS,
			pretty: true
		}))
		.pipe(gulp.dest('./build/'))
		.pipe(reload({ stream:true }));
});

gulp.task('serve',['dev'], function() {
  browserSync({
    server: {
      baseDir: 'build'
    }
  });
	gulp.watch('./src/jade/**/*.jade', ['templates']);
	gulp.watch('./src/scss/**/*.scss', ['sass']);
	gulp.watch('./src/css/**/*.css', ['copy']);
	gulp.watch('./src/js/**/*.js', ['copy']);
});

gulp.task('build', ['sass', 'copy', 'build-js', 'templates']);
gulp.task('dev', ['sass', 'copy', 'templates']);

gulp.task('default', ['clean'], function (cb) {
  runSequence('dev', ['sass', 'copy', 'templates'], cb);
});

gulp.task('builder', ['clean'], function (cb) {
  runSequence('build', ['sass', 'copy', 'build-js', 'templates'], cb);
});
<commit_msg>remove copy task from builder<commit_after>var gulp	= require('gulp');
var del 	= require('del');
var sass 	= require('gulp-sass');
var please 	= require('gulp-pleeease');
var concat      = require('gulp-concat');
var uglify 	= require('gulp-uglify');
var jade 	= require('gulp-jade');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload      = browserSync.reload;
//var imagemin = require('gulp-imagemin');
//var pngquant = require('imagemin-pngquant');

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

gulp.task('copy',function () {
	return gulp.src('./src/js/**/*.js', {
		base: 'src'
	}).pipe(gulp.dest('./build'))
	.pipe(reload({stream: true}));
});

gulp.task('sass', function () {
    return gulp.src('./src/scss/**/*.scss')
        .pipe(sass({errLogToConsole: true}))
        .pipe(please({
   	        minifier: false,
        	autoprefixer: {
        		browsers: ['last 2 versions']
        	}
        }))
        .pipe(gulp.dest('./build/css'))
        .pipe(reload({stream: true}));
});

gulp.task('images', function () {
    return gulp.src('./src/img/**/*.*')
        .pipe(imagemin({
            progressive: true,
            use: [pngquant()]
        }))
        .pipe(gulp.dest('./build/img'))
        .pipe(reload({stream: true}));
});

gulp.task('build-js', function () {
	return gulp.src(['./src/js/**/*.js', , '!./src/js/vendor/*.js'])
		.pipe(concat('app.js'))
        .pipe(uglify({preserveComments: 'some'})) // Keep some comments
		.pipe(gulp.dest('./build/js'))
		.pipe(reload({stream: true}));
});

gulp.task('templates', function() {
	'use strict';
	var YOUR_LOCALS = {};
	return gulp.src('./src/jade/*.jade')
		.pipe(jade({
			locals: YOUR_LOCALS,
			pretty: true
		}))
		.pipe(gulp.dest('./build/'))
		.pipe(reload({ stream:true }));
});

gulp.task('serve',['dev'], function() {
  browserSync({
    server: {
      baseDir: 'build'
    }
  });
	gulp.watch('./src/jade/**/*.jade', ['templates']);
	gulp.watch('./src/scss/**/*.scss', ['sass']);
	gulp.watch('./src/css/**/*.css', ['copy']);
	gulp.watch('./src/js/**/*.js', ['copy']);
});

gulp.task('build', ['sass', 'copy', 'build-js', 'templates']);
gulp.task('dev', ['sass', 'copy', 'templates']);

gulp.task('default', ['clean'], function (cb) {
  runSequence('dev', ['sass', 'copy', 'templates'], cb);
});

gulp.task('builder', ['clean'], function (cb) {
  runSequence('build', ['sass', 'build-js', 'templates'], cb);
});
<|endoftext|>


<commit_before>'use strict';

// Foundation for Apps
//
// We use this Gulpfile to assemble the documentation, run unit tests,
// and deploy changes to the live documentation and CDN.
//
// The tasks are grouped into these categories:
//   1. Libraries
//   2. Variables
//   3. Cleaning files
//   4. Copying files
//   5. Stylesheets
//   6. JavaScript
//   7. Testing
//   8. Server
//   9. Deployment
//  10. Default tasks

// 1. LIBRARIES
// - - - - - - - - - - - - - - -

var gulp        = require('gulp'),
    $           = require('gulp-load-plugins')(),
    rimraf      = require('rimraf'),
    runSequence = require('run-sequence'),
    modRewrite  = require('connect-modrewrite'),
    routes      = require('./bin/gulp-dynamic-routing'),
    merge       = require('merge-stream'),
    octophant   = require('octophant'),
    Server      = require('karma').Server;

// 2. VARIABLES
// - - - - - - - - - - - - - - -
var production = false;

var paths = {
  html: {
    base: [
      './docs/**/*.*',
      '!./docs/templates/**/*.*',
      '!./docs/assets/{scss,js}/**/*.*'
    ],
    templates: [
      './docs/templates/**/*.html'
    ],
    partials: [
      'js/angular/components/**/*.html'
    ]
  },
  sass: {
    loadPaths: [
      'scss',
      'docs/assets/scss'
    ],
    testPaths: [
      'scss',
      'docs/assets/scss',
      'bower_components/bootcamp/dist'
    ]
  },
  javascript: {
    foundation: [
      'js/vendor/**/*.js',
      'js/angular/**/*.js',
      '!js/angular/app.js'
    ],
    base: [
      'js/vendor/**/*.js',
      'js/angular/**/*.js',
      '!js/angular/app.js'
    ],
    libs: [
      'bower_components/fastclick/lib/fastclick.js',
      'bower_components/viewport-units-buggyfill/viewport-units-buggyfill.js',
      'bower_components/tether/tether.js',
      'bower_components/angular/angular.js',
      'bower_components/angular-animate/angular-animate.js',
      'bower_components/angular-ui-router/release/angular-ui-router.js',
      'bower_components/hammerjs/hammer.js'
    ],
    docs: [
      'bower_components/marked/lib/marked.js',
      'bower_components/highlightjs/highlight.pack.js',
      'bower_components/angular-highlightjs/angular-highlightjs.js',
      'bower_components/allmighty-autocomplete/script/autocomplete.js',
      'docs/assets/js/app.js'
    ]
  }
};

// 3. CLEANIN' FILES
// - - - - - - - - - - - - - - -

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

// Clean the partials directory
gulp.task('clean:partials', function(cb) {
  rimraf('./build/partials', cb);
});

// Clean the dist directory
gulp.task('clean:dist', function(cb) {
  rimraf('./dist', cb);
});

// 4. COPYING FILES
// - - - - - - - - - - - - - - -

// Copy static files (but not the Angular templates, Sass, or JS)
gulp.task('copy', function() {
  gulp.src(paths.html.base, {
    base: './docs/'
  })
    .pipe(gulp.dest('build'));

  return gulp.src('./iconic/**/*')
    .pipe(gulp.dest('build/assets/img/iconic/'));
});

// Copy page templates and generate routes
gulp.task('copy:templates', ['javascript'], function() {
  return gulp.src(paths.html.templates)
    .pipe(routes({
      path: 'build/assets/js/routes.js',
      root: 'docs'
    }))
    .pipe(gulp.dest('./build/templates'))
  ;
});

// Copy Foundation directive partials
gulp.task('copy:partials', ['clean:partials'], function(cb) {
  gulp.src(paths.html.partials)
    .pipe($.ngHtml2js({
      prefix: 'components/',
      moduleName: 'base',
      declareModule: false
    }))
    .pipe($.if(production, $.uglify()))
    .pipe($.concat('templates.js'))
    .pipe(gulp.dest('./build/assets/js'));

  gulp.src('./docs/partials/**/*.html')
    .pipe(gulp.dest('./build/partials/'));

  cb();
});

// 5. STYLESHEETS
// - - - - - - - - - - - - - - -

// Inject styles for docs-specific libraries
gulp.task('css', ['sass'], function() {
  var dirs = [
    'bower_components/allmighty-autocomplete/style/autocomplete.css',
    'build/assets/css/app.css'
  ];
  return gulp.src(dirs)
    .pipe($.concat('app.css'))
    .pipe(gulp.dest('build/assets/css'))
  ;
});

// Compile stylesheets
gulp.task('sass', function() {
  return gulp.src('docs/assets/scss/app.scss')
    .pipe($.sass({
      includePaths: paths.sass.loadPaths,
      outputStyle: 'nested',
      errLogToConsole: true
    }))
    .pipe($.autoprefixer({
      browsers: ['> 1%', 'last 2 versions', 'ie >= 10', 'iOS >= 7', 'Safari >= 7', 'Opera >= 25']
    }))
    .pipe(gulp.dest('./build/assets/css/'));
});

// Generate Sass settings file
gulp.task('sass:settings', function() {
  octophant([
    'scss/_includes.scss',
    'scss/_global.scss',
    'scss/helpers/_breakpoints.scss',
    'scss/components/_typography.scss',
    'scss/components/_grid.scss',
    'scss/components/_button.scss',
    'scss/components/*.scss'
  ], {
    title: 'Foundation for Apps Settings'.toUpperCase(),
    partialsPath: 'docs/partials/scss',
    settingsPath: 'scss'
  });
});

// 6. JAVASCRIPT
// - - - - - - - - - - - - - - -

// Compile Foundation JavaScript
gulp.task('javascript', function() {
  var dirs = paths.javascript.libs.concat(
    paths.javascript.foundation,
    paths.javascript.docs
  );
  return gulp.src(dirs)
    .pipe($.if(production, $.uglify({
      beautify: true,
      mangle: false
    }).on('error', function(e) {
      console.log(e);
    })))
    .pipe($.concat('app.js'))
    .pipe(gulp.dest('./build/assets/js/'))
  ;
});

// 7. SERVER
// - - - - - - - - - - - - - - -

gulp.task('server:start', function() {
  $.connect.server({
    root: './build',
    middleware: function() {
      return [
        modRewrite(['^[^\\.]*$ /index.html [L]'])
      ];
    }
  });
});

// 8. TESTING
// - - - - - - - - - - - - - - -

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

gulp.task('test:sass', function() {
  return gulp.src('./tests/unit/scss/tests.scss')
    .pipe($.sass({
      includePaths: paths.sass.testPaths,
      outputStyle: 'nested',
      errLogToConsole: true
    }))
    .on('data', function(data) {
      console.log(data.contents.toString());
    });
});

gulp.task('test', ['test:karma', 'test:sass'], function() {
  console.log('Tests finished.');
});

// Motion testing

gulp.task('test:motion:compile', ['clean', 'sass', 'javascript'], function() {
  gulp.src('./tests/motion/index.html')
    .pipe(gulp.dest('./build'));
  gulp.src('./tests/motion/templates/**/*.html')
    .pipe(routes({
      path: 'build/assets/js/routes.js',
      root: 'tests/motion'
    }))
    .pipe(gulp.dest('./build/templates'));
});

gulp.task('test:motion', ['server:start', 'test:motion:compile'], function() {
  gulp.watch(['js/**/*', 'tests/motion/**/*'], ['test:motion:compile']);
});

// 9. DISTRIBUTION BUILD
// - - - - - - - - - - - - - - -

// Distribution files
gulp.task('production:enable', function(cb) { production = true; cb(); });

gulp.task('build:dist', ['clean:dist', 'production:enable', 'build'], function() {
  var merged = merge();

  // legacy package
  merged.add(gulp.src('scss/foundation.scss')
    .pipe($.sass({
      outputStyle: 'nested',
      errLogToConsole: true
    }))
    .pipe($.autoprefixer({
      browsers: ['> 1%', 'last 2 versions', 'ie >= 10', 'iOS >= 7', 'Safari >= 7', 'Opera >= 25']
    }))
    .pipe($.rename('foundation-apps.css'))
    .pipe(gulp.dest('./dist/css'))
    .pipe($.minifyCss())
    .pipe($.rename('foundation-apps.min.css'))
    .pipe(gulp.dest('./dist/css')));

  merged.add(gulp.src(paths.javascript.foundation)
    .pipe($.concat('foundation-apps.js'))
    .pipe(gulp.dest('./dist/js'))
    .pipe($.uglify())
    .pipe($.rename('foundation-apps.min.js'))
    .pipe(gulp.dest('./dist/js')));

  merged.add(gulp.src(paths.html.partials)
    .pipe($.ngHtml2js({
      prefix: 'components/',
      moduleName: 'foundation',
      declareModule: false
    }))
    .pipe($.concat('foundation-apps-templates.js'))
    .pipe(gulp.dest('./dist/js'))
    .pipe($.uglify())
    .pipe($.rename('foundation-apps-templates.min.js'))
    .pipe(gulp.dest('./dist/js')));

  // base package
  merged.add(gulp.src('scss/base.scss')
    .pipe($.sass({
      outputStyle: 'nested',
      errLogToConsole: true
    }))
    .pipe($.autoprefixer({
      browsers: ['> 1%', 'last 2 versions', 'ie >= 10', 'iOS >= 7', 'Safari >= 7', 'Opera >= 25']
    }))
    .pipe($.rename('base-apps.css'))
    .pipe(gulp.dest('./dist/css'))
    .pipe($.minifyCss())
    .pipe($.rename('base-apps.min.css'))
    .pipe(gulp.dest('./dist/css')));

  merged.add(gulp.src(paths.javascript.base)
    .pipe($.concat('base-apps.js'))
    .pipe(gulp.dest('./dist/js'))
    .pipe($.uglify())
    .pipe($.rename('base-apps.min.js'))
    .pipe(gulp.dest('./dist/js')));

  merged.add(gulp.src(paths.html.partials)
    .pipe($.ngHtml2js({
      prefix: 'components/',
      moduleName: 'base',
      declareModule: false
    }))
    .pipe($.concat('base-apps-templates.js'))
    .pipe(gulp.dest('./dist/js'))
    .pipe($.uglify())
    .pipe($.rename('base-apps-templates.min.js'))
    .pipe(gulp.dest('./dist/js')));

  merged.add(gulp.src("./build/**/*")
    .pipe(gulp.dest('./dist/docs')));

  return merged;
});

// 10. NOW BRING IT TOGETHER
// - - - - - - - - - - - - - - -

// Build the documentation once
gulp.task('build', function(cb) {
  runSequence('clean', ['copy', 'copy:partials', 'css', 'javascript', 'copy:templates'], function() {
    cb();
  });
});

// Build the documentation, start a test server, and re-compile when files change
gulp.task('default', ['build', 'server:start'], function() {

  // Watch static files
  gulp.watch(paths.html.base, ['copy']);

  // Watch Angular templates
  gulp.watch(paths.html.templates, ['copy:templates']);

  // Watch Angular partials
  gulp.watch(paths.html.partials, ['copy:partials']);

  // Watch Sass
  gulp.watch(['./docs/assets/scss/**/*', './scss/**/*'], ['css']);

  // Watch JavaScript
  gulp.watch(paths.javascript.foundation.concat(paths.javascript.docs), ['javascript']);
});

gulp.task('bump:patch', function() { return bump('patch'); });
gulp.task('bump:minor', function() { return bump('minor'); });
gulp.task('bump:major', function() { return bump('major'); });

gulp.task('publish:patch', ['build:dist', 'bump:patch'], function() { return publish(); });
gulp.task('publish:minor', ['build:dist', 'bump:minor'], function() { return publish(); });
gulp.task('publish:major', ['build:dist', 'bump:major'], function() { return publish(); });

function bump(importance) {
  // get all the files to bump version in
  return gulp.src(['./package.json', './bower.json'])
    // bump the version number in those files
    .pipe($.bump({type: importance}))
    // save it back to filesystem
    .pipe(gulp.dest('./'));
}

function publish() {
  return gulp.src(['./package.json', './bower.json', './dist/**'])
    // commit the changes
    .pipe($.git.commit('bump version'))
    // read only one file to get the version number
    .pipe($.filter('package.json'))
    // **tag it in the repository**
    .pipe($.tagVersion());
}
<commit_msg>clean up build logic<commit_after>'use strict';

// Foundation for Apps
//
// We use this Gulpfile to assemble the documentation, run unit tests,
// and deploy changes to the live documentation and CDN.
//
// The tasks are grouped into these categories:
//   1. Libraries
//   2. Variables
//   3. Cleaning files
//   4. Copying files
//   5. Stylesheets
//   6. JavaScript
//   7. Testing
//   8. Server
//   9. Deployment
//  10. Default tasks

// 1. LIBRARIES
// - - - - - - - - - - - - - - -

var gulp        = require('gulp'),
    $           = require('gulp-load-plugins')(),
    rimraf      = require('rimraf'),
    runSequence = require('run-sequence'),
    modRewrite  = require('connect-modrewrite'),
    routes      = require('./bin/gulp-dynamic-routing'),
    merge       = require('merge-stream'),
    octophant   = require('octophant'),
    Server      = require('karma').Server;

// 2. VARIABLES
// - - - - - - - - - - - - - - -
var production = false;

var paths = {
  html: {
    base: [
      './docs/**/*.*',
      '!./docs/templates/**/*.*',
      '!./docs/assets/{scss,js}/**/*.*'
    ],
    templates: [
      './docs/templates/**/*.html'
    ],
    partials: [
      'js/angular/components/**/*.html'
    ]
  },
  sass: {
    loadPaths: [
      'scss',
      'docs/assets/scss'
    ],
    testPaths: [
      'scss',
      'docs/assets/scss',
      'bower_components/bootcamp/dist'
    ]
  },
  javascript: {
    foundation: [
      'js/vendor/**/*.js',
      'js/angular/**/*.js',
      '!js/angular/app.js'
    ],
    base: [
      'js/vendor/**/*.js',
      'js/angular/**/*.js',
      '!js/angular/app.js'
    ],
    libs: [
      'bower_components/fastclick/lib/fastclick.js',
      'bower_components/viewport-units-buggyfill/viewport-units-buggyfill.js',
      'bower_components/tether/tether.js',
      'bower_components/angular/angular.js',
      'bower_components/angular-animate/angular-animate.js',
      'bower_components/angular-ui-router/release/angular-ui-router.js',
      'bower_components/hammerjs/hammer.js'
    ],
    docs: [
      'bower_components/marked/lib/marked.js',
      'bower_components/highlightjs/highlight.pack.js',
      'bower_components/angular-highlightjs/angular-highlightjs.js',
      'bower_components/allmighty-autocomplete/script/autocomplete.js',
      'docs/assets/js/app.js'
    ]
  }
};

// 3. CLEANIN' FILES
// - - - - - - - - - - - - - - -

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

// Clean the partials directory
gulp.task('clean:partials', function(cb) {
  rimraf('./build/partials', cb);
});

// Clean the dist directory
gulp.task('clean:dist', function(cb) {
  rimraf('./dist', cb);
});

// 4. COPYING FILES
// - - - - - - - - - - - - - - -

// Copy static files (but not the Angular templates, Sass, or JS)
gulp.task('copy', function() {
  var merged = merge();

  merged.add(gulp.src(paths.html.base, {
    base: './docs/'
  })
    .pipe(gulp.dest('build')));

  merged.add(gulp.src('./iconic/**/*')
    .pipe(gulp.dest('build/assets/img/iconic/')));

  return merged;
});

// Copy page templates and generate routes
gulp.task('copy:templates', ['javascript'], function() {
  return gulp.src(paths.html.templates)
    .pipe(routes({
      path: 'build/assets/js/routes.js',
      root: 'docs'
    }))
    .pipe(gulp.dest('./build/templates'))
  ;
});

// Copy Foundation directive partials
gulp.task('copy:partials', ['clean:partials'], function() {
  var merged = merge();

  // legacy package
  merged.add(gulp.src(paths.html.partials)
  .pipe($.ngHtml2js({
    prefix: 'components/',
    moduleName: 'foundation',
    declareModule: false
  }))
  .pipe($.concat('foundation-apps-templates.js'))
  .pipe(gulp.dest('./build/assets/js'))
  .pipe($.if(production, $.uglify()))
  .pipe($.rename('foundation-apps-templates.min.js'))
  .pipe(gulp.dest('./build/assets/js')));

  // base package
  merged.add(gulp.src(paths.html.partials)
    .pipe($.ngHtml2js({
      prefix: 'components/',
      moduleName: 'base',
      declareModule: false
    }))
    .pipe($.concat('base-apps-templates.js'))
    .pipe(gulp.dest('./build/assets/js'))
    .pipe($.if(production, $.uglify()))
    .pipe($.rename('base-apps-templates.min.js'))
    .pipe(gulp.dest('./build/assets/js'))
    .pipe($.concat('templates.js')) // use same template for docs
    .pipe(gulp.dest('./build/assets/js')));

  merged.add(gulp.src('./docs/partials/**/*.html')
    .pipe(gulp.dest('./build/partials/')));

  return merged;
});

// 5. STYLESHEETS
// - - - - - - - - - - - - - - -

// Inject styles for docs-specific libraries
gulp.task('css', ['sass'], function() {
  var dirs = [
    'bower_components/allmighty-autocomplete/style/autocomplete.css',
    'build/assets/css/app.css'
  ];
  return gulp.src(dirs)
    .pipe($.concat('app.css'))
    .pipe(gulp.dest('build/assets/css'))
  ;
});

// Compile stylesheets
gulp.task('sass', function() {
  var merged = merge();

  // legacy package
  merged.add(gulp.src('scss/foundation.scss')
    .pipe($.sass({
      outputStyle: 'nested',
      errLogToConsole: true
    }))
    .pipe($.autoprefixer({
      browsers: ['> 1%', 'last 2 versions', 'ie >= 10', 'iOS >= 7', 'Safari >= 7', 'Opera >= 25']
    }))
    .pipe($.rename('foundation-apps.css'))
    .pipe(gulp.dest('./build/assets/css'))
    .pipe($.if(production, $.minifyCss()))
    .pipe($.rename('foundation-apps.min.css'))
    .pipe(gulp.dest('./build/assets/css')));

  // base package
  merged.add(gulp.src('scss/base.scss')
    .pipe($.sass({
      outputStyle: 'nested',
      errLogToConsole: true
    }))
    .pipe($.autoprefixer({
      browsers: ['> 1%', 'last 2 versions', 'ie >= 10', 'iOS >= 7', 'Safari >= 7', 'Opera >= 25']
    }))
    .pipe($.rename('base-apps.css'))
    .pipe(gulp.dest('./build/assets/css'))
    .pipe($.if(production, $.minifyCss()))
    .pipe($.rename('base-apps.min.css'))
    .pipe(gulp.dest('./build/assets/css')));

  merged.add(gulp.src('docs/assets/scss/app.scss')
    .pipe($.sass({
      includePaths: paths.sass.loadPaths,
      outputStyle: 'nested',
      errLogToConsole: true
    }))
    .pipe($.autoprefixer({
      browsers: ['> 1%', 'last 2 versions', 'ie >= 10', 'iOS >= 7', 'Safari >= 7', 'Opera >= 25']
    }))
    .pipe($.if(production, $.minifyCss()))
    .pipe(gulp.dest('./build/assets/css/')));

  return merged;
});

// Generate Sass settings file
gulp.task('sass:settings', function() {
  octophant([
    'scss/_includes.scss',
    'scss/_global.scss',
    'scss/helpers/_breakpoints.scss',
    'scss/components/_typography.scss',
    'scss/components/_grid.scss',
    'scss/components/_button.scss',
    'scss/components/*.scss'
  ], {
    title: 'Foundation for Apps Settings'.toUpperCase(),
    partialsPath: 'docs/partials/scss',
    settingsPath: 'scss'
  });
});

// 6. JAVASCRIPT
// - - - - - - - - - - - - - - -

// Compile Foundation JavaScript
gulp.task('javascript', function() {
  var merged = merge();

  // legacy package
  merged.add(gulp.src(paths.javascript.foundation)
    .pipe($.concat('foundation-apps.js'))
    .pipe(gulp.dest('./build/assets/js'))
    .pipe($.if(production, $.uglify()))
    .pipe($.rename('foundation-apps.min.js'))
    .pipe(gulp.dest('./build/assets/js')));

  // base package
  merged.add(gulp.src(paths.javascript.base)
    .pipe($.concat('base-apps.js'))
    .pipe(gulp.dest('./build/assets/js'))
    .pipe($.if(production, $.uglify()))
    .pipe($.rename('base-apps.min.js'))
    .pipe(gulp.dest('./build/assets/js')));

  var dirs = paths.javascript.libs.concat(
      paths.javascript.base,
      paths.javascript.docs
    );
  merged.add(gulp.src(dirs)
    .pipe($.if(production, $.uglify()))
    .pipe($.concat('app.js'))
    .pipe(gulp.dest('./build/assets/js/')));

  return merged;
});

// 7. SERVER
// - - - - - - - - - - - - - - -

gulp.task('server:start', function() {
  $.connect.server({
    root: './build',
    middleware: function() {
      return [
        modRewrite(['^[^\\.]*$ /index.html [L]'])
      ];
    }
  });
});

gulp.task('server:start:dist', function() {
  $.connect.server({
    root: './dist/docs',
    middleware: function() {
      return [
        modRewrite(['^[^\\.]*$ /index.html [L]'])
      ];
    }
  });
});

// 8. TESTING
// - - - - - - - - - - - - - - -

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

gulp.task('test:sass', function() {
  return gulp.src('./tests/unit/scss/tests.scss')
    .pipe($.sass({
      includePaths: paths.sass.testPaths,
      outputStyle: 'nested',
      errLogToConsole: true
    }))
    .on('data', function(data) {
      console.log(data.contents.toString());
    });
});

gulp.task('test', ['test:karma', 'test:sass'], function() {
  console.log('Tests finished.');
});

// Motion testing

gulp.task('test:motion:compile', ['clean', 'sass', 'javascript'], function() {
  var merged = merge();

  merged.add(gulp.src('./tests/motion/index.html')
    .pipe(gulp.dest('./build')));

  merged.add(gulp.src('./tests/motion/templates/**/*.html')
    .pipe(routes({
      path: 'build/assets/js/routes.js',
      root: 'tests/motion'
    }))
    .pipe(gulp.dest('./build/templates')));
});

gulp.task('test:motion', ['server:start', 'test:motion:compile'], function() {
  gulp.watch(['js/**/*', 'tests/motion/**/*'], ['test:motion:compile']);
});

// 9. DISTRIBUTION BUILD
// - - - - - - - - - - - - - - -

gulp.task('copy:dist', function() {
  var merged = merge();

  // copy javascript
  merged.add(gulp.src([
      "./build/assets/js/foundation-apps*.js",
      "./build/assets/js/base-apps*.js"
    ])
    .pipe(gulp.dest('./dist/js')));

  // copy css
  merged.add(gulp.src([
      "./build/assets/css/foundation-apps*.css",
      "./build/assets/css/base-apps*.css"
    ])
    .pipe(gulp.dest('./dist/css')));

  // copy docs
  merged.add(gulp.src([
    "./build/index.html",
    "./build/partials/**/*",
    "./build/templates/**/*",
    "./build/assets/fonts/**/*",
    "./build/assets/img/**/*",
    "./build/assets/css/app.css",
    "./build/assets/js/app.js",
    "./build/assets/js/routes.js",
    "./build/assets/js/templates.js"
  ], {
    base: "./build"
  })
    .pipe(gulp.dest('./dist/docs')));

  return merged;
});

// 10. NOW BRING IT TOGETHER
// - - - - - - - - - - - - - - -

gulp.task('production:enable', function(cb) { production = true; cb(); });

// Build the documentation once
gulp.task('build', function(cb) {
  runSequence('clean', ['copy', 'copy:partials', 'css', 'javascript', 'copy:templates'], function() {
    cb();
  });
});

gulp.task('build:dist', function(cb) {
  runSequence('clean:dist', 'production:enable', 'build', 'copy:dist', function() {
    cb();
  });
});

// Build the documentation, start a test server, and re-compile when files change
gulp.task('default', ['build', 'server:start'], function() {

  // Watch static files
  gulp.watch(paths.html.base, ['copy']);

  // Watch Angular templates
  gulp.watch(paths.html.templates, ['copy:templates']);

  // Watch Angular partials
  gulp.watch(paths.html.partials, ['copy:partials']);

  // Watch Sass
  gulp.watch(['./docs/assets/scss/**/*', './scss/**/*'], ['css']);

  // Watch JavaScript
  gulp.watch(paths.javascript.foundation.concat(paths.javascript.docs), ['javascript']);
});

// Build the documentation, start a test server, and re-compile when files change
gulp.task('default:dist', ['build:dist', 'server:start:dist'], function() {

  // Watch static files
  gulp.watch(paths.html.base, ['copy', 'copy:dist']);

  // Watch Angular templates
  gulp.watch(paths.html.templates, ['copy:templates', 'copy:dist']);

  // Watch Angular partials
  gulp.watch(paths.html.partials, ['copy:partials', 'copy:dist']);

  // Watch Sass
  gulp.watch(['./docs/assets/scss/**/*', './scss/**/*'], ['css', 'copy:dist']);

  // Watch JavaScript
  gulp.watch(paths.javascript.foundation.concat(paths.javascript.docs), ['javascript', 'copy:dist']);
});

gulp.task('bump:patch', function() { return bump('patch'); });
gulp.task('bump:minor', function() { return bump('minor'); });
gulp.task('bump:major', function() { return bump('major'); });

gulp.task('publish:patch', ['build:dist', 'bump:patch'], function() { return publish(); });
gulp.task('publish:minor', ['build:dist', 'bump:minor'], function() { return publish(); });
gulp.task('publish:major', ['build:dist', 'bump:major'], function() { return publish(); });

function bump(importance) {
  // get all the files to bump version in
  return gulp.src(['./package.json', './bower.json'])
    // bump the version number in those files
    .pipe($.bump({type: importance}))
    // save it back to filesystem
    .pipe(gulp.dest('./'));
}

function publish() {
  return gulp.src(['./package.json', './bower.json', './dist/**/*'])
    // commit the changes
    .pipe($.git.commit('bump version'))
    // read only one file to get the version number
    .pipe($.filter('package.json'))
    // **tag it in the repository**
    .pipe($.tagVersion());
}
<|endoftext|>


<commit_before>/*
 * Mithril.js Starter Kit
 * Copyright (c) 2014 Phil Toms (@philtoms)
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.txt file in the root directory of this source tree.
 */

'use strict';

// Include Gulp and other build automation tools and utilities
// See: https://github.com/gulpjs/gulp/blob/master/docs/API.md

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var path = require('path');
var merge = require('merge-stream');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var pagespeed = require('psi');
var extend = require('extend');
var fs = require('fs');
var url = require('url');
var argv = require('minimist')(process.argv.slice(2));

// Settings
var DEST = './build';                         // The build output folder
var RELEASE = !!argv.release;                 // Minimize and optimize during a build?
var GOOGLE_ANALYTICS_ID = 'UA-XXXXX-X';       // https://www.google.com/analytics/web/
var AUTOPREFIXER_BROWSERS = [                 // https://github.com/ai/autoprefixer
  'ie >= 10',
  'ie_mob >= 10',
  'ff >= 30',
  'chrome >= 34',
  'safari >= 7',
  'opera >= 23',
  'ios >= 7',
  'android >= 4.4',
  'bb >= 10'
];

var src = {};
var watch = false;
var pkgs = (function() {
  var pkgs = {};
  var map = function(source) {
    for (var key in source) {
      pkgs[key.replace(/[^a-z0-9]/gi, '')] = source[key].substring(1);
    }
  };
  map(require('./package.json').dependencies);
  return pkgs;
}());

// The default task
gulp.task('default', ['serve']);

// Clean up
gulp.task('clean', del.bind(null, [DEST]));

// 3rd party libraries
gulp.task('vendor', function() {
  src.vendor = [
  'bower_components/todomvc-common/base.{js,css}',
  'bower_components/todomvc-common/bg.png'
  ];
  return merge(
    gulp.src(src.vendor)
      .pipe(gulp.dest(DEST + '/vendor')),
    gulp.src('./node_modules/bootstrap/dist/fonts/**')
      .pipe(gulp.dest(DEST + '/fonts'))
  );
});

// Static files
gulp.task('assets', function() {
  src.assets = [
  'src/assets/**',
  'src/pages/index.html'
  ];
  return gulp.src(src.assets)
    .pipe($.changed(DEST))
    .pipe(gulp.dest(DEST))
    .pipe($.size({title: 'assets'}));
});

// Images
gulp.task('images', function() {
  src.images = 'src/images/**';
  return gulp.src(src.images)
    .pipe($.changed(DEST + '/images'))
    .pipe($.imagemin({
      progressive: true,
      interlaced: true
    }))
    .pipe(gulp.dest(DEST + '/images'))
    .pipe($.size({title: 'images'}));
});

// HTML pages
gulp.task('pages', function() {
  src.pages = ['src/pages/**/*.js', 'src/pages/index.html', 'src/pages/404.html'];

  return gulp.src(src.pages)
    .pipe($.changed(DEST, {extension: '.html'}))
    .pipe($.replace('UA-XXXXX-X', GOOGLE_ANALYTICS_ID))
    .pipe($.if(!RELEASE, $.replace('.min.js', '.js')))
    .pipe($.if(RELEASE, $.htmlmin({
      removeComments: true,
      collapseWhitespace: true,
      minifyJS: true
    }), $.jsbeautifier()))
    .pipe(gulp.dest(DEST))
    .pipe($.size({title: 'pages'}));
});

// CSS style sheets
gulp.task('styles', function() {
  src.styles = 'src/styles/**/*.{css,less}';
  return gulp.src('src/styles/app.less')
    .pipe($.plumber())
    .pipe($.less({
      sourceMap: !RELEASE,
      sourceMapBasepath: __dirname
    }))
    .on('error', console.error.bind(console))
    .pipe($.autoprefixer({browsers: AUTOPREFIXER_BROWSERS}))
    .pipe($.if(RELEASE, $.minifyCss()))
    .pipe(gulp.dest(DEST + '/css'))
    .pipe($.size({title: 'styles'}));
});

// Bundle
gulp.task('bundle', function(cb) {
  var options = require('./config/webpack.js')(RELEASE,watch);
  gulp.src('./src/app.js')
    .pipe($.webpack(options))
    .pipe(gulp.dest('./build/'));
  cb(null);
});

// Build the app from source code
gulp.task('build', ['clean'], function(cb) {
  runSequence(['vendor', 'assets', 'images', 'styles', 'bundle'], cb);
});

// Launch a lightweight HTTP Server
gulp.task('serve', function(cb) {

  watch = true;

  runSequence('build', function() {
    browserSync({
      notify: false,
      // Customize the BrowserSync console logging prefix
      logPrefix: 'MSK',
      // Run as an https by uncommenting 'https: true'
      // Note: this uses an unsigned certificate which on first access
      //       will present a certificate warning in the browser.
      // https: true,
      server: {
        baseDir: DEST,
        // Allow web page requests without .html file extension in URLs
        middleware: function(req, res, cb) {
          var uri = url.parse(req.url);
          if (uri.pathname.length > 1 &&
            path.extname(uri.pathname) === '' &&
            fs.existsSync(DEST + uri.pathname + '.html')) {
            req.url = uri.pathname + '.html' + (uri.search || '');
          }
          cb();
        }
      }
    });

    gulp.watch(src.vendor, ['vendor']);
    gulp.watch(src.assets, ['assets']);
    gulp.watch(src.images, ['images']);
    gulp.watch(src.pages, ['pages']);
    gulp.watch(src.styles, ['styles']);
    gulp.watch(DEST + '/**/*.*', function(file) {
      browserSync.reload(path.relative(__dirname, file.path));
    });
    cb();
  });
});

// run jest tests
// gulp.task('jest', function () {
//     return gulp.src('src/**/__tests__').pipe($.jest({
//         unmockedModulePathPatterns: [
//         ],
//         testDirectoryName: "src",
//         testPathIgnorePatterns: [
//             "node_modules",
//             "spec/support"
//         ],
//         moduleFileExtensions: [
//             "js",
//             "json",
//             "msx"
//         ]
//     }));
// });

var jest = require('jest-cli');
var chalk = require('chalk');
gulp.task('jest', function (callback) {
  var onComplete = function (result) {
    // if (result) {
    // } else {
    //   console.log(chalk.bgYellow('!!! Jest tests failed! You should fix them soon. !!!'));
    // }
    callback();
  }
  jest.runCLI({}, __dirname, onComplete);
});

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

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

// Deploy to GitHub Pages
gulp.task('deploy', function() {

  // Remove temp folder
  if (argv.clean) {
    var os = require('os');
    var path = require('path');
    var repoPath = path.join(os.tmpdir(), 'tmpRepo');
    $.util.log('Delete ' + $.util.colors.magenta(repoPath));
    del.sync(repoPath, {force: true});
  }

  return gulp.src(DEST + '/**/*')
    .pipe($.if('**/robots.txt', !argv.production ? $.replace('Disallow:', 'Disallow: /') : $.util.noop()))
    .pipe($.ghPages({
      remoteUrl: 'https://github.com/{name}/{name}.github.io.git',
      branch: 'master'
    }));
});

// Run PageSpeed Insights
// Update `url` below to the public URL for your site
gulp.task('pagespeed', pagespeed.bind(null, {
  // By default, we use the PageSpeed Insights
  // free (no API key) tier. You can use a Google
  // Developer API key if you have one. See
  // http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
  url: 'https://example.com',
  strategy: 'mobile'
}));
<commit_msg>Update gulpfile.js<commit_after>/*
 * Mithril.js Starter Kit
 * Copyright (c) 2014 Phil Toms (@philtoms)
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.txt file in the root directory of this source tree.
 */

'use strict';

// Include Gulp and other build automation tools and utilities
// See: https://github.com/gulpjs/gulp/blob/master/docs/API.md

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var path = require('path');
var merge = require('merge-stream');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var pagespeed = require('psi');
var extend = require('extend');
var fs = require('fs');
var url = require('url');
var argv = require('minimist')(process.argv.slice(2));

// Settings
var DEST = './build';                         // The build output folder
var RELEASE = !!argv.release;                 // Minimize and optimize during a build?
var GOOGLE_ANALYTICS_ID = 'UA-XXXXX-X';       // https://www.google.com/analytics/web/
var AUTOPREFIXER_BROWSERS = [                 // https://github.com/ai/autoprefixer
  'ie >= 10',
  'ie_mob >= 10',
  'ff >= 30',
  'chrome >= 34',
  'safari >= 7',
  'opera >= 23',
  'ios >= 7',
  'android >= 4.4',
  'bb >= 10'
];

var src = {};
var watch = false;
var pkgs = (function() {
  var pkgs = {};
  var map = function(source) {
    for (var key in source) {
      pkgs[key.replace(/[^a-z0-9]/gi, '')] = source[key].substring(1);
    }
  };
  map(require('./package.json').dependencies);
  return pkgs;
}());

// The default task
gulp.task('default', ['serve']);

// Clean up
gulp.task('clean', del.bind(null, [DEST]));

// 3rd party libraries
gulp.task('vendor', function() {
  src.vendor = [
  ];
  return merge(
    gulp.src(src.vendor)
      .pipe(gulp.dest(DEST + '/vendor')),
    gulp.src('./node_modules/bootstrap/dist/fonts/**')
      .pipe(gulp.dest(DEST + '/fonts'))
  );
});

// Static files
gulp.task('assets', function() {
  src.assets = [
  'src/assets/**',
  'src/pages/index.html'
  ];
  return gulp.src(src.assets)
    .pipe($.changed(DEST))
    .pipe(gulp.dest(DEST))
    .pipe($.size({title: 'assets'}));
});

// Images
gulp.task('images', function() {
  src.images = 'src/images/**';
  return gulp.src(src.images)
    .pipe($.changed(DEST + '/images'))
    .pipe($.imagemin({
      progressive: true,
      interlaced: true
    }))
    .pipe(gulp.dest(DEST + '/images'))
    .pipe($.size({title: 'images'}));
});

// HTML pages
gulp.task('pages', function() {
  src.pages = ['src/pages/**/*.js', 'src/pages/index.html', 'src/pages/404.html'];

  return gulp.src(src.pages)
    .pipe($.changed(DEST, {extension: '.html'}))
    .pipe($.replace('UA-XXXXX-X', GOOGLE_ANALYTICS_ID))
    .pipe($.if(!RELEASE, $.replace('.min.js', '.js')))
    .pipe($.if(RELEASE, $.htmlmin({
      removeComments: true,
      collapseWhitespace: true,
      minifyJS: true
    }), $.jsbeautifier()))
    .pipe(gulp.dest(DEST))
    .pipe($.size({title: 'pages'}));
});

// CSS style sheets
gulp.task('styles', function() {
  src.styles = 'src/styles/**/*.{css,less}';
  return gulp.src('src/styles/app.less')
    .pipe($.plumber())
    .pipe($.less({
      sourceMap: !RELEASE,
      sourceMapBasepath: __dirname
    }))
    .on('error', console.error.bind(console))
    .pipe($.autoprefixer({browsers: AUTOPREFIXER_BROWSERS}))
    .pipe($.if(RELEASE, $.minifyCss()))
    .pipe(gulp.dest(DEST + '/css'))
    .pipe($.size({title: 'styles'}));
});

// Bundle
gulp.task('bundle', function(cb) {
  var options = require('./config/webpack.js')(RELEASE,watch);
  gulp.src('./src/app.js')
    .pipe($.webpack(options))
    .pipe(gulp.dest('./build/'));
  cb(null);
});

// Build the app from source code
gulp.task('build', ['clean'], function(cb) {
  runSequence(['vendor', 'assets', 'images', 'styles', 'bundle'], cb);
});

// Launch a lightweight HTTP Server
gulp.task('serve', function(cb) {

  watch = true;

  runSequence('build', function() {
    browserSync({
      notify: false,
      // Customize the BrowserSync console logging prefix
      logPrefix: 'MSK',
      // Run as an https by uncommenting 'https: true'
      // Note: this uses an unsigned certificate which on first access
      //       will present a certificate warning in the browser.
      // https: true,
      server: {
        baseDir: DEST,
        // Allow web page requests without .html file extension in URLs
        middleware: function(req, res, cb) {
          var uri = url.parse(req.url);
          if (uri.pathname.length > 1 &&
            path.extname(uri.pathname) === '' &&
            fs.existsSync(DEST + uri.pathname + '.html')) {
            req.url = uri.pathname + '.html' + (uri.search || '');
          }
          cb();
        }
      }
    });

    gulp.watch(src.vendor, ['vendor']);
    gulp.watch(src.assets, ['assets']);
    gulp.watch(src.images, ['images']);
    gulp.watch(src.pages, ['pages']);
    gulp.watch(src.styles, ['styles']);
    gulp.watch(DEST + '/**/*.*', function(file) {
      browserSync.reload(path.relative(__dirname, file.path));
    });
    cb();
  });
});

// run jest tests
// gulp.task('jest', function () {
//     return gulp.src('src/**/__tests__').pipe($.jest({
//         unmockedModulePathPatterns: [
//         ],
//         testDirectoryName: "src",
//         testPathIgnorePatterns: [
//             "node_modules",
//             "spec/support"
//         ],
//         moduleFileExtensions: [
//             "js",
//             "json",
//             "msx"
//         ]
//     }));
// });

var jest = require('jest-cli');
var chalk = require('chalk');
gulp.task('jest', function (callback) {
  var onComplete = function (result) {
    // if (result) {
    // } else {
    //   console.log(chalk.bgYellow('!!! Jest tests failed! You should fix them soon. !!!'));
    // }
    callback();
  }
  jest.runCLI({}, __dirname, onComplete);
});

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

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

// Deploy to GitHub Pages
gulp.task('deploy', function() {

  // Remove temp folder
  if (argv.clean) {
    var os = require('os');
    var path = require('path');
    var repoPath = path.join(os.tmpdir(), 'tmpRepo');
    $.util.log('Delete ' + $.util.colors.magenta(repoPath));
    del.sync(repoPath, {force: true});
  }

  return gulp.src(DEST + '/**/*')
    .pipe($.if('**/robots.txt', !argv.production ? $.replace('Disallow:', 'Disallow: /') : $.util.noop()))
    .pipe($.ghPages({
      remoteUrl: 'https://github.com/{name}/{name}.github.io.git',
      branch: 'master'
    }));
});

// Run PageSpeed Insights
// Update `url` below to the public URL for your site
gulp.task('pagespeed', pagespeed.bind(null, {
  // By default, we use the PageSpeed Insights
  // free (no API key) tier. You can use a Google
  // Developer API key if you have one. See
  // http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
  url: 'https://example.com',
  strategy: 'mobile'
}));
<|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/28');
require('./tasks/netdna');
require('./tasks/server');
require('./tasks/templates');

/*gulp.task('watch', function() {
    return gulp.watch(Config.paths.sass, ['html:sass']);
});*/

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:compile'], function(done){
  $.runSequence('templates:create', ['lint:run', 'html:compile', 'images:compile', 'images:svg', 'html:fonts', 'swagger:copy', 'extras'], done);
});

gulp.task('server', ['html:sass', 'swagger:compile', '28:login'], function(done){
  $.runSequence('server:dev', done);
});

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

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

gulp.task('setup', ['config:load'], function(done){
    $.runSequence('build', [ 's3:setup', '28:setup' ], 'server:dist', /*'tests:unit', */'tests:e2e', 'server:stop', done);
});

gulp.task('teardown', ['config:load'], function(done){
    $.runSequence('28:login', '28:remove-project', 's3:teardown', done);
});
<commit_msg>:fire: 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/28');
require('./tasks/netdna');
require('./tasks/server');
require('./tasks/templates');

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:compile'], function(done){
  $.runSequence('templates:create', ['lint:run', 'html:compile', 'images:compile', 'images:svg', 'html:fonts', 'swagger:copy', 'extras'], done);
});

gulp.task('server', ['html:sass', 'swagger:compile', '28:login'], function(done){
  $.runSequence('server:dev', done);
});

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

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

gulp.task('setup', ['config:load'], function(done){
    $.runSequence('build', [ 's3:setup', '28:setup' ], 'server:dist', /*'tests:unit', */'tests:e2e', 'server:stop', done);
});

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


<commit_before>'use strict'

// Foundation for Apps
//
// We use this Gulpfile to assemble the documentation, run unit tests,
// and deploy changes to the live documentation and CDN.
//
// The tasks are grouped into these categories:
//   1. Libraries
//   2. Variables
//   3. Cleaning files
//   4. Copying files
//   5. Stylesheets
//   6. JavaScript
//   7. Testing
//   8. Server
//   9. Deployment
//  10. Default tasks

// 1. LIBRARIES
// - - - - - - - - - - - - - - -

var gulp           = require('gulp'),
    $              = require('gulp-load-plugins')(),
    rimraf         = require('rimraf'),
    runSequence    = require('run-sequence'),
    modRewrite     = require('connect-modrewrite'),
    routes         = require('./bin/gulp-dynamic-routing'),
    merge          = require('merge-stream'),
    settingsParser = require('settings-parser')
;

var addVersions = function() {
  var pkg = require('./package.json');
  return $.rename(function(path) {
    // Inject the version number into the filename
    var base = path.basename.split('.');
    if (base.length === 1) {
      base = base + '-' + pkg.version;
    }
    else {
      base = base.slice(0, -1).join('') + '-' + pkg.version + '.' + base[base.length - 1];
    }
    path.basename = base;
    path.dirname = '';
  })
}

// 2. VARIABLES
// - - - - - - - - - - - - - - -

var paths = {
  html: {
    base: [
      './docs/**/*.*',
      '!./docs/templates/**/*.*',
      '!./docs/assets/{scss,js}/**/*.*'
    ],
    templates: [
      './docs/templates/**/*.html'
    ],
    partials: [
      'js/angular/components/**/*.html'
    ]
  },
  sass: {
    loadPaths: [
      'scss',
      'docs/assets/scss'
    ],
    testPaths: [
      'scss',
      'docs/assets/scss',
      'bower_components/bootcamp/dist'
    ]
  },
  javascript: {
    foundation: [
      'js/vendor/**/*.js',
      'js/angular/**/*.js',
      '!js/angular/app.js'
    ],
    libs: [
      'bower_components/fastclick/lib/fastclick.js',
      'bower_components/viewport-units-buggyfill/viewport-units-buggyfill.js',
      'bower_components/tether/tether.js',
      'bower_components/angular/angular.js',
      'bower_components/angular-animate/angular-animate.js',
      'bower_components/angular-ui-router/release/angular-ui-router.js',
      'bower_components/hammerjs/hammer.js'
    ],
    docs: [
      'bower_components/marked/lib/marked.js',
      'bower_components/angular-highlightjs/angular-highlightjs.js',
      'bower_components/highlightjs/highlight.pack.js',
      'bower_components/allmighty-autocomplete/script/autocomplete.js',
      'docs/assets/js/app.js'
    ]
  }
}

// 3. CLEANIN' FILES
// - - - - - - - - - - - - - - -

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

// Clean the partials directory
gulp.task('clean:partials', function(cb) {
  rimraf('./build/partials', cb);
});

// Clean the dist directory
gulp.task('clean:dist', function(cb) {
  rimraf('./dist', cb);
});

// 4. COPYING FILES
// - - - - - - - - - - - - - - -

// Copy static files (but not the Angular templates, Sass, or JS)
gulp.task('copy', function() {
  gulp.src(paths.html.base, {
    base: './docs/'
  })
    .pipe(gulp.dest('build'));

  return gulp.src('./iconic/**/*')
    .pipe(gulp.dest('build/assets/img/iconic/'));
});

// Copy page templates and generate routes
gulp.task('copy:templates', ['javascript'], function() {
  var config = [];

  return gulp.src(paths.html.templates)
    .pipe(routes({
      path: 'build/assets/js/routes.js',
      root: 'docs'
    }))
    .pipe(gulp.dest('./build/templates'))
  ;
});

// Copy Foundation directive partials
gulp.task('copy:partials', ['clean:partials'], function(cb) {
  gulp.src(paths.html.partials)
    .pipe($.ngHtml2js({
      prefix: 'components/',
      moduleName: 'foundation',
      declareModule: false
    }))
    .pipe($.concat('templates.js'))
    .pipe(gulp.dest('./build/assets/js'));

  gulp.src('./docs/partials/**/*.html')
    .pipe(gulp.dest('./build/partials/'));

  cb();
});

// 5. STYLESHEETS
// - - - - - - - - - - - - - - -

// Inject styles for docs-specific libraries
gulp.task('css', ['sass'], function() {
  var dirs = [
    'bower_components/allmighty-autocomplete/style/autocomplete.css',
    'build/assets/css/app.css'
  ];
  return gulp.src(dirs)
    .pipe($.concat('app.css'))
    .pipe(gulp.dest('build/assets/css'))
  ;
});

// Compile stylesheets with Ruby Sass
gulp.task('sass', function() {
  var filter = $.filter(['*.css']);

  return $.rubySass('docs/assets/scss/', {
      loadPath: paths.sass.loadPaths,
      style: 'nested',
      bundleExec: true
    })
    .on('error', function(err) {
      console.log(err.message);
    })
    .pipe(filter)
      .pipe($.autoprefixer({
        browsers: ['last 2 versions', 'ie 10']
      }))
    .pipe(filter.restore())
    .pipe(gulp.dest('./build/assets/css/'));
});

// Compile stylesheets with node-sass
gulp.task('sass:node', function() {
  return gulp.src('docs/assets/scss/app.scss')
    .pipe($.sass({
      includePaths: paths.sass.loadPaths,
      outputStyle: 'nested',
      errLogToConsole: true
    }))
    .pipe($.autoprefixer({
      browsers: ['last 2 versions', 'ie 10']
    }))
    .pipe($.concat('app_node.css'))
    .pipe(gulp.dest('./build/assets/css/'));
});

// Generate Sass settings file
gulp.task('sass:settings', function() {
  settingsParser([
    'scss/_includes.scss',
    'scss/_global.scss',
    'scss/helpers/_breakpoints.scss',
    'scss/components/_typography.scss',
    'scss/components/_grid.scss',
    'scss/components/_button.scss',
    'scss/components/*.scss'
  ], {
    title: 'Foundation for Apps Settings'.toUpperCase(),
    partialsPath: 'docs/partials/scss',
    settingsPath: 'scss'
  });
});

// 6. JAVASCRIPT
// - - - - - - - - - - - - - - -

// Compile Foundation JavaScript
gulp.task('javascript', function() {
  var dirs = paths.javascript.libs.concat(
    paths.javascript.foundation,
    paths.javascript.docs
  );
  return gulp.src(dirs)
    .pipe($.uglify({
      beautify: true,
      mangle: false
    }).on('error', function(e) {
      console.log(e);
    }))
    .pipe($.concat('app.js'))
    .pipe(gulp.dest('./build/assets/js/'))
  ;
});

// 7. SERVER
// - - - - - - - - - - - - - - -

gulp.task('server:start', function() {
  $.connect.server({
    root: './build',
    middleware: function() {
      return [
        modRewrite(['^[^\\.]*$ /index.html [L]'])
      ];
    },
  });
});

// 8. TESTING
// - - - - - - - - - - - - - - -

gulp.task('test:karma', ['build', 'sass:node'], function() {
  var testFiles = [
    'build/assets/js/foundation.js',
    'build/assets/js/dependencies.js',
    'build/assets/js/app.js',
    'bower_components/angular-mocks/angular-mocks.js',
    'bower_components/jsdiff/diff.js',
    'build/assets/css/app.css',
    'build/assets/css/app_node.css',
    'tests/unit/common/*Spec.js'
  ];

  return gulp.src(testFiles)
    .pipe($.karma({
      configFile: 'karma.conf.js',
      action: 'run'
    }))
    .on('error', function(err) {
      throw err;
    })
  ;

});

gulp.task('test:sass', function() {
  return $.rubySass('./tests/unit/scss/tests.scss', {
    loadPath: paths.sass.testPaths,
    style: 'nested',
    bundleExec: true
  })
    .on('data', function(data) {
      console.log(data.contents.toString());
    });
});

gulp.task('test', ['test:karma', 'test:sass'], function() {
  console.log('Tests finished.');
});

gulp.task('compile-motion', ['clean', 'sass', 'javascript'], function() {
  gulp.src('./tests/motion/index.html')
    .pipe(gulp.dest('./build'));
  gulp.src('./tests/motion/templates/**/*.html')
    .pipe(routes({
      path: 'build/assets/js/routes.js',
      root: 'tests/motion'
    }))
    .pipe(gulp.dest('./build/templates'));
});

gulp.task('test:motion', ['server:start', 'compile-motion'], function() {
  gulp.watch(['js/**/*', 'tests/motion/**/*'], ['compile-motion']);
});

// 9. DEPLOYMENT
// - - - - - - - - - - - - - - -

// Deploy distribution files
gulp.task('deploy:dist', ['clean:dist'], function(cb) {
  var filter = $.filter(['*.css']);

  var css = $.rubySass('scss/', {
      loadPath: ['scss'],
      style: 'nested',
      bundleExec: true
    })
    .pipe(filter)
      .pipe($.autoprefixer({
        browsers: ['last 2 versions', 'ie 10']
      }))
    .pipe(filter.restore())
    .pipe($.rename('foundation-apps.css'))
    .pipe(gulp.dest('./dist/css'))
    .pipe($.minifyCss())
    .pipe($.rename('foundation-apps.min.css'))
    .pipe(gulp.dest('./dist/css'));

  var js = gulp.src(paths.javascript.foundation)
    .pipe($.concat('foundation-apps.js'))
    .pipe(gulp.dest('./dist/js'))
    .pipe($.uglify())
    .pipe($.rename('foundation-apps.min.js'))
    .pipe(gulp.dest('./dist/js'));

  var partials = gulp.src(paths.html.partials)
    .pipe($.ngHtml2js({
      prefix: 'components/',
      moduleName: 'foundation',
      declareModule: false
    }))
    .pipe($.concat('foundation-apps-templates.js'))
    .pipe(gulp.dest('./dist/js'))
    .pipe($.uglify())
    .pipe($.rename('foundation-apps-templates.min.js'))
    .pipe(gulp.dest('./dist/js'))

  cb();
});

// Deploy documentation
gulp.task('deploy:docs', ['build'], function() {
  return gulp.src('build/**')
    .pipe($.prompt.confirm("Make sure everything looks good before you deploy."))
    .pipe($.rsync({
      root: 'build',
      hostname: 'deployer@72.32.134.77',
      destination: '/home/deployer/sites/foundation-apps/current'
    }));
});

// Deploy to CDN
gulp.task('deploy:cdn', ['deploy:dist'], function() {
  return gulp.src('./dist/**/*', {base:'./dist/'})
    .pipe($.filter(['**/*.css', '**/*.js']))
    .pipe(addVersions())
    .pipe($.rsync({
      hostname: 'deployer@72.32.134.77',
      destination: '/home/deployer/sites/foundation-apps-cdn/current',
      relative: false
    }));
});

// 10. NOW BRING IT TOGETHER
// - - - - - - - - - - - - - - -

// Build the documentation once
gulp.task('build', function(cb) {
  runSequence('clean', ['copy', 'copy:partials', 'css', 'javascript', 'copy:templates'], function() {
    cb();
  });
});

// Build the documentation, start a test server, and re-compile when files change
gulp.task('default', ['build', 'server:start'], function() {

  // Watch static files
  gulp.watch(paths.html.base, ['copy']);

  // Watch Angular templates
  gulp.watch(paths.html.templates, ['copy:templates']);

  // Watch Angular partials
  gulp.watch(paths.html.partials, ['copy:partials']);

  // Watch Sass
  gulp.watch(['./docs/assets/scss/**/*', './scss/**/*'], ['css']);

  // Watch JavaScript
  gulp.watch(paths.javascript.foundation.concat(paths.javascript.docs), ['javascript']);
});
<commit_msg>Uglify templates file generated for docs<commit_after>'use strict'

// Foundation for Apps
//
// We use this Gulpfile to assemble the documentation, run unit tests,
// and deploy changes to the live documentation and CDN.
//
// The tasks are grouped into these categories:
//   1. Libraries
//   2. Variables
//   3. Cleaning files
//   4. Copying files
//   5. Stylesheets
//   6. JavaScript
//   7. Testing
//   8. Server
//   9. Deployment
//  10. Default tasks

// 1. LIBRARIES
// - - - - - - - - - - - - - - -

var gulp           = require('gulp'),
    $              = require('gulp-load-plugins')(),
    rimraf         = require('rimraf'),
    runSequence    = require('run-sequence'),
    modRewrite     = require('connect-modrewrite'),
    routes         = require('./bin/gulp-dynamic-routing'),
    merge          = require('merge-stream'),
    settingsParser = require('settings-parser')
;

var addVersions = function() {
  var pkg = require('./package.json');
  return $.rename(function(path) {
    // Inject the version number into the filename
    var base = path.basename.split('.');
    if (base.length === 1) {
      base = base + '-' + pkg.version;
    }
    else {
      base = base.slice(0, -1).join('') + '-' + pkg.version + '.' + base[base.length - 1];
    }
    path.basename = base;
    path.dirname = '';
  })
}

// 2. VARIABLES
// - - - - - - - - - - - - - - -

var paths = {
  html: {
    base: [
      './docs/**/*.*',
      '!./docs/templates/**/*.*',
      '!./docs/assets/{scss,js}/**/*.*'
    ],
    templates: [
      './docs/templates/**/*.html'
    ],
    partials: [
      'js/angular/components/**/*.html'
    ]
  },
  sass: {
    loadPaths: [
      'scss',
      'docs/assets/scss'
    ],
    testPaths: [
      'scss',
      'docs/assets/scss',
      'bower_components/bootcamp/dist'
    ]
  },
  javascript: {
    foundation: [
      'js/vendor/**/*.js',
      'js/angular/**/*.js',
      '!js/angular/app.js'
    ],
    libs: [
      'bower_components/fastclick/lib/fastclick.js',
      'bower_components/viewport-units-buggyfill/viewport-units-buggyfill.js',
      'bower_components/tether/tether.js',
      'bower_components/angular/angular.js',
      'bower_components/angular-animate/angular-animate.js',
      'bower_components/angular-ui-router/release/angular-ui-router.js',
      'bower_components/hammerjs/hammer.js'
    ],
    docs: [
      'bower_components/marked/lib/marked.js',
      'bower_components/angular-highlightjs/angular-highlightjs.js',
      'bower_components/highlightjs/highlight.pack.js',
      'bower_components/allmighty-autocomplete/script/autocomplete.js',
      'docs/assets/js/app.js'
    ]
  }
}

// 3. CLEANIN' FILES
// - - - - - - - - - - - - - - -

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

// Clean the partials directory
gulp.task('clean:partials', function(cb) {
  rimraf('./build/partials', cb);
});

// Clean the dist directory
gulp.task('clean:dist', function(cb) {
  rimraf('./dist', cb);
});

// 4. COPYING FILES
// - - - - - - - - - - - - - - -

// Copy static files (but not the Angular templates, Sass, or JS)
gulp.task('copy', function() {
  gulp.src(paths.html.base, {
    base: './docs/'
  })
    .pipe(gulp.dest('build'));

  return gulp.src('./iconic/**/*')
    .pipe(gulp.dest('build/assets/img/iconic/'));
});

// Copy page templates and generate routes
gulp.task('copy:templates', ['javascript'], function() {
  var config = [];

  return gulp.src(paths.html.templates)
    .pipe(routes({
      path: 'build/assets/js/routes.js',
      root: 'docs'
    }))
    .pipe(gulp.dest('./build/templates'))
  ;
});

// Copy Foundation directive partials
gulp.task('copy:partials', ['clean:partials'], function(cb) {
  gulp.src(paths.html.partials)
    .pipe($.ngHtml2js({
      prefix: 'components/',
      moduleName: 'foundation',
      declareModule: false
    }))
    .pipe($.uglify())
    .pipe($.concat('templates.js'))
    .pipe(gulp.dest('./build/assets/js'));

  gulp.src('./docs/partials/**/*.html')
    .pipe(gulp.dest('./build/partials/'));

  cb();
});

// 5. STYLESHEETS
// - - - - - - - - - - - - - - -

// Inject styles for docs-specific libraries
gulp.task('css', ['sass'], function() {
  var dirs = [
    'bower_components/allmighty-autocomplete/style/autocomplete.css',
    'build/assets/css/app.css'
  ];
  return gulp.src(dirs)
    .pipe($.concat('app.css'))
    .pipe(gulp.dest('build/assets/css'))
  ;
});

// Compile stylesheets with Ruby Sass
gulp.task('sass', function() {
  var filter = $.filter(['*.css']);

  return $.rubySass('docs/assets/scss/', {
      loadPath: paths.sass.loadPaths,
      style: 'nested',
      bundleExec: true
    })
    .on('error', function(err) {
      console.log(err.message);
    })
    .pipe(filter)
      .pipe($.autoprefixer({
        browsers: ['last 2 versions', 'ie 10']
      }))
    .pipe(filter.restore())
    .pipe(gulp.dest('./build/assets/css/'));
});

// Compile stylesheets with node-sass
gulp.task('sass:node', function() {
  return gulp.src('docs/assets/scss/app.scss')
    .pipe($.sass({
      includePaths: paths.sass.loadPaths,
      outputStyle: 'nested',
      errLogToConsole: true
    }))
    .pipe($.autoprefixer({
      browsers: ['last 2 versions', 'ie 10']
    }))
    .pipe($.concat('app_node.css'))
    .pipe(gulp.dest('./build/assets/css/'));
});

// Generate Sass settings file
gulp.task('sass:settings', function() {
  settingsParser([
    'scss/_includes.scss',
    'scss/_global.scss',
    'scss/helpers/_breakpoints.scss',
    'scss/components/_typography.scss',
    'scss/components/_grid.scss',
    'scss/components/_button.scss',
    'scss/components/*.scss'
  ], {
    title: 'Foundation for Apps Settings'.toUpperCase(),
    partialsPath: 'docs/partials/scss',
    settingsPath: 'scss'
  });
});

// 6. JAVASCRIPT
// - - - - - - - - - - - - - - -

// Compile Foundation JavaScript
gulp.task('javascript', function() {
  var dirs = paths.javascript.libs.concat(
    paths.javascript.foundation,
    paths.javascript.docs
  );
  return gulp.src(dirs)
    .pipe($.uglify({
      beautify: true,
      mangle: false
    }).on('error', function(e) {
      console.log(e);
    }))
    .pipe($.concat('app.js'))
    .pipe(gulp.dest('./build/assets/js/'))
  ;
});

// 7. SERVER
// - - - - - - - - - - - - - - -

gulp.task('server:start', function() {
  $.connect.server({
    root: './build',
    middleware: function() {
      return [
        modRewrite(['^[^\\.]*$ /index.html [L]'])
      ];
    },
  });
});

// 8. TESTING
// - - - - - - - - - - - - - - -

gulp.task('test:karma', ['build', 'sass:node'], function() {
  var testFiles = [
    'build/assets/js/foundation.js',
    'build/assets/js/dependencies.js',
    'build/assets/js/app.js',
    'bower_components/angular-mocks/angular-mocks.js',
    'bower_components/jsdiff/diff.js',
    'build/assets/css/app.css',
    'build/assets/css/app_node.css',
    'tests/unit/common/*Spec.js'
  ];

  return gulp.src(testFiles)
    .pipe($.karma({
      configFile: 'karma.conf.js',
      action: 'run'
    }))
    .on('error', function(err) {
      throw err;
    })
  ;

});

gulp.task('test:sass', function() {
  return $.rubySass('./tests/unit/scss/tests.scss', {
    loadPath: paths.sass.testPaths,
    style: 'nested',
    bundleExec: true
  })
    .on('data', function(data) {
      console.log(data.contents.toString());
    });
});

gulp.task('test', ['test:karma', 'test:sass'], function() {
  console.log('Tests finished.');
});

gulp.task('compile-motion', ['clean', 'sass', 'javascript'], function() {
  gulp.src('./tests/motion/index.html')
    .pipe(gulp.dest('./build'));
  gulp.src('./tests/motion/templates/**/*.html')
    .pipe(routes({
      path: 'build/assets/js/routes.js',
      root: 'tests/motion'
    }))
    .pipe(gulp.dest('./build/templates'));
});

gulp.task('test:motion', ['server:start', 'compile-motion'], function() {
  gulp.watch(['js/**/*', 'tests/motion/**/*'], ['compile-motion']);
});

// 9. DEPLOYMENT
// - - - - - - - - - - - - - - -

// Deploy distribution files
gulp.task('deploy:dist', ['clean:dist'], function(cb) {
  var filter = $.filter(['*.css']);

  var css = $.rubySass('scss/', {
      loadPath: ['scss'],
      style: 'nested',
      bundleExec: true
    })
    .pipe(filter)
      .pipe($.autoprefixer({
        browsers: ['last 2 versions', 'ie 10']
      }))
    .pipe(filter.restore())
    .pipe($.rename('foundation-apps.css'))
    .pipe(gulp.dest('./dist/css'))
    .pipe($.minifyCss())
    .pipe($.rename('foundation-apps.min.css'))
    .pipe(gulp.dest('./dist/css'));

  var js = gulp.src(paths.javascript.foundation)
    .pipe($.concat('foundation-apps.js'))
    .pipe(gulp.dest('./dist/js'))
    .pipe($.uglify())
    .pipe($.rename('foundation-apps.min.js'))
    .pipe(gulp.dest('./dist/js'));

  var partials = gulp.src(paths.html.partials)
    .pipe($.ngHtml2js({
      prefix: 'components/',
      moduleName: 'foundation',
      declareModule: false
    }))
    .pipe($.concat('foundation-apps-templates.js'))
    .pipe(gulp.dest('./dist/js'))
    .pipe($.uglify())
    .pipe($.rename('foundation-apps-templates.min.js'))
    .pipe(gulp.dest('./dist/js'))

  cb();
});

// Deploy documentation
gulp.task('deploy:docs', ['build'], function() {
  return gulp.src('build/**')
    .pipe($.prompt.confirm("Make sure everything looks good before you deploy."))
    .pipe($.rsync({
      root: 'build',
      hostname: 'deployer@72.32.134.77',
      destination: '/home/deployer/sites/foundation-apps/current'
    }));
});

// Deploy to CDN
gulp.task('deploy:cdn', ['deploy:dist'], function() {
  return gulp.src('./dist/**/*', {base:'./dist/'})
    .pipe($.filter(['**/*.css', '**/*.js']))
    .pipe(addVersions())
    .pipe($.rsync({
      hostname: 'deployer@72.32.134.77',
      destination: '/home/deployer/sites/foundation-apps-cdn/current',
      relative: false
    }));
});

// 10. NOW BRING IT TOGETHER
// - - - - - - - - - - - - - - -

// Build the documentation once
gulp.task('build', function(cb) {
  runSequence('clean', ['copy', 'copy:partials', 'css', 'javascript', 'copy:templates'], function() {
    cb();
  });
});

// Build the documentation, start a test server, and re-compile when files change
gulp.task('default', ['build', 'server:start'], function() {

  // Watch static files
  gulp.watch(paths.html.base, ['copy']);

  // Watch Angular templates
  gulp.watch(paths.html.templates, ['copy:templates']);

  // Watch Angular partials
  gulp.watch(paths.html.partials, ['copy:partials']);

  // Watch Sass
  gulp.watch(['./docs/assets/scss/**/*', './scss/**/*'], ['css']);

  // Watch JavaScript
  gulp.watch(paths.javascript.foundation.concat(paths.javascript.docs), ['javascript']);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var rimraf = require('rimraf');
var less = require('gulp-less');
var minifyCSS = require('gulp-clean-css');
var cssBase64 = require('gulp-css-base64');
var es = require('event-stream');
var rseq = require('run-sequence');
var zip = require('gulp-zip');
var rename = require('gulp-rename');
var shell = require('gulp-shell');
var jeditor = require("gulp-json-editor");
var peditor = require('gulp-plist');
var app = require('./package');

function pipe(src, transforms, dest) {
  if (typeof transforms === 'string') {
    dest = transforms;
    transforms = null;
  }

  var stream = gulp.src(src);
  transforms && transforms.forEach(function (transform) {
    stream = stream.pipe(transform);
  });

  if (dest) {
    stream = stream.pipe(gulp.dest(dest));
  }

  return stream;
}

gulp.task('styles', function () {
  return gulp.src('./src/less/style.less')
      .pipe(less())
      .pipe(cssBase64())
      .pipe(minifyCSS())
      .pipe(gulp.dest('./src/css'));
});

gulp.task('options', function () {
  return gulp.src('./src/less/options.less')
      .pipe(less())
      .pipe(cssBase64())
      .pipe(minifyCSS())
      .pipe(gulp.dest('./src/css'));
});

gulp.task('clean', function () {
  return rimraf.sync('./build');
});

gulp.task('chrome', function () {
  return es.merge(
      pipe('./src/js/**/*', './build/chrome/js'),
      pipe('./src/css/**/*', './build/chrome/css'),
      pipe('./src/icons/**/*', './build/chrome/icons'),
      pipe('./vendor/chrome/data/**/*', './build/chrome'),
      pipe('./vendor/chrome/manifest.json', [
        jeditor({
          'name': app.title,
          'version': app.version,
          'description': app.description,
          'homepage_url': app.homepage
        })
      ], './build/chrome/')
  );
});

gulp.task('opera', function () {
  return es.merge(
      pipe('./src/js/**/*', './build/opera/js'),
      pipe('./src/css/**/*', './build/opera/css'),
      pipe('./src/icons/**/*', './build/opera/icons'),
      pipe('./vendor/opera/data/**/*', './build/opera'),
      pipe('./vendor/opera/manifest.json', [
        jeditor({
          'name': app.title,
          'version': app.version,
          'description': app.description,
          'homepage_url': app.homepage
        })
      ], './build/opera/')
  );
});

gulp.task('firefox', function () {
  return es.merge(
      pipe('./src/js/**/*', './build/firefox/data/js'),
      pipe(['./src/css/**/*', '!./src/css/options.css'], './build/firefox/data/css'),
      pipe('./src/icons/**/*', './build/firefox/data/icons'),
      pipe('./vendor/firefox/data/**/*', './build/firefox/data'),
      pipe('./vendor/firefox/package.json', [
        jeditor({
          'title': app.title,
          'version': app.version,
          'description': app.description,
          'homepage': app.homepage
        })
      ], './build/firefox/')
  );
});

gulp.task('safari', function () {
  return es.merge(
      pipe('./src/js/**/*', './build/safari/handsometrello.safariextension/js'),
      pipe(['./src/css/**/*', '!./src/css/options.css'], './build/safari/handsometrello.safariextension/css'),
      pipe('./src/icons/**/*', './build/safari/handsometrello.safariextension/icons'),
      pipe('./vendor/safari/data/**/*', './build/safari/handsometrello.safariextension'),
      pipe('./vendor/safari/Info.plist', [
        peditor({
          CFBundleDisplayName: app.title,
          CFBundleShortVersionString: app.version,
          Description: app.description,
          Website: app.homepage
        })
      ], './build/safari/handsometrello.safariextension')
  );
});

gulp.task('chrome-dist', function () {
  gulp.src('./build/chrome/**/*')
      .pipe(zip('handsome-trello-chrome-extension-' + app.version + '.zip'))
      .pipe(gulp.dest('./dist/chrome'))
      .pipe(rename('handsome-trello-chrome-extension-latest.zip'))
      .pipe(gulp.dest('./dist/chrome'));
});

gulp.task('opera-dist', function () {
  gulp.src('./build/opera/**/*')
      .pipe(zip('handsome-trello-opera-extension-' + app.version + '.zip'))
      .pipe(gulp.dest('./dist/opera'))
      .pipe(rename('handsome-trello-opera-extension-latest.zip'))
      .pipe(gulp.dest('./dist/opera'));
});

gulp.task('firefox-dist', shell.task([
  'mkdir -p dist/firefox',
  'cd ./build/firefox && ../../node_modules/.bin/jpm xpi > /dev/null',
  'mv ./build/firefox/*-' + app.version + '.xpi ./dist/firefox/handsome-trello-firefox-extension-' + app.version + '.xpi',
  'cp ./dist/firefox/handsome-trello-firefox-extension-' + app.version + '.xpi ./dist/firefox/handsome-trello-firefox-extension-latest.xpi'
]));

gulp.task('safari-dist', shell.task([
  'mkdir -p dist/safari',
  'cd ./build/safari && ../../node_modules/.bin/xarjs create ../../dist/safari/handsome-trello-safari-extension-' + app.version + '.safariextz --cert ../../vendor/safari/certs/cert.pem --cert ../../vendor/safari/certs/apple-intermediate.pem --cert ../../vendor/safari/certs/apple-root.pem --private-key ../../vendor/safari/certs/privatekey.pem handsometrello.safariextension',
  'cp ./dist/safari/handsome-trello-safari-extension-' + app.version + '.safariextz ./dist/safari/handsome-trello-safari-extension-latest.safariextz'
]));

gulp.task('firefox-run', shell.task([
  'cd ./build/firefox && ../../node_modules/.bin/jpm run'
]));

gulp.task('dist', function (cb) {
  return rseq('clean', ['styles', 'options'], ['chrome', 'opera', 'firefox', 'safari'], ['chrome-dist', 'opera-dist', 'firefox-dist', 'safari-dist'], cb);
});

gulp.task('watch', function () {
  rseq('default');

  gulp.watch([
    './src/less/**/*',
    './src/fonts/**/*'
  ], ['styles', 'options'], ['chrome', 'opera', 'firefox', 'safari']);

  gulp.watch([
    './src/js/**/*',
    './src/css/**/*',
    './vendor/**/*',
    './package.json'
  ], ['default']);
});

gulp.task('run', function (cb) {
  return rseq('clean', ['styles', 'options'], 'firefox', 'firefox-run', cb);
});

gulp.task('addons', shell.task([
  'cp -R ./dist ../addons'
]));

gulp.task('default', function (cb) {
  return rseq('clean', ['styles', 'options'], ['chrome', 'opera', 'firefox', 'safari'], cb);
});
<commit_msg>Fix watch tasks order (starting crash)<commit_after>var gulp = require('gulp');
var rimraf = require('rimraf');
var less = require('gulp-less');
var minifyCSS = require('gulp-clean-css');
var cssBase64 = require('gulp-css-base64');
var es = require('event-stream');
var rseq = require('run-sequence');
var zip = require('gulp-zip');
var rename = require('gulp-rename');
var shell = require('gulp-shell');
var jeditor = require("gulp-json-editor");
var peditor = require('gulp-plist');
var app = require('./package');

function pipe(src, transforms, dest) {
  if (typeof transforms === 'string') {
    dest = transforms;
    transforms = null;
  }

  var stream = gulp.src(src);
  transforms && transforms.forEach(function (transform) {
    stream = stream.pipe(transform);
  });

  if (dest) {
    stream = stream.pipe(gulp.dest(dest));
  }

  return stream;
}

gulp.task('styles', function () {
  return gulp.src('./src/less/style.less')
      .pipe(less())
      .pipe(cssBase64())
      .pipe(minifyCSS())
      .pipe(gulp.dest('./src/css'));
});

gulp.task('options', function () {
  return gulp.src('./src/less/options.less')
      .pipe(less())
      .pipe(cssBase64())
      .pipe(minifyCSS())
      .pipe(gulp.dest('./src/css'));
});

gulp.task('clean', function () {
  return rimraf.sync('./build');
});

gulp.task('chrome', function () {
  return es.merge(
      pipe('./src/js/**/*', './build/chrome/js'),
      pipe('./src/css/**/*', './build/chrome/css'),
      pipe('./src/icons/**/*', './build/chrome/icons'),
      pipe('./vendor/chrome/data/**/*', './build/chrome'),
      pipe('./vendor/chrome/manifest.json', [
        jeditor({
          'name': app.title,
          'version': app.version,
          'description': app.description,
          'homepage_url': app.homepage
        })
      ], './build/chrome/')
  );
});

gulp.task('opera', function () {
  return es.merge(
      pipe('./src/js/**/*', './build/opera/js'),
      pipe('./src/css/**/*', './build/opera/css'),
      pipe('./src/icons/**/*', './build/opera/icons'),
      pipe('./vendor/opera/data/**/*', './build/opera'),
      pipe('./vendor/opera/manifest.json', [
        jeditor({
          'name': app.title,
          'version': app.version,
          'description': app.description,
          'homepage_url': app.homepage
        })
      ], './build/opera/')
  );
});

gulp.task('firefox', function () {
  return es.merge(
      pipe('./src/js/**/*', './build/firefox/data/js'),
      pipe(['./src/css/**/*', '!./src/css/options.css'], './build/firefox/data/css'),
      pipe('./src/icons/**/*', './build/firefox/data/icons'),
      pipe('./vendor/firefox/data/**/*', './build/firefox/data'),
      pipe('./vendor/firefox/package.json', [
        jeditor({
          'title': app.title,
          'version': app.version,
          'description': app.description,
          'homepage': app.homepage
        })
      ], './build/firefox/')
  );
});

gulp.task('safari', function () {
  return es.merge(
      pipe('./src/js/**/*', './build/safari/handsometrello.safariextension/js'),
      pipe(['./src/css/**/*', '!./src/css/options.css'], './build/safari/handsometrello.safariextension/css'),
      pipe('./src/icons/**/*', './build/safari/handsometrello.safariextension/icons'),
      pipe('./vendor/safari/data/**/*', './build/safari/handsometrello.safariextension'),
      pipe('./vendor/safari/Info.plist', [
        peditor({
          CFBundleDisplayName: app.title,
          CFBundleShortVersionString: app.version,
          Description: app.description,
          Website: app.homepage
        })
      ], './build/safari/handsometrello.safariextension')
  );
});

gulp.task('chrome-dist', function () {
  gulp.src('./build/chrome/**/*')
      .pipe(zip('handsome-trello-chrome-extension-' + app.version + '.zip'))
      .pipe(gulp.dest('./dist/chrome'))
      .pipe(rename('handsome-trello-chrome-extension-latest.zip'))
      .pipe(gulp.dest('./dist/chrome'));
});

gulp.task('opera-dist', function () {
  gulp.src('./build/opera/**/*')
      .pipe(zip('handsome-trello-opera-extension-' + app.version + '.zip'))
      .pipe(gulp.dest('./dist/opera'))
      .pipe(rename('handsome-trello-opera-extension-latest.zip'))
      .pipe(gulp.dest('./dist/opera'));
});

gulp.task('firefox-dist', shell.task([
  'mkdir -p dist/firefox',
  'cd ./build/firefox && ../../node_modules/.bin/jpm xpi > /dev/null',
  'mv ./build/firefox/*-' + app.version + '.xpi ./dist/firefox/handsome-trello-firefox-extension-' + app.version + '.xpi',
  'cp ./dist/firefox/handsome-trello-firefox-extension-' + app.version + '.xpi ./dist/firefox/handsome-trello-firefox-extension-latest.xpi'
]));

gulp.task('safari-dist', shell.task([
  'mkdir -p dist/safari',
  'cd ./build/safari && ../../node_modules/.bin/xarjs create ../../dist/safari/handsome-trello-safari-extension-' + app.version + '.safariextz --cert ../../vendor/safari/certs/cert.pem --cert ../../vendor/safari/certs/apple-intermediate.pem --cert ../../vendor/safari/certs/apple-root.pem --private-key ../../vendor/safari/certs/privatekey.pem handsometrello.safariextension',
  'cp ./dist/safari/handsome-trello-safari-extension-' + app.version + '.safariextz ./dist/safari/handsome-trello-safari-extension-latest.safariextz'
]));

gulp.task('firefox-run', shell.task([
  'cd ./build/firefox && ../../node_modules/.bin/jpm run'
]));

gulp.task('dist', function (cb) {
  return rseq('clean', ['styles', 'options'], ['chrome', 'opera', 'firefox', 'safari'], ['chrome-dist', 'opera-dist', 'firefox-dist', 'safari-dist'], cb);
});

gulp.task('watch', function () {
  rseq('default', function () {
    gulp.watch([
      './src/less/**/*',
      './src/fonts/**/*'
    ], ['styles', 'options'], ['chrome', 'opera', 'firefox', 'safari']);

    gulp.watch([
      './src/js/**/*',
      './src/css/**/*',
      './vendor/**/*',
      './package.json'
    ], ['default']);
  });
});

gulp.task('run', function (cb) {
  return rseq('clean', ['styles', 'options'], 'firefox', 'firefox-run', cb);
});

gulp.task('addons', shell.task([
  'cp -R ./dist ../addons'
]));

gulp.task('default', function (cb) {
  return rseq('clean', ['styles', 'options'], ['chrome', 'opera', 'firefox', 'safari'], cb);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var shell = require('gulp-shell');
var browserSync = require('browser-sync').create();

// Task for building blog when something changed:
gulp.task('build', shell.task(['bundle exec jekyll build --watch --config _config_dev.yml']));
// Or if you don't use bundle:
// gulp.task('build', shell.task(['jekyll build --watch']));

// Task for serving blog with Browsersync
gulp.task('serve', function () {
    browserSync.init({server: {baseDir: '_site/'}});
    // Reloads page when some of the already built files changed:
    gulp.watch('_site/**/*.*').on('change', browserSync.reload);
});

gulp.task('default', ['build', 'serve']);<commit_msg>Force jekyll auto renegerate<commit_after>var gulp = require('gulp');
var shell = require('gulp-shell');
var browserSync = require('browser-sync').create();

// Task for building blog when something changed:
gulp.task('build', shell.task(['bundle exec jekyll build --force_polling --watch --config _config_dev.yml']));
// Or if you don't use bundle:
// gulp.task('build', shell.task(['jekyll build --watch']));

// Task for serving blog with Browsersync
gulp.task('serve', function () {
    browserSync.init({server: {baseDir: '_site/'}});
    // Reloads page when some of the already built files changed:
    gulp.watch('_site/**/*.*').on('change', browserSync.reload);
});

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