<commit_before>/**
 * Gulp file for the timeline project.  This handles tasks like building,
 * linting, and other helpful development things.
 */
'use strict';

// Dependencies
var fs = require('fs');
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var plumber = require('gulp-plumber');
var replace = require('gulp-replace');
var util = require('gulp-util');
var header = require('gulp-header');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var less = require('gulp-less');
var recess = require('gulp-recess');
var cssminify = require('gulp-minify-css');
var autoprefixer = require('gulp-autoprefixer');
var webserver = require('gulp-webserver');
var mocha = require('gulp-mocha');

// Create banner to insert into files
var pkg = require('./package.json');
var banner = ['/**',
  ' * <%= pkg.name %> - <%= pkg.description %>',
  ' * @version v<%= pkg.version %>',
  ' * @link <%= pkg.homepage %>',
  ' * @license <%= pkg.license %>',
  ' */',
  ''].join('\n');

// Browser support (for autoprefixer).  This should be more defined
// for the project as a whole
var supportedBrowsers = ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1'];

// Plumber allows for better error handling and makes it so that
// gulp doesn't crash so hard.  Good for watching and linting tasks
var plumberHandler = function(error) {
  if (error) {
    util.beep();
  }
  else {
    this.emit('end');
  }
};

// Support JS is a task to look at the supporting JS, like this
// file
gulp.task('support-js', function() {
  return gulp.src(['gulpfile.js', 'tests/**/*.js'])
    .pipe(plumber(plumberHandler))
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(jshint.reporter('fail'))
    .pipe(jscs());
});

// Run tests
gulp.task('test', function() {
  return gulp.src('tests/**/*.js', { read: false })
    .pipe(plumber(plumberHandler))
    .pipe(mocha({
      ui: 'bdd',
      reporter: 'spec'
    }));
});

// Main JS task for timeline library.  Takes in files from src and outputs
// to dist.  Gets template and uses JSHint, JSCS, add header, minify
gulp.task('js', function() {
  gulp.src('src/**/*.js')
    .pipe(plumber(plumberHandler))
    .pipe(replace(
      'REPLACE-DEFAULT-TEMPLATE',
      fs.readFileSync('src/timeline.tpl.html', {
        encoding: 'utf-8'
      }).replace(/'/g, '\\\'').replace(/(\r\n|\n|\r|\s+)/g, ' ')
    ))
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(jshint.reporter('fail'))
    .pipe(jscs())
    .pipe(header(banner, { pkg: pkg }))
    .pipe(gulp.dest('dist'))
    .pipe(uglify())
    .pipe(header(banner, { pkg: pkg }))
    .pipe(rename({
      extname: '.min.js'
    }))
    .pipe(gulp.dest('dist'));
});

// Styles.  Recess linting, Convert LESS to CSS, minify
gulp.task('styles', function() {
  gulp.src('src/**/*.less')
    .pipe(plumber(plumberHandler))
    .pipe(recess({
      noOverqualifying: false
    }))
    .pipe(less())
    .pipe(recess.reporter({
      fail: true
    }))
    .pipe(autoprefixer({
      browsers: supportedBrowsers
    }))
    .pipe(header(banner, { pkg: pkg }))
    .pipe(gulp.dest('dist'))
    .pipe(cssminify())
    .pipe(header(banner, { pkg: pkg }))
    .pipe(rename({
      extname: '.min.css'
    }))
    .pipe(gulp.dest('dist'));
});

// Watch for files that need to be processed
gulp.task('watch', function() {
  gulp.watch(['gulpfile.js', 'tests/**/*.js'], ['support-js']);
  gulp.watch(['src/**/*.js', 'src/**/*.html'], ['js', 'test']);
  gulp.watch('src/**/*.less', ['styles']);
});

// Web server for conveinence
gulp.task('webserver', function() {
  gulp.src('./')
    .pipe(webserver({
      port: 8089,
      livereload: {
        enable: true,
        filter: function(file) {
          // Only watch dist and examples
          return (file.match(/dist|examples/)) ? true : false;
        }
      },
      directoryListing: true,
      open: true,
      fallback: 'index.html'
    }));
});

// Default task is a basic build
gulp.task('default', ['support-js', 'js', 'test', 'styles']);

// Combine webserver and watch tasks for a more complete server
gulp.task('server', ['default', 'watch', 'webserver']);
<commit_msg>Running tests when tests change.<commit_after>/**
 * Gulp file for the timeline project.  This handles tasks like building,
 * linting, and other helpful development things.
 */
'use strict';

// Dependencies
var fs = require('fs');
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var plumber = require('gulp-plumber');
var replace = require('gulp-replace');
var util = require('gulp-util');
var header = require('gulp-header');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var less = require('gulp-less');
var recess = require('gulp-recess');
var cssminify = require('gulp-minify-css');
var autoprefixer = require('gulp-autoprefixer');
var webserver = require('gulp-webserver');
var mocha = require('gulp-mocha');

// Create banner to insert into files
var pkg = require('./package.json');
var banner = ['/**',
  ' * <%= pkg.name %> - <%= pkg.description %>',
  ' * @version v<%= pkg.version %>',
  ' * @link <%= pkg.homepage %>',
  ' * @license <%= pkg.license %>',
  ' */',
  ''].join('\n');

// Browser support (for autoprefixer).  This should be more defined
// for the project as a whole
var supportedBrowsers = ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1'];

// Plumber allows for better error handling and makes it so that
// gulp doesn't crash so hard.  Good for watching and linting tasks
var plumberHandler = function(error) {
  if (error) {
    util.beep();
  }
  else {
    this.emit('end');
  }
};

// Support JS is a task to look at the supporting JS, like this
// file
gulp.task('support-js', function() {
  return gulp.src(['gulpfile.js', 'tests/**/*.js'])
    .pipe(plumber(plumberHandler))
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(jshint.reporter('fail'))
    .pipe(jscs());
});

// Run tests
gulp.task('test', function() {
  return gulp.src('tests/**/*.js', { read: false })
    .pipe(plumber(plumberHandler))
    .pipe(mocha({
      ui: 'bdd',
      reporter: 'spec'
    }));
});

// Main JS task for timeline library.  Takes in files from src and outputs
// to dist.  Gets template and uses JSHint, JSCS, add header, minify
gulp.task('js', function() {
  gulp.src('src/**/*.js')
    .pipe(plumber(plumberHandler))
    .pipe(replace(
      'REPLACE-DEFAULT-TEMPLATE',
      fs.readFileSync('src/timeline.tpl.html', {
        encoding: 'utf-8'
      }).replace(/'/g, '\\\'').replace(/(\r\n|\n|\r|\s+)/g, ' ')
    ))
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(jshint.reporter('fail'))
    .pipe(jscs())
    .pipe(header(banner, { pkg: pkg }))
    .pipe(gulp.dest('dist'))
    .pipe(uglify())
    .pipe(header(banner, { pkg: pkg }))
    .pipe(rename({
      extname: '.min.js'
    }))
    .pipe(gulp.dest('dist'));
});

// Styles.  Recess linting, Convert LESS to CSS, minify
gulp.task('styles', function() {
  gulp.src('src/**/*.less')
    .pipe(plumber(plumberHandler))
    .pipe(recess({
      noOverqualifying: false
    }))
    .pipe(less())
    .pipe(recess.reporter({
      fail: true
    }))
    .pipe(autoprefixer({
      browsers: supportedBrowsers
    }))
    .pipe(header(banner, { pkg: pkg }))
    .pipe(gulp.dest('dist'))
    .pipe(cssminify())
    .pipe(header(banner, { pkg: pkg }))
    .pipe(rename({
      extname: '.min.css'
    }))
    .pipe(gulp.dest('dist'));
});

// Watch for files that need to be processed
gulp.task('watch', function() {
  gulp.watch(['gulpfile.js', 'tests/**/*.js'], ['support-js']);
  gulp.watch(['src/**/*.js', 'src/**/*.html'], ['js', 'test']);
  gulp.watch(['tests/**/*.js'], ['test']);
  gulp.watch('src/**/*.less', ['styles']);
});

// Web server for conveinence
gulp.task('webserver', function() {
  gulp.src('./')
    .pipe(webserver({
      port: 8089,
      livereload: {
        enable: true,
        filter: function(file) {
          // Only watch dist and examples
          return (file.match(/dist|examples/)) ? true : false;
        }
      },
      directoryListing: true,
      open: true,
      fallback: 'index.html'
    }));
});

// Default task is a basic build
gulp.task('default', ['support-js', 'js', 'test', 'styles']);

// Combine webserver and watch tasks for a more complete server
gulp.task('server', ['default', 'watch', 'webserver']);
<|endoftext|>


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

	// Gulp
var gulp            = require('gulp'),
	plugins          = require('gulp-load-plugins')(),
	gulpif           = require('gulp-if'),

	// Utilities
	argv             = require('yargs').argv,
	zip              = require('gulp-zip'),
	sourcemaps       = require('gulp-sourcemaps'),
	runSeq           = require('run-sequence'),
	rename           = require('gulp-rename'),
	concat           = require('gulp-concat'),

	// Javascript
	uglify           = require('gulp-uglify'),
	jshint           = require('gulp-jshint'),

	// Templates
	handlebars       = require('gulp-compile-handlebars'),

	// CSS
	minifyCss        = require('gulp-minify-css'),
	autoprefixer     = require('autoprefixer-core'),
	sgc              = require('gulp-sass-generate-contents'),
	postcss          = require('gulp-postcss'),
	pixrem           = require('gulp-pixrem'),

	// Images
	imagemin         = require('gulp-imagemin'),
	pngquant         = require('imagemin-pngquant'),

	// Configuration
	config           = require('./_config/project.json'),
	templateDataJson = require('./_config/templateData.json'),
	templateHelpers  = require('./_config/templateHelpers.js')(),
	jshintConfig     = require('./_config/jshint.json'),
	creds            = require('./_config/creds.json'),
	itcss            = require('./_config/itcss'),
	destStyles       = config.src + '/' + config.dirs.styles;

/* ============================================================ *\
	SCRIPTS JS / lint, concat and minify scripts
\* ============================================================ */

gulp.task('scripts', function(){
	return gulp.src([config.src + '/' + config.dirs.scripts + '/**/*.js'])
		.pipe(gulpif(argv.prod, jshint(jshintConfig))) //Default only
		.pipe(concat('bundle.js'))
		.pipe(gulpif(argv.prod, uglify())) //Production only
		.pipe(gulp.dest(config.dest + '/' + config.dirs.scripts));
});

/* ============================================================ *\
	GENERATE SASS IMPORTS AND
\* ============================================================ */

gulp.task('sass-generate-contents', function () {
	return gulp.src(itcss())
	.pipe(sgc(destStyles + '/main.scss', creds))
	.pipe(gulp.dest(destStyles));
});

/* ============================================================ *\
	STYLES / SCSS
\* ============================================================ */

gulp.task('sass', function () {
	return gulp.src(destStyles + '/main.scss')
		.pipe(gulpif(!argv.prod, plugins.sourcemaps.init())) //Default only
		.pipe(plugins.sass({ errLogToConsole: true, includePaths: [config.dirs.components], outputStyle: 'compact' }))
		.pipe(postcss([autoprefixer({ browsers: ['> 5%', 'Android 3'] })]))
		.pipe(plugins.pixrem(config.pixelBase))
		.pipe(gulpif(!argv.prod, plugins.sourcemaps.write('.'))) //Default only
		.pipe(plugins.pixrem(config.pixelBase))
		.pipe(gulpif(argv.prod, minifyCss())) //Production only
		.pipe(gulp.dest(config.dest + '/' + config.dirs.styles));
});

/* ============================================================ *\
	IMAGES / minify images
\* ============================================================ */

gulp.task('imagemin', function () {
	return gulp.src(config.src + '/' + config.dirs.images + '/**/*')
		.pipe(gulpif(argv.prod, imagemin({
			progressive: true,
			svgoPlugins: [{removeViewBox: false}],
			use: [pngquant()]
		}))) //Production only
		.pipe(gulp.dest(config.dest + '/' + config.dirs.images));
});

/* ============================================================ *\
	MOVE / Copy files
\* ============================================================ */

gulp.task('copy:fonts', function(){
	return gulp.src([config.src + '/' + config.dirs.fonts + '/**/*'])
		.pipe(gulp.dest(config.dest + '/' + config.dirs.fonts));
})

gulp.task('copy', function(){
	return gulp.src(['!' + config.dest + '/styles', '!' + config.dest + '/styles/*.map', config.dest + '/**/*'])
		.pipe(gulp.dest(config.build));
})

/* ============================================================ *\
	PACKAGE THE FOLDER UP
\* ============================================================ */

gulp.task('package-release', function () {

	var d = new Date();
	var packageName = creds.packageName + '' + d.getDay() + '.' + d.getMonth() + '.' + d.getFullYear() + '_' + d.getHours() + '.' + d.getMinutes();

	return gulp.src('build/**/*')
		.pipe(zip(packageName + '.zip'))
		.pipe(gulp.dest('release'));
});

/* ============================================================ *\
	COMPILE TEMPLATES / HTML
\* ============================================================ */

gulp.task('compile-html', function () {
	var templateData = {
		data: templateDataJson
	},

	options = {
		batch : ['./views/_partials'],
		helpers: templateHelpers
	}

	return gulp.src(['./views/*.hbs'])
		.pipe(handlebars(templateData, options))
		.pipe(rename({extname: '.html'}))
		.pipe(gulp.dest('build'));
});

/* ============================================================ *\
	MAIN TASKS
\* ============================================================ */

gulp.task('watch:sass', function () {
	gulpif(!argv.prod, gulp.watch([config.src + '/' + config.dirs.styles + '/**/*.scss', config.dirs.components + '/**/*.scss'], ['sass']));
});
gulp.task('watch:js', function () {
	gulpif(!argv.prod, gulp.watch([config.src + '/' + config.dirs.scripts + '/**/*.js', config.dirs.components + '/**/*.js'], ['scripts']));
});
gulp.task('watch', function (cb) {
	runSeq(['watch:sass', 'watch:js'], cb);
});

gulp.task('build', function (cb) {
	runSeq(['default'], ['copy'], ['compile-html'],  cb);
});

gulp.task('release', function (cb) {
	runSeq(['build'], ['package-release'],  cb);
});

gulp.task('default', function (cb) {
	runSeq(['sass-generate-contents'],['sass', 'scripts', 'copy:fonts', 'imagemin'], cb);
});
<commit_msg>refactor: Change zip module to use plugins module (zip -> plugins.zip)<commit_after>/*jslint node: true */
'use strict';

	// Gulp
var gulp            = require('gulp'),
	plugins          = require('gulp-load-plugins')(),
	gulpif           = require('gulp-if'),

	// Utilities
	argv             = require('yargs').argv,
	// zip              = require('gulp-zip'),
	// sourcemaps       = require('gulp-sourcemaps'),
	runSeq           = require('run-sequence'),
	rename           = require('gulp-rename'),
	concat           = require('gulp-concat'),

	// Javascript
	uglify           = require('gulp-uglify'),
	jshint           = require('gulp-jshint'),

	// Templates
	handlebars       = require('gulp-compile-handlebars'),

	// CSS
	minifyCss        = require('gulp-minify-css'),
	autoprefixer     = require('autoprefixer-core'),
	sgc              = require('gulp-sass-generate-contents'),
	postcss          = require('gulp-postcss'),
	pixrem           = require('gulp-pixrem'),

	// Images
	imagemin         = require('gulp-imagemin'),
	pngquant         = require('imagemin-pngquant'),

	// Configuration
	config           = require('./_config/project.json'),
	templateDataJson = require('./_config/templateData.json'),
	templateHelpers  = require('./_config/templateHelpers.js')(),
	jshintConfig     = require('./_config/jshint.json'),
	creds            = require('./_config/creds.json'),
	itcss            = require('./_config/itcss'),
	destStyles       = config.src + '/' + config.dirs.styles;

/* ============================================================ *\
	SCRIPTS JS / lint, concat and minify scripts
\* ============================================================ */

gulp.task('scripts', function(){
	return gulp.src([config.src + '/' + config.dirs.scripts + '/**/*.js'])
		.pipe(gulpif(argv.prod, jshint(jshintConfig))) //Default only
		.pipe(concat('bundle.js'))
		.pipe(gulpif(argv.prod, uglify())) //Production only
		.pipe(gulp.dest(config.dest + '/' + config.dirs.scripts));
});

/* ============================================================ *\
	GENERATE SASS IMPORTS AND
\* ============================================================ */

gulp.task('sass-generate-contents', function () {
	return gulp.src(itcss())
	.pipe(sgc(destStyles + '/main.scss', creds))
	.pipe(gulp.dest(destStyles));
});

/* ============================================================ *\
	STYLES / SCSS
\* ============================================================ */

gulp.task('sass', function () {
	return gulp.src(destStyles + '/main.scss')
		.pipe(gulpif(!argv.prod, plugins.sourcemaps.init())) //Default only
		.pipe(plugins.sass({ errLogToConsole: true, includePaths: [config.dirs.components], outputStyle: 'compact' }))
		.pipe(postcss([autoprefixer({ browsers: ['> 5%', 'Android 3'] })]))
		.pipe(plugins.pixrem(config.pixelBase))
		.pipe(gulpif(!argv.prod, plugins.sourcemaps.write('.'))) //Default only
		.pipe(plugins.pixrem(config.pixelBase))
		.pipe(gulpif(argv.prod, minifyCss())) //Production only
		.pipe(gulp.dest(config.dest + '/' + config.dirs.styles));
});

/* ============================================================ *\
	IMAGES / minify images
\* ============================================================ */

gulp.task('imagemin', function () {
	return gulp.src(config.src + '/' + config.dirs.images + '/**/*')
		.pipe(gulpif(argv.prod, imagemin({
			progressive: true,
			svgoPlugins: [{removeViewBox: false}],
			use: [pngquant()]
		}))) //Production only
		.pipe(gulp.dest(config.dest + '/' + config.dirs.images));
});

/* ============================================================ *\
	MOVE / Copy files
\* ============================================================ */

gulp.task('copy:fonts', function(){
	return gulp.src([config.src + '/' + config.dirs.fonts + '/**/*'])
		.pipe(gulp.dest(config.dest + '/' + config.dirs.fonts));
})

gulp.task('copy', function(){
	return gulp.src(['!' + config.dest + '/styles', '!' + config.dest + '/styles/*.map', config.dest + '/**/*'])
		.pipe(gulp.dest(config.build));
})

/* ============================================================ *\
	PACKAGE THE FOLDER UP
\* ============================================================ */

gulp.task('package-release', function () {

	var d = new Date();
	var packageName = creds.packageName + '' + d.getDay() + '.' + d.getMonth() + '.' + d.getFullYear() + '_' + d.getHours() + '.' + d.getMinutes();

	return gulp.src('build/**/*')
		.pipe(plugins.zip(packageName + '.zip'))
		.pipe(gulp.dest('release'));
});

/* ============================================================ *\
	COMPILE TEMPLATES / HTML
\* ============================================================ */

gulp.task('compile-html', function () {
	var templateData = {
		data: templateDataJson
	},

	options = {
		batch : ['./views/_partials'],
		helpers: templateHelpers
	}

	return gulp.src(['./views/*.hbs'])
		.pipe(handlebars(templateData, options))
		.pipe(rename({extname: '.html'}))
		.pipe(gulp.dest('build'));
});

/* ============================================================ *\
	MAIN TASKS
\* ============================================================ */

gulp.task('watch:sass', function () {
	gulpif(!argv.prod, gulp.watch([config.src + '/' + config.dirs.styles + '/**/*.scss', config.dirs.components + '/**/*.scss'], ['sass']));
});
gulp.task('watch:js', function () {
	gulpif(!argv.prod, gulp.watch([config.src + '/' + config.dirs.scripts + '/**/*.js', config.dirs.components + '/**/*.js'], ['scripts']));
});
gulp.task('watch', function (cb) {
	runSeq(['watch:sass', 'watch:js'], cb);
});

gulp.task('build', function (cb) {
	runSeq(['default'], ['copy'], ['compile-html'],  cb);
});

gulp.task('release', function (cb) {
	runSeq(['build'], ['package-release'],  cb);
});

gulp.task('default', function (cb) {
	runSeq(['sass-generate-contents'],['sass', 'scripts', 'copy:fonts', 'imagemin'], cb);
});
<|endoftext|>


<commit_before>var gulp = require("gulp"),
	browserify = require("browserify"),
	watchify = require("watchify"),
	reactify = require("reactify"),
	source = require("vinyl-source-stream");

var bundler = watchify(browserify({
	cache: {},
	packageCache: {},
	fullPaths: true,
	paths: ["./node_modules", "./script/app"]
}).add("./script/app/init.js").transform("reactify"), watchify.args);

function bundle() {
	return bundler
		.bundle()
		.pipe(source("bundle.js"))
		.pipe(gulp.dest("./script/build"));
}

gulp.task("browserify", bundle);
bundler.on("update", bundle);
bundler.on("time", function(time) {
	console.log("Done - " + time + "ms.");
});

gulp.task("default", ["browserify"]);<commit_msg>Removed unnecessary gulpfile.js.<commit_after><|endoftext|>


<commit_before>'use strict'

const gulp = require('gulp')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
const rtlcss = require('gulp-rtlcss')
const cleanCSS = require('gulp-clean-css')
const sass = require('gulp-sass')
const sourcemaps = require('gulp-sourcemaps')
const ts = require('gulp-typescript')
const concat = require('gulp-concat')

const scripts_src = ['./assets/scripts/**/*.ts']
const scripts_dest = './dist/scripts'
const styles_src = ['./assets/styles/**/*.scss']
const styles_dest = './dist/styles'
const vendor_dest = './dist/vendor'
const vendor_assets = './assets/vendor'

gulp.task('scripts', () =>
    gulp.src(scripts_src)
        .pipe(sourcemaps.init())
        .pipe(ts({
            "module": "commonjs",
            "target": "es5",
            "noImplicitAny": true,
            "noImplicitUseStrict": true,
            "noImplicitThis": true,
            "strictNullChecks": true,
            "strictFunctionTypes": true
        }))
        .pipe(uglify())
        .pipe(rename({'suffix' : '.min'}))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(scripts_dest))
)

gulp.task('styles', () =>
    gulp.src(styles_src)
        .pipe(sourcemaps.init())
        .pipe(sass().on('error', sass.logError))
        // .pipe(cleanCSS({format: 'beautify'}))
        // .pipe(gulp.dest(styles_dest))
        .pipe(cleanCSS())
        .pipe(rename({'suffix' : '.min'}))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(styles_dest))
        .pipe(rtlcss())
        .pipe(rename((path) =>
            path.basename = path.basename.replace('.min', '-rtl.min')
        ))
        .pipe(gulp.dest(styles_dest))
)

gulp.task('vendor', () => {
    gulp.src([
        './vendor/grottopress/wordpress-posts/dist/styles/*.min.css',
        './node_modules/html5shiv/dist/html5shiv.min.js',
        './node_modules/respond.js/dest/respond.min.js'
    ]).pipe(gulp.dest(vendor_dest))

    gulp.src(['./node_modules/normalize.css/normalize.css'])
        .pipe(cleanCSS())
        .pipe(rename({'suffix' : '.min'}))
        .pipe(gulp.dest(vendor_dest))

    gulp.src([
        './node_modules/@fortawesome/fontawesome/index.js',
        './node_modules/@fortawesome/fontawesome-free-solid/index.js',
        './node_modules/@fortawesome/fontawesome-free-regular/index.js',
        './node_modules/@fortawesome/fontawesome-free-brands/index.js'
    ])
        .pipe(concat('fontawesome.js'))
        .pipe(uglify())
        .pipe(rename({'suffix' : '.min'}))
        .pipe(gulp.dest(vendor_dest))

    gulp.src(['./node_modules/@grottopress/scss/**'])
        .pipe(gulp.dest(`${vendor_assets}/@grottopress/scss`))
})

gulp.task('watch', () => {
    gulp.watch(scripts_src, ['scripts'])
    gulp.watch(styles_src, ['styles'])
})

gulp.task('default', [
    'scripts',
    'styles',
    'watch'
])
<commit_msg>Use gulp-concat plugin to rename file<commit_after>'use strict'

const gulp = require('gulp')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
const rtlcss = require('gulp-rtlcss')
const cleanCSS = require('gulp-clean-css')
const sass = require('gulp-sass')
const sourcemaps = require('gulp-sourcemaps')
const ts = require('gulp-typescript')
const concat = require('gulp-concat')

const scripts_src = ['./assets/scripts/**/*.ts']
const scripts_dest = './dist/scripts'
const styles_src = ['./assets/styles/**/*.scss']
const styles_dest = './dist/styles'
const vendor_dest = './dist/vendor'
const vendor_assets = './assets/vendor'

gulp.task('scripts', () =>
    gulp.src(scripts_src)
        .pipe(sourcemaps.init())
        .pipe(ts({
            "module": "commonjs",
            "target": "es5",
            "noImplicitAny": true,
            "noImplicitUseStrict": true,
            "noImplicitThis": true,
            "strictNullChecks": true,
            "strictFunctionTypes": true
        }))
        .pipe(uglify())
        .pipe(rename({'suffix' : '.min'}))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(scripts_dest))
)

gulp.task('styles', () =>
    gulp.src(styles_src)
        .pipe(sourcemaps.init())
        .pipe(sass().on('error', sass.logError))
        // .pipe(cleanCSS({format: 'beautify'}))
        // .pipe(gulp.dest(styles_dest))
        .pipe(cleanCSS())
        .pipe(rename({'suffix' : '.min'}))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(styles_dest))
        .pipe(rtlcss())
        .pipe(rename((path) =>
            path.basename = path.basename.replace('.min', '-rtl.min')
        ))
        .pipe(gulp.dest(styles_dest))
)

gulp.task('vendor', () => {
    gulp.src([
        './vendor/grottopress/wordpress-posts/dist/styles/*.min.css',
        './node_modules/html5shiv/dist/html5shiv.min.js',
        './node_modules/respond.js/dest/respond.min.js'
    ]).pipe(gulp.dest(vendor_dest))

    gulp.src(['./node_modules/normalize.css/normalize.css'])
        .pipe(cleanCSS())
        .pipe(rename({'suffix' : '.min'}))
        .pipe(gulp.dest(vendor_dest))

    gulp.src([
        './node_modules/@fortawesome/fontawesome/index.js',
        './node_modules/@fortawesome/fontawesome-free-solid/index.js',
        './node_modules/@fortawesome/fontawesome-free-regular/index.js',
        './node_modules/@fortawesome/fontawesome-free-brands/index.js'
    ])
        .pipe(concat('fontawesome.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest(vendor_dest))

    gulp.src(['./node_modules/@grottopress/scss/**'])
        .pipe(gulp.dest(`${vendor_assets}/@grottopress/scss`))
})

gulp.task('watch', () => {
    gulp.watch(scripts_src, ['scripts'])
    gulp.watch(styles_src, ['styles'])
})

gulp.task('default', [
    'scripts',
    'styles',
    'watch'
])
<|endoftext|>


<commit_before>'use strict';

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

var autoprefixer = require('autoprefixer-stylus');
var browserSync = require('browser-sync').create();
var buffer = require('vinyl-buffer');
var del = require('del');
var imageminPngquant = require('imagemin-pngquant');
var jade = require('jade');
var jstransformer = require('jstransformer');
var jstransformerStylus = require('jstransformer-stylus');
var path = require('path');
var runSequence = require('run-sequence');
var rupture = require('rupture');
var spritesmith = require('gulp.spritesmith');
var posthtmlAttrsSorter = require('posthtml-attrs-sorter');

// Error handler for gulp-plumber
var errorHandler = function (err) {
	$.util.log([(err.name + ' in ' + err.plugin).bold.red, '', err.message, ''].join('\n'));

	if ($.util.env.beep) {
		$.util.beep();
	}

	this.emit('end');
};

// Print object in console
var debugObj = function (obj) {
	var util = require('util');
	console.log(util.inspect(obj, {showHidden: false, depth: null}));
};

// Read file and return object
var getData = function getData (file) {
	var dataEntry;
	var data;
	var fs = require('fs');

	try {
		dataEntry = fs.readFileSync(file, 'utf8');
	} catch (er) {
		dataEntry = false;
	}

	if (dataEntry) {
		eval('data = {' + dataEntry + '}');
	} else {
		data = '{}';
	}

	return data;
};

var correctNumber = function correctNumber(number) {
	return number < 10 ? '0' + number : number;
};

// Return timestamp
var getDateTime = function getDateTime() {
	var now = new Date();
	var year = now.getFullYear();
	var month = correctNumber(now.getMonth() + 1);
	var day = correctNumber(now.getDate());
	var hours = correctNumber(now.getHours());
	var minutes = correctNumber(now.getMinutes());
	return year + '-' + month + '-' + day + '-' + hours + minutes;
};

// Plugins options
var options = {
	del: [
		'dest',
		'tmp'
	],

	plumber: {
		errorHandler: errorHandler
	},

	browserSync: {
		server: {
			baseDir: './dest'
		}
	},

	stylus: {
		use: [
			rupture(),
			autoprefixer({
				cascade: false
			})
		]
	},

	cssbeautify: {
		indent: '\t',
		autosemicolon: true
	},

	jade: {
		jade: jade,
		pretty: '\t'
	},

	htmlPrettify: {
		'unformatted': ['pre', 'code'],
		'indent_with_tabs': true,
		'preserve_newlines': true,
		'brace_style': 'expand',
		'end_with_newline': true
	},

	svgSymbols: {
		title: false,
		id: '%f',
		className: '%f',
		templates: [
			path.join(__dirname, 'source/static/styles/templates/icons-template.styl'),
			path.join(__dirname, 'source/static/styles/templates/icons-template.svg')
		]
	},

	spritesmith: {
		retinaSrcFilter: '**/*@2x.png',
		imgName: 'sprite.png',
		retinaImgName: 'sprite@2x.png',
		cssName: 'sprite.styl',
		algorithm: 'binary-tree',
		padding: 8,
		cssTemplate: './source/static/styles/templates/sprite-template.mustache'
	},

	imagemin: {
		optimizationLevel: 3,
		progressive: true,
		interlaced: true,
		svgoPlugins: [{removeViewBox: false}],
		use: [
			imageminPngquant()
		]
	},

	posthtml: {
		plugins: [
			posthtmlAttrsSorter({
				order: [
					'class',
					'id',
					'name',
					'data',
					'ng',
					'src',
					'for',
					'type',
					'href',
					'values',
					'title',
					'alt',
					'role',
					'aria'
				]
			})
		],
		options: {}
	}
};

gulp.task('cleanup', function (cb) {
	return del(options.del, cb);
});

gulp.task('browser-sync', function() {
	return browserSync.init(options.browserSync);
});

gulp.task('bs-reload', function (cb) {
	browserSync.reload();
});

gulp.task('combine-modules-styles', function (cb) {
	return gulp.src(['**/*.styl', '!**/_*.styl'], {cwd: 'source/modules'})
		.pipe($.plumber(options.plumber))
		.pipe($.concat('modules.styl'))
		.pipe(gulp.dest('tmp'));
});

gulp.task('compile-styles', function (cb) {
	return gulp.src(['*.styl', '!_*.styl'], {cwd: 'source/static/styles'})
		.pipe($.plumber(options.plumber))
		.pipe($.stylus(options.stylus))
		.pipe($.combineMq({beautify: false}))
		.pipe($.cssbeautify(options.cssbeautify))
		.pipe($.csscomb())
		.pipe(gulp.dest('dest/assets/stylesheets'))
		.pipe($.csso())
		.pipe($.rename({suffix: '.min'}))
		.pipe(gulp.dest('dest/assets/stylesheets'))
		.pipe(browserSync.stream());
});

gulp.task('combine-modules-data', function (cb) {
	return gulp.src(['**/*.js', '!**/_*.js'], {cwd: 'source/modules/*/data'})
		.pipe($.plumber(options.plumber))
		.pipe($.concat('data.js', { newLine: ',\n\n' }))
		.pipe(gulp.dest('tmp'));
});

jade.filters.stylus = jstransformer(jstransformerStylus);
jade.filters.shoutFilter = function (str) {
	return str + '!!!!';
}

gulp.task('compile-pages', function (cb) {
	return gulp.src(['**/*.jade', '!**/_*.jade'], {cwd: 'source/pages'})
		.pipe($.plumber(options.plumber))
		// .pipe($.cached('templates'))
		// .pipe($.if(global.isWatching, $.jadeInheritance({basedir: 'source'})))
		// .pipe($.filter(function (file) {
		// 	return !/source[\\\/]modules/.test(file.path);
		// }))
		.pipe($.data(getData('tmp/data.js')))
		.pipe($.jade(options.jade))
		.pipe($.posthtml(options.posthtml.plugins, options.posthtml.options))
		.pipe($.prettify(options.htmlPrettify))
		// .pipe($.flatten())
		.pipe(gulp.dest('dest'));
});

gulp.task('copy-modules-img', function (cb) {
	return gulp.src('**/*.{jpg,gif,svg,png}', {cwd: 'source/modules/*/assets'})
		.pipe($.plumber(options.plumber))
		.pipe($.changed('dest/assets/images'))
		.pipe($.imagemin(options.imagemin))
		.pipe($.flatten())
		.pipe(gulp.dest('dest/assets/images'));
});

gulp.task('combine-modules-scripts', function (cb) {
	return gulp.src(['*.js', '!_*.js'], {cwd: 'source/modules/*'})
		.pipe($.plumber(options.plumber))
		.pipe($.concat('modules.js', { newLine: '\n\n' }))
		.pipe(gulp.dest('tmp'));
});

gulp.task('copy-assets', function (cb) {
	var imageFilter = $.filter('**/*.{jpg,gif,svg,png}', {restore: true});
	var scriptsFilter = $.filter(['**/*.js', '!**/*.min.js'], {restore: true});
	var stylesFilter = $.filter(['**/*.css', '!**/*.min.css'], {restore: true});

	return gulp.src(['**/*.*', '!**/_*.*'], {cwd: 'source/static/assets'})
		.pipe($.plumber(options.plumber))
		.pipe($.changed('dest/assets'))

		// Minify images
		.pipe(imageFilter)
		.pipe($.changed('dest/assets'))
		.pipe($.imagemin(options.imagemin))
		.pipe(imageFilter.restore)

		// Minify JavaScript files
		.pipe(scriptsFilter)
		.pipe(gulp.dest('dest/assets'))
		.pipe($.uglify())
		.pipe($.rename({suffix: '.min'}))
		.pipe(scriptsFilter.restore)

		// Minify css
		.pipe(stylesFilter)
		.pipe($.csso())
		.pipe($.rename({suffix: '.min'}))
		.pipe(stylesFilter.restore)

		// Copy other files
		.pipe(gulp.dest('dest/assets'));
});

gulp.task('combine-scripts', function (cb) {
	return gulp.src(['*.js', '!_*.js'], {cwd: 'source/static/scripts'})
		.pipe($.plumber(options.plumber))
		.pipe($.include())
		.pipe(gulp.dest('dest/assets/javascripts'))
		.pipe($.uglify())
		.pipe($.rename({suffix: '.min'}))
		.pipe(gulp.dest('dest/assets/javascripts'));
});

gulp.task('combine-svg-icons', function (cb) {
	return gulp.src(['**/*.svg', '!**/_*.svg'], {cwd: 'source/static/icons'})
		.pipe($.plumber(options.plumber))
		.pipe($.imagemin(options.imagemin))
		.pipe($.svgSymbols(options.svgSymbols))
		.pipe($.if(/\.styl$/, gulp.dest('tmp')))
		.pipe($.if(/\.svg$/, $.rename('icons.svg')))
		.pipe($.if(/\.svg$/, gulp.dest('dest/assets/images')));
});

gulp.task('combine-png-sprite', function (cb) {
	var spriteData = gulp.src(['**/*.png', '!**/_*.png'], {cwd: 'source/static/sprite'})
		.pipe(spritesmith(options.spritesmith));

	spriteData.img.pipe(buffer())
		.pipe($.imagemin())
		.pipe(gulp.dest('dest/assets/images'));

	spriteData.css.pipe(buffer())
		.pipe(gulp.dest('tmp'));

	return spriteData.img.pipe(buffer());
});

// Semver
gulp.task('patch', function () {
	return gulp.src('package.json')
		.pipe($.bump())
		.pipe(gulp.dest('./'));
});

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

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

gulp.task('semver:reset', function () {
	return gulp.src('package.json')
		.pipe($.bump({ version: '0.1.0' }))
		.pipe(gulp.dest('./'));
});

gulp.task('build-zip', function() {
	var datetime = '-' + getDateTime();
	var zipName = 'dist' + datetime + '.zip';

	return gulp.src('dest/**/*')
		.pipe($.zip(zipName))
		.pipe(gulp.dest('zip'));
});

gulp.task('build-html', function (cb) {
	return runSequence(
		'combine-modules-data',
		'compile-pages',
		cb
	);
});

gulp.task('build-css', function (cb) {
	return runSequence(
		'combine-modules-styles',
		'compile-styles',
		cb
	);
});

gulp.task('build-js', function (cb) {
	return runSequence(
		'combine-modules-scripts',
		'combine-scripts',
		cb
	);
});

gulp.task('build', function (cb) {
	return runSequence(
		'cleanup',
		[
			'build-html',
			'combine-svg-icons',
			'combine-png-sprite',
			'copy-modules-img',
			'copy-assets',
			'build-js',
		],
		'build-css',
		cb
	);
});

gulp.task('zip', function (cb) {
	return runSequence(
		'build',
		'build-zip',
		cb
	);
});

gulp.task('develop', function (cb) {
	return runSequence(
		'build',
		'browser-sync',
		cb
	);
});

gulp.task('dev', ['develop'], function (cb) {
	global.isWatching = true;

	// Modules, pages
	$.watch('source/**/*.jade', function() {
		return runSequence('compile-pages', browserSync.reload);
	});

	// Modules data
	$.watch('source/modules/*/data/*.js', function() {
		return runSequence('build-html', browserSync.reload);
	});

	// Static styles
	$.watch('source/static/styles/**/*.styl', function() {
		// return runSequence('compile-styles');
		gulp.start('compile-styles');
	});

	// Modules styles
	$.watch('source/modules/**/*.styl', function() {
		// return runSequence('build-css');
		gulp.start('build-css');
	});

	// Static scripts
	$.watch('source/static/scripts/**/*.js', function() {
		return runSequence('combine-scripts', browserSync.reload);
	});

	// Modules scripts
	$.watch('source/modules/*/*.js', function() {
		return runSequence('build-js', browserSync.reload);
	});

	// Modules images
	$.watch('source/modules/*/assets/**/*.{jpg,gif,svg,png}', function() {
		return runSequence('copy-modules-img', browserSync.reload);
	});

	// Static files
	$.watch('source/static/assets/**/*', function() {
		return runSequence('copy-assets', browserSync.reload);
	});

	// Svg icons
	$.watch('source/static/icons/**/*.svg', function() {
		return runSequence('combine-svg-icons', browserSync.reload);
	});

	// Png sprites
	$.watch('source/static/sprite/**/*.png', function() {
		return runSequence('combine-png-sprite', browserSync.reload);
	});
});
<commit_msg>Some gulpfile optimizations<commit_after>'use strict';

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

var autoprefixer = require('autoprefixer-stylus');
var browserSync = require('browser-sync').create();
var buffer = require('vinyl-buffer');
var del = require('del');
var imageminPngquant = require('imagemin-pngquant');
var jade = require('jade');
var jstransformer = require('jstransformer');
var jstransformerStylus = require('jstransformer-stylus');
var path = require('path');
var runSequence = require('run-sequence');
var rupture = require('rupture');
var spritesmith = require('gulp.spritesmith');
var posthtmlAttrsSorter = require('posthtml-attrs-sorter');

// Error handler for gulp-plumber
var errorHandler = function (err) {
	$.util.log([(err.name + ' in ' + err.plugin).bold.red, '', err.message, ''].join('\n'));

	if ($.util.env.beep) {
		$.util.beep();
	}

	this.emit('end');
};

// Print object in console
var debugObj = function (obj) {
	var util = require('util');
	console.log(util.inspect(obj, {showHidden: false, depth: null}));
};

// Read file and return object
var getData = function getData (file) {
	var dataEntry;
	var data;
	var fs = require('fs');

	try {
		dataEntry = fs.readFileSync(file, 'utf8');
	} catch (er) {
		dataEntry = false;
	}

	if (dataEntry) {
		eval('data = {' + dataEntry + '}');
	} else {
		data = '{}';
	}

	return data;
};

var correctNumber = function correctNumber(number) {
	return number < 10 ? '0' + number : number;
};

// Return timestamp
var getDateTime = function getDateTime() {
	var now = new Date();
	var year = now.getFullYear();
	var month = correctNumber(now.getMonth() + 1);
	var day = correctNumber(now.getDate());
	var hours = correctNumber(now.getHours());
	var minutes = correctNumber(now.getMinutes());
	return year + '-' + month + '-' + day + '-' + hours + minutes;
};

// Plugins options
var options = {
	del: [
		'dest',
		'tmp'
	],

	plumber: {
		errorHandler: errorHandler
	},

	browserSync: {
		server: {
			baseDir: './dest'
		}
	},

	stylus: {
		use: [
			rupture(),
			autoprefixer({
				cascade: false
			})
		]
	},

	cssbeautify: {
		indent: '\t',
		autosemicolon: true
	},

	jade: {
		jade: jade,
		pretty: '\t'
	},

	htmlPrettify: {
		'unformatted': ['pre', 'code'],
		'indent_with_tabs': true,
		'preserve_newlines': true,
		'brace_style': 'expand',
		'end_with_newline': true
	},

	svgSymbols: {
		title: false,
		id: '%f',
		className: '%f',
		templates: [
			path.join(__dirname, 'source/static/styles/templates/icons-template.styl'),
			path.join(__dirname, 'source/static/styles/templates/icons-template.svg')
		]
	},

	spritesmith: {
		retinaSrcFilter: '**/*@2x.png',
		imgName: 'sprite.png',
		retinaImgName: 'sprite@2x.png',
		cssName: 'sprite.styl',
		algorithm: 'binary-tree',
		padding: 8,
		cssTemplate: './source/static/styles/templates/sprite-template.mustache'
	},

	imagemin: {
		optimizationLevel: 3,
		progressive: true,
		interlaced: true,
		svgoPlugins: [{removeViewBox: false}],
		use: [
			imageminPngquant()
		]
	},

	posthtml: {
		plugins: [
			posthtmlAttrsSorter({
				order: [
					'class',
					'id',
					'name',
					'data',
					'ng',
					'src',
					'for',
					'type',
					'href',
					'values',
					'title',
					'alt',
					'role',
					'aria'
				]
			})
		],
		options: {}
	}
};

gulp.task('cleanup', function (cb) {
	return del(options.del, cb);
});

gulp.task('browser-sync', function() {
	return browserSync.init(options.browserSync);
});

gulp.task('bs-reload', function (cb) {
	browserSync.reload();
});

gulp.task('combine-modules-styles', function (cb) {
	return gulp.src(['**/*.styl', '!**/_*.styl'], {cwd: 'source/modules'})
		.pipe($.plumber(options.plumber))
		.pipe($.concat('modules.styl'))
		.pipe(gulp.dest('tmp'));
});

gulp.task('compile-styles', function (cb) {
	return gulp.src(['*.styl', '!_*.styl'], {cwd: 'source/static/styles'})
		.pipe($.plumber(options.plumber))
		.pipe($.stylus(options.stylus))
		.pipe($.combineMq({beautify: false}))
		.pipe($.cssbeautify(options.cssbeautify))
		.pipe($.csscomb())
		.pipe(gulp.dest('dest/assets/stylesheets'))
		.pipe($.csso())
		.pipe($.rename({suffix: '.min'}))
		.pipe(gulp.dest('dest/assets/stylesheets'))
		.pipe(browserSync.stream());
});

gulp.task('combine-modules-data', function (cb) {
	return gulp.src(['**/*.js', '!**/_*.js'], {cwd: 'source/modules/*/data'})
		.pipe($.plumber(options.plumber))
		.pipe($.concat('data.js', { newLine: ',\n\n' }))
		.pipe(gulp.dest('tmp'));
});

jade.filters.stylus = jstransformer(jstransformerStylus);
jade.filters.shoutFilter = function (str) {
	return str + '!!!!';
}

gulp.task('compile-pages', function (cb) {
	return gulp.src(['**/*.jade', '!**/_*.jade'], {cwd: 'source/pages'})
		.pipe($.plumber(options.plumber))
		// .pipe($.cached('templates'))
		// .pipe($.if(global.isWatching, $.jadeInheritance({basedir: 'source'})))
		// .pipe($.filter(function (file) {
		// 	return !/source[\\\/]modules/.test(file.path);
		// }))
		.pipe($.data(getData('tmp/data.js')))
		.pipe($.jade(options.jade))
		.pipe($.posthtml(options.posthtml.plugins, options.posthtml.options))
		.pipe($.prettify(options.htmlPrettify))
		// .pipe($.flatten())
		.pipe(gulp.dest('dest'));
});

gulp.task('copy-modules-img', function (cb) {
	return gulp.src('**/*.{jpg,gif,svg,png}', {cwd: 'source/modules/*/assets'})
		.pipe($.plumber(options.plumber))
		.pipe($.changed('dest/assets/images'))
		.pipe($.imagemin(options.imagemin))
		.pipe($.flatten())
		.pipe(gulp.dest('dest/assets/images'));
});

gulp.task('combine-modules-scripts', function (cb) {
	return gulp.src(['*.js', '!_*.js'], {cwd: 'source/modules/*'})
		.pipe($.plumber(options.plumber))
		.pipe($.concat('modules.js', { newLine: '\n\n' }))
		.pipe(gulp.dest('tmp'));
});

gulp.task('copy-assets', function (cb) {
	var imageFilter = $.filter('**/*.{jpg,gif,svg,png}', {restore: true});
	var scriptsFilter = $.filter(['**/*.js', '!**/*.min.js'], {restore: true});
	var stylesFilter = $.filter(['**/*.css', '!**/*.min.css'], {restore: true});

	return gulp.src(['**/*.*', '!**/_*.*'], {cwd: 'source/static/assets'})
		.pipe($.plumber(options.plumber))
		.pipe($.changed('dest/assets'))

		// Minify images
		.pipe(imageFilter)
		.pipe($.changed('dest/assets'))
		.pipe($.imagemin(options.imagemin))
		.pipe(imageFilter.restore)

		// Minify JavaScript files
		.pipe(scriptsFilter)
		.pipe(gulp.dest('dest/assets'))
		.pipe($.uglify())
		.pipe($.rename({suffix: '.min'}))
		.pipe(scriptsFilter.restore)

		// Minify css
		.pipe(stylesFilter)
		.pipe($.csso())
		.pipe($.rename({suffix: '.min'}))
		.pipe(stylesFilter.restore)

		// Copy other files
		.pipe(gulp.dest('dest/assets'));
});

gulp.task('combine-scripts', function (cb) {
	return gulp.src(['*.js', '!_*.js'], {cwd: 'source/static/scripts'})
		.pipe($.plumber(options.plumber))
		.pipe($.include())
		.pipe(gulp.dest('dest/assets/javascripts'))
		.pipe($.uglify())
		.pipe($.rename({suffix: '.min'}))
		.pipe(gulp.dest('dest/assets/javascripts'));
});

gulp.task('combine-svg-icons', function (cb) {
	return gulp.src(['**/*.svg', '!**/_*.svg'], {cwd: 'source/static/icons'})
		.pipe($.plumber(options.plumber))
		.pipe($.imagemin(options.imagemin))
		.pipe($.svgSymbols(options.svgSymbols))
		.pipe($.if(/\.styl$/, gulp.dest('tmp')))
		.pipe($.if(/\.svg$/, $.rename('icons.svg')))
		.pipe($.if(/\.svg$/, gulp.dest('dest/assets/images')));
});

gulp.task('combine-png-sprite', function (cb) {
	var spriteData = gulp.src(['**/*.png', '!**/_*.png'], {cwd: 'source/static/sprite'})
		.pipe(spritesmith(options.spritesmith));

	spriteData.img.pipe(buffer())
		.pipe($.imagemin())
		.pipe(gulp.dest('dest/assets/images'));

	spriteData.css.pipe(buffer())
		.pipe(gulp.dest('tmp'));

	return spriteData.img.pipe(buffer());
});

// Semver
gulp.task('patch', function () {
	return gulp.src('package.json')
		.pipe($.bump())
		.pipe(gulp.dest('./'));
});

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

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

gulp.task('semver:reset', function () {
	return gulp.src('package.json')
		.pipe($.bump({ version: '0.1.0' }))
		.pipe(gulp.dest('./'));
});

gulp.task('build-zip', function() {
	var datetime = '-' + getDateTime();
	var zipName = 'dist' + datetime + '.zip';

	return gulp.src('dest/**/*')
		.pipe($.zip(zipName))
		.pipe(gulp.dest('zip'));
});

// Service tasks
gulp.task('build-html', function (cb) {
	return runSequence(
		'combine-modules-data',
		'compile-pages',
		cb
	);
});

gulp.task('build-css', function (cb) {
	return runSequence(
		'combine-modules-styles',
		'compile-styles',
		cb
	);
});

gulp.task('build-js', function (cb) {
	return runSequence(
		'combine-modules-scripts',
		'combine-scripts',
		cb
	);
});

// Main tasks
gulp.task('build', function (cb) {
	return runSequence(
		'cleanup',
		[
			'build-html',
			'combine-svg-icons',
			'combine-png-sprite',
			'copy-modules-img',
			'copy-assets',
			'build-js',
		],
		'build-css',
		cb
	);
});

gulp.task('zip', function (cb) {
	return runSequence(
		'build',
		'build-zip',
		cb
	);
});

gulp.task('dev', function (cb) {
	return runSequence(
		'build',
		[
			'browser-sync',
			'watch'
		],
		cb
	);
});

gulp.task('watch', function (cb) {
	global.isWatching = true;

	// Modules, pages
	$.watch('source/**/*.jade', function() {
		return runSequence('compile-pages', browserSync.reload);
	});

	// Modules data
	$.watch('source/modules/*/data/*.js', function() {
		return runSequence('build-html', browserSync.reload);
	});

	// Static styles
	$.watch('source/static/styles/**/*.styl', function() {
		// return runSequence('compile-styles');
		gulp.start('compile-styles');
	});

	// Modules styles
	$.watch('source/modules/**/*.styl', function() {
		// return runSequence('build-css');
		gulp.start('build-css');
	});

	// Static scripts
	$.watch('source/static/scripts/**/*.js', function() {
		return runSequence('combine-scripts', browserSync.reload);
	});

	// Modules scripts
	$.watch('source/modules/*/*.js', function() {
		return runSequence('build-js', browserSync.reload);
	});

	// Modules images
	$.watch('source/modules/*/assets/**/*.{jpg,gif,svg,png}', function() {
		return runSequence('copy-modules-img', browserSync.reload);
	});

	// Static files
	$.watch('source/static/assets/**/*', function() {
		return runSequence('copy-assets', browserSync.reload);
	});

	// Svg icons
	$.watch('source/static/icons/**/*.svg', function() {
		return runSequence('combine-svg-icons', browserSync.reload);
	});

	// Png sprites
	$.watch('source/static/sprite/**/*.png', function() {
		return runSequence('combine-png-sprite', browserSync.reload);
	});
});

gulp.task('default', function(cb) {
	gulp.start('build');
});
<|endoftext|>


<commit_before>const fs = require('fs')
const gulp = require('gulp')
const glob = require('glob')
const rename = require('gulp-rename')
const sourcemaps = require('gulp-sourcemaps')
const clean = require('gulp-clean')
const header = require('gulp-header')
const ts = require('gulp-typescript')
const rollup = require('gulp-rollup')
const includePaths = require('rollup-plugin-includepaths')
const uglify = require('gulp-uglify')

gulp.task('clean', () =>
  gulp.src('build')
    .pipe(clean())
)

const tsResult =
  gulp.src(['assets/env.d.ts', 'packages/*/src/**/*.ts'])
    .pipe(sourcemaps.init())
    .pipe(ts(ts.createProject('tsconfig.json', {
      typescript: require('typescript'),
      noEmit: false,
    })))

gulp.task('typings', () =>
  tsResult.dts
    .pipe(rename(maybeRenameSourcePath))
    .pipe(gulp.dest('build/typings'))
)

gulp.task('es6', () =>
  tsResult.js
    .pipe(sourcemaps.write())
    .pipe(rename(maybeRenameSourcePath))
    .pipe(gulp.dest('build/es6'))
)

gulp.task('es3', ['es6'], () =>
  gulp.src('build/es6/**/*.js')
    .pipe(sourcemaps.init({ loadMaps: true }))
    .pipe(ts({
      allowJs: true,
      target: 'es3',
      module: 'commonjs',
    }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('build/es3'))
)

const headerTemplate =
`/*!
 * Vulture v<%= version %>
 * (c) 2016 Caleb Meredith
 * Released under the MIT License.
 */
`

gulp.task('dist', ['es6'], () =>
  gulp.src(['assets/entries/*.js', 'build/es6/**/*.js'])
    .pipe(sourcemaps.init({ loadMaps: true }))
    .pipe(rollup({
      entry: glob.sync('assets/entries/*.js'),
      format: 'iife',
      moduleName: 'Vulture',
      plugins: [
        includePaths({ paths: ['build/es6'] }),
      ],
    }))
    .pipe(ts({
      allowJs: true,
      target: 'es3',
    }))
    .pipe(header(headerTemplate, {
      version: JSON.parse(fs.readFileSync('lerna.json', 'utf8')).version,
    }))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('build/dist'))
)

gulp.task('dist-min', ['dist'], () =>
  gulp.src('build/dist/+([^.]).js')
    .pipe(sourcemaps.init())
    .pipe(uglify({ preserveComments: 'license' }))
    .pipe(sourcemaps.write('.'))
    .pipe(rename(addMinToPath))
    .pipe(gulp.dest('build/dist'))
)

gulp.task('bundle', ['typings', 'es6', 'es3'], () =>
    .pipe(rename(xxx))
  gulp.src('build/{typings,es6,es3}/**/*')
    .pipe(gulp.dest('packages'))
)

gulp.task('default', ['typings', 'es6', 'es3', 'dist', 'dist-min'])

function maybeRenameSourcePath (path) {
  const sourcePathRe = /(vulture[^/]*)\/src(.*)$/

  if (sourcePathRe.test(path.dirname)) {
    const [, package, dirname] = sourcePathRe.exec(path.dirname)
    path.dirname = `${package}${dirname}`
  }
}

function addMinToPath (path) {
  const jsPathRe = /^(.*?)(\.js)?$/
  const [, basename, extension] = jsPathRe.exec(path.basename)
  path.basename = `${basename}.min${extension || ''}`
}
<commit_msg>feat(gulpfile): implement build bundling<commit_after>const fs = require('fs')
const gulp = require('gulp')
const glob = require('glob')
const rename = require('gulp-rename')
const sourcemaps = require('gulp-sourcemaps')
const clean = require('gulp-clean')
const header = require('gulp-header')
const ts = require('gulp-typescript')
const rollup = require('gulp-rollup')
const includePaths = require('rollup-plugin-includepaths')
const uglify = require('gulp-uglify')

gulp.task('clean', () =>
  gulp.src('build')
    .pipe(clean())
)

const tsResult =
  gulp.src(['assets/env.d.ts', 'packages/*/src/**/*.ts'])
    .pipe(sourcemaps.init())
    .pipe(ts(ts.createProject('tsconfig.json', {
      typescript: require('typescript'),
      noEmit: false,
    })))

gulp.task('typings', () =>
  tsResult.dts
    .pipe(rename(maybeRenameSourcePath))
    .pipe(gulp.dest('build/typings'))
)

gulp.task('es6', () =>
  tsResult.js
    .pipe(sourcemaps.write())
    .pipe(rename(maybeRenameSourcePath))
    .pipe(gulp.dest('build/es6'))
)

gulp.task('es3', ['es6'], () =>
  gulp.src('build/es6/**/*.js')
    .pipe(sourcemaps.init({ loadMaps: true }))
    .pipe(ts({
      allowJs: true,
      target: 'es3',
      module: 'commonjs',
    }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('build/es3'))
)

const headerTemplate =
`/*!
 * Vulture v<%= version %>
 * (c) 2016 Caleb Meredith
 * Released under the MIT License.
 */
`

gulp.task('dist', ['es6'], () =>
  gulp.src(['assets/entries/*.js', 'build/es6/**/*.js'])
    .pipe(sourcemaps.init({ loadMaps: true }))
    .pipe(rollup({
      entry: glob.sync('assets/entries/*.js'),
      format: 'iife',
      moduleName: 'Vulture',
      plugins: [
        includePaths({ paths: ['build/es6'] }),
      ],
    }))
    .pipe(ts({
      allowJs: true,
      target: 'es3',
    }))
    .pipe(header(headerTemplate, {
      version: JSON.parse(fs.readFileSync('lerna.json', 'utf8')).version,
    }))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('build/dist'))
)

gulp.task('dist-min', ['dist'], () =>
  gulp.src('build/dist/+([^.]).js')
    .pipe(sourcemaps.init())
    .pipe(uglify({ preserveComments: 'license' }))
    .pipe(sourcemaps.write('.'))
    .pipe(rename(addMinToPath))
    .pipe(gulp.dest('build/dist'))
)

gulp.task('bundle', ['typings', 'es6', 'es3'], () =>
  gulp.src('build/{typings,es6,es3}/*/**/*.*')
    .pipe(rename(moveToPackage))
    .pipe(gulp.dest('packages'))
)

gulp.task('default', ['typings', 'es6', 'es3', 'dist', 'dist-min'])

function maybeRenameSourcePath (path) {
  const sourcePathRe = /(vulture[^/]*)\/src(.*)$/

  if (sourcePathRe.test(path.dirname)) {
    const [, package, dirname] = sourcePathRe.exec(path.dirname)
    path.dirname = `${package}${dirname}`
  }
}

function addMinToPath (path) {
  const jsPathRe = /^(.*?)(\.js)?$/
  const [, basename, extension] = jsPathRe.exec(path.basename)
  path.basename = `${basename}.min${extension || ''}`
}

function moveToPackage (path) {
  const dirnameRe = /^([^/]+)\/([^/]+)(\/.+)?$/
  const [, artifact, package, rest] = dirnameRe.exec(path.dirname)
  path.dirname = `${package}/dist/${artifact}/${rest || ''}`
}
<|endoftext|>


<commit_before>'use strict';
//https://github.com/StarterSquad/ngseed/blob/develop/Gulpfile.js
//https://github.com/google/web-starter-kit/blob/master/gulpfile.js
//https://github.com/Granze/applause/blob/master/package.json
//https://github.com/samora/ng-launchpad/blob/master/Gulpfile.js

var config = require('./build/build.config.js');
var karmaConfig = require('./build/karma.config.js');
var protractorConfig = require('./build/protractor.config.js');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var pkg = require('./package');
var karma = require('karma').server;
var del = require('del');
var _ = require('lodash');
/* jshint camelcase:false*/
var webdriverStandalone = require('gulp-protractor').webdriver_standalone;
var webdriverUpdate = require('gulp-protractor').webdriver_update;

// Run e2e tests using protractor.
// Make sure server task is running.
gulp.task('e2e', ['webdriver:update'], function() {
  return gulp.src(protractorConfig.config.specs)
    .pipe($.protractor.protractor({
      configFile: 'build/protractor.config.js'
    }))
    .on('error', function(e) {
      throw e;
    });
});

gulp.task('webdriver:update', webdriverUpdate);

/**
 * Run test once and exit
 */
gulp.task('unit', ['build'], function(cb) {
  karma.start(_.assign({}, karmaConfig, {
    singleRun: true
  }), cb);
});

/**
 * Watch for file changes and re-run tests on each change
 */
gulp.task('unit:tdd', function(cb) {
  karma.start(_.assign({}, karmaConfig, {
    singleRun: false,
    action:'watch',
    browsers: ['PhantomJS']
  }), cb);
});

gulp.task('tdd', function(cb) {
  runSequence(['serve', 'unit:tdd']);
});

// Optimize Images
gulp.task('images', function() {
  return gulp.src(config.images)
    .pipe($.imagemin({
      progressive: true,
      interlaced: true
    }))
    .pipe(gulp.dest(config.dist + '/assets/images'))
    .pipe($.size({
      title: 'images'
    }));
});

gulp.task('templates', function() {
  return gulp.src(config.tpl)
    .pipe($.changed(config.tmp))
    .pipe($.html2js({
      outputModuleName: 'templates',
      base: 'client',
      useStrict: true
    }))
    .pipe($.concat('templates.js'))
    .pipe(gulp.dest(config.tmp))
    .pipe($.size({
      title: 'templates'
    }));
});

gulp.task('scss', function() {
  return gulp.src(config.mainScss)
    .pipe($.sass({
      errLogToConsole: true
    }))
    .pipe(gulp.dest(config.tmp))
    .pipe($.size({
      title: 'scss'
    }));
});

gulp.task('serve', ['build'], function() {
  browserSync({
    notify: false,
    logPrefix: pkg.name,
    server: ['build', 'client']
  });

  gulp.watch(config.html, reload);
  gulp.watch(config.scss, ['scss', reload]);
  gulp.watch([config.js, 'gulpfile.js'], ['jshint']);
  gulp.watch(config.tpl, ['templates', reload]);
  gulp.watch(config.assets, reload);
});

gulp.task('build:dist', ['clean'], function(cb) {
  runSequence(['jshint', 'build', 'copy', 'images'], 'html', cb);
});

gulp.task('build', ['clean'], function(cb) {
  runSequence(['scss', 'templates'], cb);
});

gulp.task('serve:dist', ['build:dist'], function() {
  browserSync({
    notify: false,
    server: [config.dist]
  });
});

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

  return gulp.src(config.index)
    .pipe(assets)
    .pipe($.sourcemaps.init())
    .pipe($.if('**/*main.js', $.ngAnnotate()))
    .pipe($.if('*.js', $.uglify({
      mangle: false,
    })))
    .pipe($.if('*.css', $.csso()))
    .pipe($.if(['**/*main.js', '**/*main.css'], $.header(config.banner, {
      pkg: pkg
    })))
    .pipe($.rev())
    .pipe(assets.restore())
    .pipe($.useref())
    .pipe($.revReplace())
    .pipe($.if('*.html', $.minifyHtml({
      empty: true
    })))
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest(config.dist))
    .pipe($.size({
      title: 'html'
    }));
});

gulp.task('copy', function() {
  return gulp.src(config.assets, {
      dot: true
    }).pipe(gulp.dest(config.dist + '/assets'))
    .pipe($.size({
      title: 'copy'
    }));
});

gulp.task('clean', del.bind(null, [config.dist, config.tmp]));

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

gulp.task('jshint', function() {
  return gulp.src([config.js, 'gulpfile.js'])
    .pipe(reload({
      stream: true,
      once: true
    }))
    .pipe($.jshint())
    .pipe($.jshint.reporter('jshint-stylish'))
    .pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
});
<commit_msg>cleaning gulpfile.js<commit_after>'use strict';

var config = require('./build/build.config.js');
var karmaConfig = require('./build/karma.config.js');
var protractorConfig = require('./build/protractor.config.js');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var pkg = require('./package');
var karma = require('karma').server;
var del = require('del');
var _ = require('lodash');
/* jshint camelcase:false*/
var webdriverStandalone = require('gulp-protractor').webdriver_standalone;
var webdriverUpdate = require('gulp-protractor').webdriver_update;

//update webdriver if necessary, this task will be used by e2e task
gulp.task('webdriver:update', webdriverUpdate);

// run unit tests and watch files
gulp.task('unit:tdd', function(cb) {
  karma.start(_.assign({}, karmaConfig, {
    singleRun: false,
    action: 'watch',
    browsers: ['PhantomJS']
  }), cb);
});

// optimize images and put them in the dist folder
gulp.task('images', function() {
  return gulp.src(config.images)
    .pipe($.imagemin({
      progressive: true,
      interlaced: true
    }))
    .pipe(gulp.dest(config.dist + '/assets/images'))
    .pipe($.size({
      title: 'images'
    }));
});

//generate angular templates using html2js
gulp.task('templates', function() {
  return gulp.src(config.tpl)
    .pipe($.changed(config.tmp))
    .pipe($.html2js({
      outputModuleName: 'templates',
      base: 'client',
      useStrict: true
    }))
    .pipe($.concat('templates.js'))
    .pipe(gulp.dest(config.tmp))
    .pipe($.size({
      title: 'templates'
    }));
});

//generate css files from scss sources
gulp.task('scss', function() {
  return gulp.src(config.mainScss)
    .pipe($.sass({
      errLogToConsole: true
    }))
    .pipe(gulp.dest(config.tmp))
    .pipe($.size({
      title: 'scss'
    }));
});

//build files for creating a dist release
gulp.task('build:dist', ['clean'], function(cb) {
  runSequence(['jshint', 'build', 'copy', 'images'], 'html', cb);
});

//build files for development
gulp.task('build', ['clean'], function(cb) {
  runSequence(['scss', 'templates'], cb);
});

//generate a minified css files, 2 js file, change theirs name to be unique, and generate sourcemaps
gulp.task('html', function() {
  var assets = $.useref.assets({
    searchPath: '{build,client}'
  });

  return gulp.src(config.index)
    .pipe(assets)
    .pipe($.sourcemaps.init())
    .pipe($.if('**/*main.js', $.ngAnnotate()))
    .pipe($.if('*.js', $.uglify({
      mangle: false,
    })))
    .pipe($.if('*.css', $.csso()))
    .pipe($.if(['**/*main.js', '**/*main.css'], $.header(config.banner, {
      pkg: pkg
    })))
    .pipe($.rev())
    .pipe(assets.restore())
    .pipe($.useref())
    .pipe($.revReplace())
    .pipe($.if('*.html', $.minifyHtml({
      empty: true
    })))
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest(config.dist))
    .pipe($.size({
      title: 'html'
    }));
});

//copy assets in dist folder
gulp.task('copy', function() {
  return gulp.src(config.assets, {
      dot: true
    }).pipe(gulp.dest(config.dist + '/assets'))
    .pipe($.size({
      title: 'copy'
    }));
});

//clean temporary directories
gulp.task('clean', del.bind(null, [config.dist, config.tmp]));

//lint files
gulp.task('jshint', function() {
  return gulp.src([config.js, 'gulpfile.js', config.jsTestUnit, config.jsTestE2e])
    .pipe(reload({
      stream: true,
      once: true
    }))
    .pipe($.jshint())
    .pipe($.jshint.reporter('jshint-stylish'))
    .pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
});

/* tasks supposed to be public */

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

//run the app packed in the dist folder
gulp.task('serve:dist', ['build:dist'], function() {
  browserSync({
    notify: false,
    server: [config.dist]
  });
});

//run unit tests and exit
gulp.task('unit', ['build'], function(cb) {
  karma.start(_.assign({}, karmaConfig, {
    singleRun: true
  }), cb);
});

// Run e2e tests using protractor, make sure serve task is running.
gulp.task('e2e', ['webdriver:update'], function() {
  return gulp.src(protractorConfig.config.specs)
    .pipe($.protractor.protractor({
      configFile: 'build/protractor.config.js'
    }))
    .on('error', function(e) {
      throw e;
    });
});

//run the server,  watch for file changes and redo tests.
gulp.task('tdd', function(cb) {
  runSequence(['serve', 'unit:tdd']);
});

//run the server after having built generated files, and watch for changes
gulp.task('serve', ['build'], function() {
  browserSync({
    notify: false,
    logPrefix: pkg.name,
    server: ['build', 'client']
  });

  gulp.watch(config.html, reload);
  gulp.watch(config.scss, ['scss', reload]);
  gulp.watch([config.js, 'gulpfile.js', config.jsTestUnit, config.jsTestE2e], ['jshint']);
  gulp.watch(config.tpl, ['templates', reload]);
  gulp.watch(config.assets, reload);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var ts = require('gulp-typescript');
var uglify = require('gulp-uglify');
var webpack = require('webpack-stream');
var del = require('del');
var rename = require("gulp-rename");
var gutil = require('gulp-util');

var tsProject = ts.createProject('tsconfig.json');
///////////////////////////////////////////////////////
// CLEAN                                             //
///////////////////////////////////////////////////////
gulp.task('clean:all', function () {
    return del([
      'dist/**/*',
      'lib/**/*',
    ]);
  });

///////////////////////////////////////////////////////
// PATCH                                             //
///////////////////////////////////////////////////////

gulp.task('patch', ['clean:all'], function () {
    let projectAction = function(project) {
            project.version = process.env.version || project.version
            return project;
        };

    patchProject(projectAction)
        .pipe(gulp.dest('./'));
});

gulp.task('compile', ['patch', 'clean:all'], function () {

    let tsResult = tsProject.src()
                            .pipe(tsProject());

    return tsResult.js.pipe(gulp.dest('lib'));
});

gulp.task('copy', ['compile', 'webpack'], function() {
    gulp.src('./types/loxium.d.ts')
        .pipe(gulp.dest('./lib/'))
})

gulp.task('webpack', ['compile'], function () {

      let project = require('./package.json');

        return gulp.src('./lib/loxium.js')
            .pipe(webpack(require('./webpack.config.js')))
            .pipe(uglify())
            .pipe(rename(`loxium-${project.version}.min.js`))
            .pipe(gulp.dest(`dist/`));
    });

gulp.task('default', [ 'clean:all', 'patch', 'compile', 'webpack', 'copy' ]);

function patchProject(action) {
    let package = require('./package.json');

    package = action(package);

    let src = require('stream').Readable({ objectMode: true });

    src._read = function () {
      this.push(new gutil.File({
        cwd: "",
        base: "",
        path: "package.json",
        contents: new Buffer(JSON.stringify(package, null, 4))
      }));
      this.push(null);
    };

    return src
  }<commit_msg>changes gulp file not to include version in compiled script<commit_after>var gulp = require('gulp');
var ts = require('gulp-typescript');
var uglify = require('gulp-uglify');
var webpack = require('webpack-stream');
var del = require('del');
var rename = require("gulp-rename");
var gutil = require('gulp-util');

var tsProject = ts.createProject('tsconfig.json');
///////////////////////////////////////////////////////
// CLEAN                                             //
///////////////////////////////////////////////////////
gulp.task('clean:all', function () {
    return del([
      'dist/**/*',
      'lib/**/*',
    ]);
  });

///////////////////////////////////////////////////////
// PATCH                                             //
///////////////////////////////////////////////////////

gulp.task('patch', ['clean:all'], function () {
    let projectAction = function(project) {
            project.version = process.env.version || project.version
            return project;
        };

    patchProject(projectAction)
        .pipe(gulp.dest('./'));
});

gulp.task('compile', ['patch', 'clean:all'], function () {

    let tsResult = tsProject.src()
                            .pipe(tsProject());

    return tsResult.js.pipe(gulp.dest('lib'));
});

gulp.task('copy', ['compile', 'webpack'], function() {
    gulp.src('./types/loxium.d.ts')
        .pipe(gulp.dest('./lib/'))
})

gulp.task('webpack', ['compile'], function () {

        return gulp.src('./lib/loxium.js')
            .pipe(webpack(require('./webpack.config.js')))
            .pipe(uglify())
            .pipe(rename(`loxium.min.js`))
            .pipe(gulp.dest(`dist/`));
    });

gulp.task('default', [ 'clean:all', 'patch', 'compile', 'webpack', 'copy' ]);

function patchProject(action) {
    let package = require('./package.json');

    package = action(package);

    let src = require('stream').Readable({ objectMode: true });

    src._read = function () {
      this.push(new gutil.File({
        cwd: "",
        base: "",
        path: "package.json",
        contents: new Buffer(JSON.stringify(package, null, 4))
      }));
      this.push(null);
    };

    return src
  }<|endoftext|>


<commit_before>var gulp        = require('gulp'),
    browserSync = require('browser-sync'),
    sass        = require('gulp-sass'),
    bower       = require('gulp-bower'),
    notify      = require('gulp-notify'),
    reload      = browserSync.reload,
    bs          = require("browser-sync").create(),
    Hexo = require('hexo'),
    hexo = new Hexo(process.cwd(), {});

var src = {
    scss: 'scss',
    css:  'source/css',
    ejs: 'layout'
};

// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {

    // init starts the server
    bs.init({
        baseDir: "../../public"
    });

    // hexo.call('generate', {}).then(function(){
    //   console.log('Generating Files');
    // });

    // Now call methods on bs instead of the
    // main browserSync module export
    bs.reload("*.html");
    bs.reload("*.css");
});

// Compile sass into CSS
gulp.task('sass', function() {
    gulp.src(src.scss)
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest(src.css))
        .pipe(reload({stream: true}));
});

gulp.task('sass:watch', function () {
  gulp.watch('./scss/**/*.scss', ['sass']);
});

gulp.task('bower', function() {
  return bower()
    .pipe(gulp.dest('source/lib'))
});

gulp.task('default', ['serve']);
<commit_msg>Update and fix sass gulp path<commit_after>var gulp        = require('gulp'),
    browserSync = require('browser-sync'),
    sass        = require('gulp-sass'),
    bower       = require('gulp-bower'),
    notify      = require('gulp-notify'),
    reload      = browserSync.reload,
    bs          = require("browser-sync").create(),
    Hexo = require('hexo'),
    hexo = new Hexo(process.cwd(), {});

var src = {
    scss: './scss/',
    css:  './source/css',
    ejs: 'layout'
};

// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {

    // init starts the server
    bs.init({
        baseDir: "../../public"
    });

    // hexo.call('generate', {}).then(function(){
    //   console.log('Generating Files');
    // });

    // Now call methods on bs instead of the
    // main browserSync module export
    bs.reload("*.html");
    bs.reload("*.css");
});

// Compile sass into CSS
gulp.task('sass', function() {
    // gulp.src(src.scss + "/*/*.scss")
    gulp.src(src.scss + "{,*}/*.scss")
        .pipe(sass({}))
        // .pipe(gulp.dest(src.css))
        .pipe(gulp.dest('./css/'))
        .pipe(reload({stream: true}));
});

gulp.task('sass:watch', function () {
  gulp.watch('./scss/**/*.scss', ['sass']);
});

gulp.task('bower', function() {
  return bower()
    .pipe(gulp.dest('source/lib'))
});

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


<commit_before>var gulp = require('gulp');
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var url = require('url');
var proxy = require('proxy-middleware');
var modRewrite = require('connect-modrewrite');
var reload = browserSync.reload;
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var sort = require('gulp-sort');
var addSrc = require('gulp-add-src');
var minifyCss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var ngHtml2Js = require("gulp-ng-html2js");
var minifyHtml = require("gulp-minify-html");
var Server = require('karma').Server;
var argv = require('yargs').argv;
var replace = require('gulp-replace');

var pkg = require('./package.json');

var cfg = require('./dev-config.json');

var paths = cfg.paths;

var cssDeps = [
    paths.lib + 'angular-ui-tree/dist/angular-ui-tree.css',
    paths.lib + 'font-awesome/css/font-awesome.min.css'
];

var jsDeps = [
    paths.lib + 'angular/angular.min.js',
    paths.lib + 'angular-ui-router/release/angular-ui-router.min.js',
    paths.lib + 'angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
    paths.lib + 'angular-ui-bootstrap/dist/ui-bootstrap.js',
    paths.lib + 'leaflet/dist/leaflet.js',
    paths.lib + 'angulartics/dist/angulartics.min.js',
    paths.lib + 'angulartics-google-analytics/dist/angulartics-google-analytics.min.js',
    paths.lib + 'angular-resource/angular-resource.min.js',
    paths.lib + 'angular-sanitize/angular-sanitize.min.js',
    paths.lib + 'angular-cookies/angular-cookies.min.js',
    paths.lib + 'idai-components/dist/idai-components.min.js',
    paths.lib + 'angular-ui-tree/dist/angular-ui-tree.min.js',
    paths.lib + 'showdown/dist/showdown.min.js',
    paths.lib + 'ng-showdown/dist/ng-showdown.min.js',
    paths.lib + '3dviewer/dist/3dviewer.js',
    'lib/relative-paths-in-partial.js'
];

// compile sass and concatenate to single css file in build dir
gulp.task('compile-css', function() {
	return gulp.src('scss/app.scss')
	  	.pipe(sass({
	  		includePaths: [
	  			paths.lib + 'bootstrap-sass/assets/stylesheets/',
	  			paths.lib + 'idai-components/src/scss/'
	  		],
	  		precision: 8
	  	}))
        .pipe(addSrc(cssDeps))
	  	.pipe(concat(pkg.name + '.css'))
	    .pipe(gulp.dest(paths.build + '/css'))
	    .pipe(reload({ stream:true }));
});

// minify css files in build dir
gulp.task('minify-css', ['compile-css'], function() {
	return gulp.src(paths.build + '/css/*.css')
		.pipe(minifyCss())
  		.pipe(concat(pkg.name + '.min.css'))
		.pipe(gulp.dest(paths.build + '/css'));
});

// concatenates all js files in src into a single file in build dir
gulp.task('concat-js', function() {
	return gulp.src(['js/**/*.js', '!js/app.js'])
		.pipe(sort())
		.pipe(addSrc.append('js/app.js'))
		.pipe(concat(pkg.name + '.js'))
		.pipe(gulp.dest(paths.build))
    	.pipe(reload({ stream:true }));
});

// concatenates and minifies all dependecies into a single file in build dir
gulp.task('concat-deps', function() {
	return gulp.src(jsDeps)
		.pipe(concat(pkg.name + '-deps.js'))
    	//.pipe(uglify())
		.pipe(gulp.dest(paths.build));
});

// minifies and concatenates js files in build dir
gulp.task('minify-js', ['concat-js', 'html2js'], function() {
	return gulp.src([paths.build + '/' + pkg.name + '.js',
			paths.build + '/' + pkg.name + '-tpls.js'])
		.pipe(concat(pkg.name + '.js'))
    	.pipe(gulp.dest(paths.build))
    	.pipe(uglify())
		.pipe(concat(pkg.name + '.min.js'))
    	.pipe(gulp.dest(paths.build));
});

// converts, minifies and concatenates html partials
// to a single js file in build dir
gulp.task('html2js', function() {
    return gulp.src('partials/**/*.html')
        .pipe(minifyHtml())
        .pipe(ngHtml2Js({ moduleName: 'arachne.templates', prefix: 'partials/' }))
        .pipe(concat(pkg.name + '-tpls.js'))
        .pipe(gulp.dest(paths.build));
});

gulp.task('copy-resources', ['copy-fonts', 'copy-imgs', 'copy-index', 'copy-info', 'copy-con10t', 'copy-config']);

gulp.task('copy-fonts', function() {
	var bsFontPath = paths.lib + 'bootstrap-sass/assets/fonts/';
	return gulp.src([paths.lib + 'font-awesome/fonts/**', bsFontPath + '**/*'])
  		.pipe(gulp.dest(paths.build + '/fonts'));
});

gulp.task('copy-imgs', function() {
    return gulp.src('img/**/*', { base: 'img' })
        .pipe(gulp.dest(paths.build + '/img'));
});

// copy index.html to dist and set version
gulp.task('copy-index', function() {
    var buildNo = "SNAPSHOT";
    if (argv.build) buildNo = argv.build;
    var versionString = pkg.version + " (build #" + buildNo + ")";
    gulp.src(['index.html'])
        .pipe(replace(/version="[^"]*"/g, 'version="v' + versionString + '"'))
        .pipe(replace(/build=BUILD_NO/g, 'build=' + buildNo))
        .pipe(gulp.dest(paths.build));
});

gulp.task('copy-info', function() {
    return gulp.src('info/**/*', { base: 'info' })
        .pipe(gulp.dest(paths.build + '/info'));
});

gulp.task('copy-config', function() {
    return gulp.src('config/**/*', { base: 'config' })
        .pipe(gulp.dest(paths.build + '/config'));
});

gulp.task('copy-con10t', function() {
    return gulp.src('con10t/**/*', { base: 'con10t' })
        .pipe(gulp.dest(paths.build + '/con10t'));
});

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

gulp.task('build', [
	'minify-css',
	'concat-deps',
	'minify-js',
	'copy-resources'
]);

// clean
gulp.task('clean', function() {
	return del(paths.build + '/**/*');
});

// runs the development server and sets up browser reloading
gulp.task('server', ['compile-css', 'minify-js', 'concat-deps', 'copy-resources'], function() {
	var proxyOptions = url.parse(cfg.backendUri);
    proxyOptions.route = '/data';

	browserSync({
		server: {
			baseDir: 'dist',
        	middleware: [
        		proxy(proxyOptions),
        		// rewrite for AngularJS HTML5 mode, redirect all non-file urls to index.html
				modRewrite(['!\\.html|\\.js|\\.svg|\\.css|\\.png|\\.jpg|\\.gif|\\.json|\\.woff2|\\.woff|\\.ttf$ /index.html [L]']),
        	]
		},
		port: 1234
	});

	gulp.watch('scss/**/*.scss', ['compile-css']);
	gulp.watch('js/**/*.js', ['minify-js']);
    gulp.watch('partials/**/*.html', ['minify-js']);
    gulp.watch('index.html', ['copy-index']);
    gulp.watch('con10t/**/*', ['copy-con10t']);

	gulp.watch(['index.html', 'partials/**/*.html', 'js/**/*.js'], reload);
});

gulp.task('default', function() {
	runSequence('clean', 'test', 'build');
});<commit_msg>readd depedency to leaflet markers cluster (fixes #3157)<commit_after>var gulp = require('gulp');
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var url = require('url');
var proxy = require('proxy-middleware');
var modRewrite = require('connect-modrewrite');
var reload = browserSync.reload;
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var sort = require('gulp-sort');
var addSrc = require('gulp-add-src');
var minifyCss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var ngHtml2Js = require("gulp-ng-html2js");
var minifyHtml = require("gulp-minify-html");
var Server = require('karma').Server;
var argv = require('yargs').argv;
var replace = require('gulp-replace');

var pkg = require('./package.json');

var cfg = require('./dev-config.json');

var paths = cfg.paths;

var cssDeps = [
    paths.lib + 'angular-ui-tree/dist/angular-ui-tree.css',
    paths.lib + 'font-awesome/css/font-awesome.min.css'
];

var jsDeps = [
    paths.lib + 'angular/angular.min.js',
    paths.lib + 'angular-ui-router/release/angular-ui-router.min.js',
    paths.lib + 'angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
    paths.lib + 'angular-ui-bootstrap/dist/ui-bootstrap.js',
    paths.lib + 'leaflet/dist/leaflet.js',
    paths.lib + 'leaflet.markercluster/dist/leaflet.markercluster.js',
    paths.lib + 'angulartics/dist/angulartics.min.js',
    paths.lib + 'angulartics-google-analytics/dist/angulartics-google-analytics.min.js',
    paths.lib + 'angular-resource/angular-resource.min.js',
    paths.lib + 'angular-sanitize/angular-sanitize.min.js',
    paths.lib + 'angular-cookies/angular-cookies.min.js',
    paths.lib + 'idai-components/dist/idai-components.min.js',
    paths.lib + 'angular-ui-tree/dist/angular-ui-tree.min.js',
    paths.lib + 'showdown/dist/showdown.min.js',
    paths.lib + 'ng-showdown/dist/ng-showdown.min.js',
    paths.lib + '3dviewer/dist/3dviewer.js',
    'lib/relative-paths-in-partial.js'
];

// compile sass and concatenate to single css file in build dir
gulp.task('compile-css', function() {
	return gulp.src('scss/app.scss')
	  	.pipe(sass({
	  		includePaths: [
	  			paths.lib + 'bootstrap-sass/assets/stylesheets/',
	  			paths.lib + 'idai-components/src/scss/'
	  		],
	  		precision: 8
	  	}))
        .pipe(addSrc(cssDeps))
	  	.pipe(concat(pkg.name + '.css'))
	    .pipe(gulp.dest(paths.build + '/css'))
	    .pipe(reload({ stream:true }));
});

// minify css files in build dir
gulp.task('minify-css', ['compile-css'], function() {
	return gulp.src(paths.build + '/css/*.css')
		.pipe(minifyCss())
  		.pipe(concat(pkg.name + '.min.css'))
		.pipe(gulp.dest(paths.build + '/css'));
});

// concatenates all js files in src into a single file in build dir
gulp.task('concat-js', function() {
	return gulp.src(['js/**/*.js', '!js/app.js'])
		.pipe(sort())
		.pipe(addSrc.append('js/app.js'))
		.pipe(concat(pkg.name + '.js'))
		.pipe(gulp.dest(paths.build))
    	.pipe(reload({ stream:true }));
});

// concatenates and minifies all dependecies into a single file in build dir
gulp.task('concat-deps', function() {
	return gulp.src(jsDeps)
		.pipe(concat(pkg.name + '-deps.js'))
    	//.pipe(uglify())
		.pipe(gulp.dest(paths.build));
});

// minifies and concatenates js files in build dir
gulp.task('minify-js', ['concat-js', 'html2js'], function() {
	return gulp.src([paths.build + '/' + pkg.name + '.js',
			paths.build + '/' + pkg.name + '-tpls.js'])
		.pipe(concat(pkg.name + '.js'))
    	.pipe(gulp.dest(paths.build))
    	.pipe(uglify())
		.pipe(concat(pkg.name + '.min.js'))
    	.pipe(gulp.dest(paths.build));
});

// converts, minifies and concatenates html partials
// to a single js file in build dir
gulp.task('html2js', function() {
    return gulp.src('partials/**/*.html')
        .pipe(minifyHtml())
        .pipe(ngHtml2Js({ moduleName: 'arachne.templates', prefix: 'partials/' }))
        .pipe(concat(pkg.name + '-tpls.js'))
        .pipe(gulp.dest(paths.build));
});

gulp.task('copy-resources', ['copy-fonts', 'copy-imgs', 'copy-index', 'copy-info', 'copy-con10t', 'copy-config']);

gulp.task('copy-fonts', function() {
	var bsFontPath = paths.lib + 'bootstrap-sass/assets/fonts/';
	return gulp.src([paths.lib + 'font-awesome/fonts/**', bsFontPath + '**/*'])
  		.pipe(gulp.dest(paths.build + '/fonts'));
});

gulp.task('copy-imgs', function() {
    return gulp.src('img/**/*', { base: 'img' })
        .pipe(gulp.dest(paths.build + '/img'));
});

// copy index.html to dist and set version
gulp.task('copy-index', function() {
    var buildNo = "SNAPSHOT";
    if (argv.build) buildNo = argv.build;
    var versionString = pkg.version + " (build #" + buildNo + ")";
    gulp.src(['index.html'])
        .pipe(replace(/version="[^"]*"/g, 'version="v' + versionString + '"'))
        .pipe(replace(/build=BUILD_NO/g, 'build=' + buildNo))
        .pipe(gulp.dest(paths.build));
});

gulp.task('copy-info', function() {
    return gulp.src('info/**/*', { base: 'info' })
        .pipe(gulp.dest(paths.build + '/info'));
});

gulp.task('copy-config', function() {
    return gulp.src('config/**/*', { base: 'config' })
        .pipe(gulp.dest(paths.build + '/config'));
});

gulp.task('copy-con10t', function() {
    return gulp.src('con10t/**/*', { base: 'con10t' })
        .pipe(gulp.dest(paths.build + '/con10t'));
});

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

gulp.task('build', [
	'minify-css',
	'concat-deps',
	'minify-js',
	'copy-resources'
]);

// clean
gulp.task('clean', function() {
	return del(paths.build + '/**/*');
});

// runs the development server and sets up browser reloading
gulp.task('server', ['compile-css', 'minify-js', 'concat-deps', 'copy-resources'], function() {
	var proxyOptions = url.parse(cfg.backendUri);
    proxyOptions.route = '/data';

	browserSync({
		server: {
			baseDir: 'dist',
        	middleware: [
        		proxy(proxyOptions),
        		// rewrite for AngularJS HTML5 mode, redirect all non-file urls to index.html
				modRewrite(['!\\.html|\\.js|\\.svg|\\.css|\\.png|\\.jpg|\\.gif|\\.json|\\.woff2|\\.woff|\\.ttf$ /index.html [L]']),
        	]
		},
		port: 1234
	});

	gulp.watch('scss/**/*.scss', ['compile-css']);
	gulp.watch('js/**/*.js', ['minify-js']);
    gulp.watch('partials/**/*.html', ['minify-js']);
    gulp.watch('index.html', ['copy-index']);
    gulp.watch('con10t/**/*', ['copy-con10t']);

	gulp.watch(['index.html', 'partials/**/*.html', 'js/**/*.js'], reload);
});

gulp.task('default', function() {
	runSequence('clean', 'test', 'build');
});<|endoftext|>


<commit_before>var gulp        = require('gulp'),
	plumber     = require('gulp-plumber'),
	browserSync = require('browser-sync'),
	stylus      = require('gulp-stylus'),
	uglify      = require('gulp-uglify'),
	concat      = require('gulp-concat'),
	jeet        = require('jeet'),
	rupture     = require('rupture'),
	koutoSwiss  = require('kouto-swiss'),
	prefixer    = require('autoprefixer-stylus'),
	imagemin    = require('gulp-imagemin'),
	cp          = require('child_process');

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

/**
 * Build the Jekyll Site
 */
gulp.task('jekyll-build', function (done) {
	browserSync.notify(messages.jekyllBuild);
	return cp.spawn("bundle", ['exec','jekyll','build'], {stdio: 'inherit'})
		.on('close', done);
});

/**
 * Rebuild Jekyll & do page reload
 */
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
	browserSync.reload();
});

/**
 * Wait for jekyll-build, then launch the Server
 */
gulp.task('browser-sync', ['jekyll-build'], function() {
	browserSync({
		server: {
			baseDir: '_site'
		}
	});
});

/**
 * Stylus task
 */
gulp.task('stylus', function(){
		gulp.src('src/styl/main.styl')
		.pipe(plumber())
		.pipe(stylus({
			use:[koutoSwiss(), prefixer(), jeet(),rupture()],
			compress: true
		}))
		.pipe(gulp.dest('_site/assets/css/'))
		.pipe(browserSync.reload({stream:true}))
    .pipe(gulp.dest('assets/css'));
});

/**
 * Javascript Task
 */
gulp.task('js', function(){
	return gulp.src('src/js/**/*.js')
		.pipe(plumber())
		.pipe(concat('main.js'))
		.pipe(uglify())
		.pipe(gulp.dest('assets/js/'))
		.pipe(browserSync.reload({stream:true}))
    .pipe(gulp.dest('_site/assets/js/'));
});

/**
 * Imagemin Task
 */
gulp.task('imagemin', function() {
	return gulp.src('src/img/**/*.{jpg,png,gif}')
		.pipe(plumber())
		.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
		.pipe(gulp.dest('assets/img/'));
});

/**
 * Watch stylus files for changes & recompile
 * Watch html/md files, run jekyll & reload BrowserSync
 */
gulp.task('watch', function () {
	gulp.watch('src/styl/**/*.styl', ['stylus']);
	gulp.watch('src/js/**/*.js', ['js']);
	gulp.watch('src/img/**/*.{jpg,png,gif}', ['imagemin']);
	gulp.watch(['*.html', '_includes/*.html', '_layouts/*.html', '_posts/*'], ['jekyll-rebuild']);
});

/**
 * Default task, running just `gulp` will compile the sass,
 * compile the jekyll site, launch BrowserSync & watch files.
 */
gulp.task('default', ['js', 'stylus', 'browser-sync', 'watch']);
<commit_msg>Watch config file for changes too<commit_after>var gulp        = require('gulp'),
	plumber     = require('gulp-plumber'),
	browserSync = require('browser-sync'),
	stylus      = require('gulp-stylus'),
	uglify      = require('gulp-uglify'),
	concat      = require('gulp-concat'),
	jeet        = require('jeet'),
	rupture     = require('rupture'),
	koutoSwiss  = require('kouto-swiss'),
	prefixer    = require('autoprefixer-stylus'),
	imagemin    = require('gulp-imagemin'),
	cp          = require('child_process');

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

/**
 * Build the Jekyll Site
 */
gulp.task('jekyll-build', function (done) {
	browserSync.notify(messages.jekyllBuild);
	return cp.spawn("bundle", ['exec','jekyll','build'], {stdio: 'inherit'})
		.on('close', done);
});

/**
 * Rebuild Jekyll & do page reload
 */
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
	browserSync.reload();
});

/**
 * Wait for jekyll-build, then launch the Server
 */
gulp.task('browser-sync', ['jekyll-build'], function() {
	browserSync({
		server: {
			baseDir: '_site'
		}
	});
});

/**
 * Stylus task
 */
gulp.task('stylus', function(){
		gulp.src('src/styl/main.styl')
		.pipe(plumber())
		.pipe(stylus({
			use:[koutoSwiss(), prefixer(), jeet(),rupture()],
			compress: true
		}))
		.pipe(gulp.dest('_site/assets/css/'))
		.pipe(browserSync.reload({stream:true}))
    .pipe(gulp.dest('assets/css'));
});

/**
 * Javascript Task
 */
gulp.task('js', function(){
	return gulp.src('src/js/**/*.js')
		.pipe(plumber())
		.pipe(concat('main.js'))
		.pipe(uglify())
		.pipe(gulp.dest('assets/js/'))
		.pipe(browserSync.reload({stream:true}))
    .pipe(gulp.dest('_site/assets/js/'));
});

/**
 * Imagemin Task
 */
gulp.task('imagemin', function() {
	return gulp.src('src/img/**/*.{jpg,png,gif}')
		.pipe(plumber())
		.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
		.pipe(gulp.dest('assets/img/'));
});

/**
 * Watch stylus files for changes & recompile
 * Watch html/md files, run jekyll & reload BrowserSync
 */
gulp.task('watch', function () {
	gulp.watch('src/styl/**/*.styl', ['stylus']);
	gulp.watch('src/js/**/*.js', ['js']);
	gulp.watch('src/img/**/*.{jpg,png,gif}', ['imagemin']);
	gulp.watch(['*.html', '_includes/*.html', '_layouts/*.html', '_posts/*', '_config.yml'], ['jekyll-rebuild']);
});

/**
 * Default task, running just `gulp` will compile the sass,
 * compile the jekyll site, launch BrowserSync & watch files.
 */
gulp.task('default', ['js', 'stylus', 'browser-sync', 'watch']);
<|endoftext|>


<commit_before>var path = require('path')
var gulp = require('gulp')
var runSequence = require('run-sequence')
var gutil = require('gulp-util')
var webpack = require('webpack')
var del = require('del')
var babel = require("gulp-babel")

var PATH = {
  SRC: path.join(__dirname, './src'),
  DIST: path.join(__dirname, './dist')
}

gulp.task('build:clean', function() {
  return del(path.join(PATH.DIST, './**/*'))
})

gulp.task('build:client:compile', function(callback) {
  webpack(require('./webpack.prod.config'), function(err, stats) {
    if (err) {
      throw new gutil.PluginError('webpack', err)
    }
    gutil.log('[webpack]', stats.toString({ colors: true }))
    callback()
  })
})

gulp.task('build:client:copy', function() {
  return gulp.src(path.join(PATH.SRC, './server/public/**/*'))
  .pipe(gulp.dest(path.join(PATH.DIST, './public')))
})

gulp.task('build:client:del', function() {
  return del([
    path.join(PATH.SRC, './server/public/javascripts/main-app.js'),
    path.join(PATH.SRC, './server/public/javascripts/share-app.js')
  ])
})

gulp.task('build:client', function(callback) {
  runSequence(
    'build:client:compile',
    'build:client:copy',
    'build:client:del',
    callback
  )
})

gulp.task('build:server', function() {
  return gulp.src([
    path.join(PATH.SRC, './server/**/*.js'),
    '!' + path.join(PATH.SRC, './server/public/**/*'),
    '!' + path.join(PATH.SRC, './server/index.dev.js')
  ])
  .pipe(babel())
  .pipe(gulp.dest(PATH.DIST))
})

gulp.task('build:copy-package', function() {
  return gulp.src(path.join(__dirname, './package.json'))
  .pipe(gulp.dest(PATH.DIST))
})

gulp.task('build:copy-views', function() {
  return gulp.src(path.join(PATH.SRC, './server/views/**/*'))
  .pipe(gulp.dest(path.join(PATH.DIST, './views')))
})

gulp.task('build', function(callback) {
  runSequence(
    'build:clean',
    ['build:client', 'build:server'],
    ['build:copy-package', 'build:copy-views'],
    callback
  )
})
<commit_msg>补充gulpfile遗漏的部分<commit_after>var path = require('path')
var gulp = require('gulp')
var runSequence = require('run-sequence')
var gutil = require('gulp-util')
var webpack = require('webpack')
var del = require('del')
var babel = require("gulp-babel")

var PATH = {
  SRC: path.join(__dirname, './src'),
  DIST: path.join(__dirname, './dist')
}

gulp.task('build:clean', function() {
  return del(path.join(PATH.DIST, './**/*'))
})

gulp.task('build:client:compile', function(callback) {
  webpack(require('./webpack.prod.config'), function(err, stats) {
    if (err) {
      throw new gutil.PluginError('webpack', err)
    }
    gutil.log('[webpack]', stats.toString({ colors: true }))
    callback()
  })
})

gulp.task('build:client:copy', function() {
  return gulp.src(path.join(PATH.SRC, './server/public/**/*'))
  .pipe(gulp.dest(path.join(PATH.DIST, './public')))
})

gulp.task('build:client:del', function() {
  return del([
    path.join(PATH.SRC, './server/public/javascripts/main-app.js'),
    path.join(PATH.SRC, './server/public/javascripts/share-app.js'),
    path.join(PATH.SRC, './server/public/stylesheets/main-app.css'),
    path.join(PATH.SRC, './server/public/stylesheets/share-app.css')
  ])
})

gulp.task('build:client', function(callback) {
  runSequence(
    'build:client:compile',
    'build:client:copy',
    'build:client:del',
    callback
  )
})

gulp.task('build:server', function() {
  return gulp.src([
    path.join(PATH.SRC, './server/**/*.js'),
    '!' + path.join(PATH.SRC, './server/public/**/*'),
    '!' + path.join(PATH.SRC, './server/index.dev.js')
  ])
  .pipe(babel())
  .pipe(gulp.dest(PATH.DIST))
})

gulp.task('build:copy-package', function() {
  return gulp.src(path.join(__dirname, './package.json'))
  .pipe(gulp.dest(PATH.DIST))
})

gulp.task('build:copy-views', function() {
  return gulp.src(path.join(PATH.SRC, './server/views/**/*'))
  .pipe(gulp.dest(path.join(PATH.DIST, './views')))
})

gulp.task('build', function(callback) {
  runSequence(
    'build:clean',
    ['build:client', 'build:server'],
    ['build:copy-package', 'build:copy-views'],
    callback
  )
})
<|endoftext|>


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

var config = require('./gulp/config');
var clean = require('./gulp/clean');
var downloadLocales = require('./gulp/download-locales');
var locale = require('./gulp/locale');
var browserify = require('./gulp/browserify');
var less = require('./gulp/less');
var cache = require('./gulp/cache');
var publish = require('./gulp/publish');

var jshint = require('./gulp/jshint');
var jscs = require('./gulp/jscs');
var unit = require('./gulp/unit');

// Config
gulp.task('config', config);

// Build
gulp.task('clean', ['config'], clean);
gulp.task('download-locales', ['clean'], downloadLocales);
gulp.task('locale', ['download-locales'], locale);

gulp.task('less', ['clean'], less);
gulp.task('browserify', ['clean', 'locale'], browserify);
gulp.task('publish', ['less', 'locale'], publish);
gulp.task('build', ['less', 'browserify', 'publish'], cache);

gulp.task('re-locale', ['clean'], locale);
gulp.task('re-browserify', ['clean', 're-locale'], browserify);
gulp.task('re-publish', ['less', 're-locale'], publish);
gulp.task('re-build', ['less', 're-browserify', 're-publish'], cache);

// Test
gulp.task('jshint', jshint);
gulp.task('jscs', jscs);
gulp.task('lint', ['jshint', 'jscs']);
gulp.task('unit', unit);
gulp.task('test', ['lint', 'unit']);

// Watch
gulp.task('watch', ['build'], function () {
    gulp.watch([
        './{blocks,components,lib,static,views,publish}/**/*.{js,json,less,html}',
        './locale/en_US/*.json',
        './config/*.env',
        '.env'
    ],['re-build']);
});

// Serve + Watch
gulp.task('dev', ['watch'], function() {
  gulp.src('build')
    .pipe(webserver({
        port: 8080,
        livereload: true,
        open: true,
        fallback: 'index.html'
    }));
});
<commit_msg>make sure tests can pass, build before tests<commit_after>var gulp = require('gulp');
var webserver = require('gulp-webserver');

var config = require('./gulp/config');
var clean = require('./gulp/clean');
var downloadLocales = require('./gulp/download-locales');
var locale = require('./gulp/locale');
var browserify = require('./gulp/browserify');
var less = require('./gulp/less');
var cache = require('./gulp/cache');
var publish = require('./gulp/publish');

var jshint = require('./gulp/jshint');
var jscs = require('./gulp/jscs');
var unit = require('./gulp/unit');

// Config
gulp.task('config', config);

// Build
gulp.task('clean', ['config'], clean);
gulp.task('download-locales', ['clean'], downloadLocales);
gulp.task('locale', ['download-locales'], locale);

gulp.task('less', ['clean'], less);
gulp.task('browserify', ['clean', 'locale'], browserify);
gulp.task('publish', ['less', 'locale'], publish);
gulp.task('build', ['less', 'browserify', 'publish'], cache);

gulp.task('re-locale', ['clean'], locale);
gulp.task('re-browserify', ['clean', 're-locale'], browserify);
gulp.task('re-publish', ['less', 're-locale'], publish);
gulp.task('re-build', ['less', 're-browserify', 're-publish'], cache);

// Test
gulp.task('jshint', jshint);
gulp.task('jscs', jscs);
gulp.task('lint', ['jshint', 'jscs']);
gulp.task('unit', ['re-build'], unit);
gulp.task('test', ['lint', 'unit']);

// Watch
gulp.task('watch', ['build'], function () {
    gulp.watch([
        './{blocks,components,lib,static,views,publish}/**/*.{js,json,less,html}',
        './locale/en_US/*.json',
        './config/*.env',
        '.env'
    ],['re-build']);
});

// Serve + Watch
gulp.task('dev', ['watch'], function() {
  gulp.src('build')
    .pipe(webserver({
        port: 8080,
        livereload: true,
        open: true,
        fallback: 'index.html'
    }));
});
<|endoftext|>