<commit_before>/* eslint-disable no-var */
/* eslint-disable prefer-arrow-callback */
/* eslint-disable prefer-template */

var gulp          = require('gulp');
var gutil         = require('gulp-util');
var notifier      = require('node-notifier');
var browserSync   = require('browser-sync');
var webpack       = require('webpack');
var eslint        = require('gulp-eslint');
var filter        = require('gulp-filter');
var rename        = require('gulp-rename');
var shell         = require('gulp-shell');
var runSequence   = require('run-sequence');
var assign        = require('lodash.assign');

var sharedWebpackConfig = {
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /dist|public|node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'react', 'stage-2']
        }
      }
    ]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  watch: false
};

var libWebpackConfig = assign({}, sharedWebpackConfig, {
  entry: './src/index.js',
  output: {
    path: './lib',
    filename: 'react-brickwork.js',
    library: 'reactBrickwork',
    libraryTarget: 'umd'
  },
  externals: {
    'react': 'react',
    'react-dom': 'react-dom',
    'react-addons-transition-group': 'react-addons-transition-group',
    'react-motion': 'react-motion',
    'enquire.js': 'enquire.js',
    'lodash.isequal': 'lodash.isequal',
    'lodash.partition': 'lodash.partition'
  }
});

var demoWebpackConfig = assign({}, sharedWebpackConfig, {
  entry: './demo/src/main.js',
  output: {
    path: './demo/public',
    filename: 'demo.js'
  }
});

// var devCompiler = webpack([
//   assign({}, libWebpackConfig, { devtool: 'inline-source-map' }),
//   assign({}, demoWebpackConfig, { devtool: 'inline-source-map' })
// ]);

var devCompiler = webpack([libWebpackConfig, demoWebpackConfig]);

gulp.task('webpack', function(done) {
  var firstTime = true;

  devCompiler.watch({
    aggregateTimeout: 100
  }, function(err, stats) {
    if (err) {
      notifier.notify({ title: 'Webpack Error', message: err });
      throw new gutil.PluginError('webpack', err);
    }

    var jsonStats = stats.toJson();

    if (jsonStats.errors.length > 0) {
      notifier.notify({ title: 'Webpack Error', message: jsonStats.errors[0] });
    } else if (jsonStats.warnings.length > 0) {
      notifier.notify({ title: 'Webpack Warning', message: jsonStats.warnings[0] });
    }

    gutil.log(gutil.colors.cyan('[webpack]'), stats.toString({
      chunks: false,
      version: false,
      colors: true
    }));

    if (jsonStats.assets[0].name === 'demo.js') {
      browserSync.reload();

      if (firstTime) {
        firstTime = false;
        done();
      }
    }
  });
});

gulp.task('browser-sync', ['webpack', 'demo-html-css'], function() {
  browserSync({
    notify: false,
    server: {
      baseDir: 'demo/public'
    }
  });
});

gulp.task('demo-html-css', function() {
  var sliderCssFilter = filter('node_modules/rc-slider/assets/index.css',
                               { restore: true });

  return gulp.src(['demo/src/*.@(html|css)',
    'node_modules/rc-slider/assets/index.css'])
    .pipe(sliderCssFilter)
    .pipe(rename('rc-slider.css'))
    .pipe(sliderCssFilter.restore)
    .pipe(gulp.dest('demo/public'))
    .pipe(browserSync.reload({ stream: true }));
});

gulp.task('watch', function() {
  gulp.watch('src/js/**/*', function(e) {
    gutil.log(gutil.colors.magenta(
      e.path.substring(e.path.lastIndexOf('/') + 1)) + ' ' +
      gutil.colors.cyan(e.type + '...'));
  });

  gulp.watch('demo/src/*.@(html|css)', ['demo-html-css']);
});

gulp.task('gh-pages-start', shell.task([
  'git stash',
  'git checkout gh-pages'
]));

gulp.task('gh-pages-middle', function() {
  return gulp.src('./demo/public/**/*')
    .pipe(gulp.dest('./'));
});

gulp.task('gh-pages-end', shell.task([
  'git add *.html',
  'git add *.css',
  'git add *.js',
  'git commit --amend --no-edit',
  'git checkout master',
  'git stash apply'
]));

gulp.task('gh-pages', function(done) {
  runSequence('gh-pages-start', 'gh-pages-middle', 'gh-pages-end', done);
});

gulp.task('lint', function() {
  return gulp.src(['src/**/*.js*(x)', 'demo/src/**/*.js*(x)'])
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

gulp.task('default', ['browser-sync', 'watch']);
<commit_msg>Improving gh-pages build<commit_after>/* eslint-disable no-var */
/* eslint-disable prefer-arrow-callback */
/* eslint-disable prefer-template */

var gulp          = require('gulp');
var gutil         = require('gulp-util');
var notifier      = require('node-notifier');
var browserSync   = require('browser-sync');
var webpack       = require('webpack');
var eslint        = require('gulp-eslint');
var filter        = require('gulp-filter');
var rename        = require('gulp-rename');
var shell         = require('gulp-shell');
var runSequence   = require('run-sequence');
var assign        = require('lodash.assign');

var sharedWebpackConfig = {
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /dist|public|node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'react', 'stage-2']
        }
      }
    ]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  watch: false
};

var libWebpackConfig = assign({}, sharedWebpackConfig, {
  entry: './src/index.js',
  output: {
    path: './lib',
    filename: 'react-brickwork.js',
    library: 'reactBrickwork',
    libraryTarget: 'umd'
  },
  externals: {
    'react': 'react',
    'react-dom': 'react-dom',
    'react-addons-transition-group': 'react-addons-transition-group',
    'react-motion': 'react-motion',
    'enquire.js': 'enquire.js',
    'lodash.isequal': 'lodash.isequal',
    'lodash.partition': 'lodash.partition'
  }
});

var demoWebpackConfig = assign({}, sharedWebpackConfig, {
  entry: './demo/src/main.js',
  output: {
    path: './demo/public',
    filename: 'demo.js'
  }
});

// var devCompiler = webpack([
//   assign({}, libWebpackConfig, { devtool: 'inline-source-map' }),
//   assign({}, demoWebpackConfig, { devtool: 'inline-source-map' })
// ]);

var devCompiler = webpack([libWebpackConfig, demoWebpackConfig]);

gulp.task('webpack', function(done) {
  var firstTime = true;

  devCompiler.watch({
    aggregateTimeout: 100
  }, function(err, stats) {
    if (err) {
      notifier.notify({ title: 'Webpack Error', message: err });
      throw new gutil.PluginError('webpack', err);
    }

    var jsonStats = stats.toJson();

    if (jsonStats.errors.length > 0) {
      notifier.notify({ title: 'Webpack Error', message: jsonStats.errors[0] });
    } else if (jsonStats.warnings.length > 0) {
      notifier.notify({ title: 'Webpack Warning', message: jsonStats.warnings[0] });
    }

    gutil.log(gutil.colors.cyan('[webpack]'), stats.toString({
      chunks: false,
      version: false,
      colors: true
    }));

    if (jsonStats.assets[0].name === 'demo.js') {
      browserSync.reload();

      if (firstTime) {
        firstTime = false;
        done();
      }
    }
  });
});

gulp.task('browser-sync', ['webpack', 'demo-html-css'], function() {
  browserSync({
    notify: false,
    server: {
      baseDir: 'demo/public'
    }
  });
});

gulp.task('demo-html-css', function() {
  var sliderCssFilter = filter('node_modules/rc-slider/assets/index.css',
                               { restore: true });

  return gulp.src(['demo/src/*.@(html|css)',
    'node_modules/rc-slider/assets/index.css'])
    .pipe(sliderCssFilter)
    .pipe(rename('rc-slider.css'))
    .pipe(sliderCssFilter.restore)
    .pipe(gulp.dest('demo/public'))
    .pipe(browserSync.reload({ stream: true }));
});

gulp.task('watch', function() {
  gulp.watch('src/js/**/*', function(e) {
    gutil.log(gutil.colors.magenta(
      e.path.substring(e.path.lastIndexOf('/') + 1)) + ' ' +
      gutil.colors.cyan(e.type + '...'));
  });

  gulp.watch('demo/src/*.@(html|css)', ['demo-html-css']);
});

gulp.task('gh-pages-start', shell.task([
  'git stash',
  'git checkout gh-pages'
]));

gulp.task('gh-pages-middle', function() {
  return gulp.src('./demo/public/**/*')
    .pipe(gulp.dest('./'));
});

gulp.task('gh-pages-end', shell.task([
  'git add index.html demo.js *.css',
  'git commit --amend --no-edit',
  'git push origin gh-pages --force',
  'git checkout master',
  'git stash apply'
]));

gulp.task('gh-pages', function(done) {
  runSequence('gh-pages-start', 'gh-pages-middle', 'gh-pages-end', done);
});

gulp.task('lint', function() {
  return gulp.src(['src/**/*.js*(x)', 'demo/src/**/*.js*(x)'])
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

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


<commit_before>var gulp = require("gulp"),
   concat = require("gulp-concat"),
   uglify = require("gulp-uglify"),
   less = require("gulp-less"),
   min = require("gulp-clean-css"),
   postCSS = require("gulp-postcss"),
   autoprefixer = require("autoprefixer"),
   browserSync = require("browser-sync").create(),
   order = require('gulp-order'),
   plumber = require("gulp-plumber");

gulp.task("js", function () {
  return gulp.watch("js/*.js", function () {
    gulp.src(["js/*.js", "js/lib/x2js-v1.1.5/xml2json.min.js"])
      .pipe(order([
        'xml2json.min.js',
        'jasper.js',
        'event.js',
        'asset.js',
        'entity.js',
        'controller.js',
        'graphics.js',
        'init.js'
        ]))
      .pipe(plumber())
      .pipe(concat("jasper.js"))
      .pipe(gulp.dest("js/test/"))
      .pipe(gulp.dest("js/dist/"))

    gulp.src("js/dist/jasper.js")
      .pipe(concat("jasper.min.js"))
      .pipe(uglify())
      .pipe(gulp.dest("."))
      .pipe(gulp.dest("../test"));
  });
});

//todo: add a task to use browser-sync for dev purposes

gulp.task("css", function () {
  return gulp.watch("style/less/*.less", function () {
    gulp.src("style/less/*.less")
      .pipe(plumber())
      .pipe(less())
      .pipe(postCSS([autoprefixer({version: ['last 2 versions']})]))
      .pipe(min())
      .pipe(gulp.dest("style/css/"));
  });
});

gulp.task("default", ["js", "css"]);<commit_msg>issue with gulp destinations for minified js<commit_after>var gulp = require("gulp"),
   concat = require("gulp-concat"),
   uglify = require("gulp-uglify"),
   less = require("gulp-less"),
   min = require("gulp-clean-css"),
   postCSS = require("gulp-postcss"),
   autoprefixer = require("autoprefixer"),
   browserSync = require("browser-sync").create(),
   order = require('gulp-order'),
   plumber = require("gulp-plumber");

gulp.task("js", function () {
  return gulp.watch("js/*.js", function () {
    gulp.src(["js/*.js", "js/lib/x2js-v1.1.5/xml2json.min.js"])
      .pipe(order([
        'xml2json.min.js',
        'jasper.js',
        'event.js',
        'asset.js',
        'entity.js',
        'controller.js',
        'graphics.js',
        'init.js'
        ]))
      .pipe(plumber())
      .pipe(concat("jasper.js"))
      .pipe(gulp.dest("js/test/"))
      .pipe(gulp.dest("js/dist/"))

    gulp.src("js/dist/jasper.js")
      .pipe(concat("jasper.min.js"))
      .pipe(uglify())
      .pipe(gulp.dest("js/dist/"))
      .pipe(gulp.dest("js/test/"));
  });
});

//todo: add a task to use browser-sync for dev purposes

gulp.task("css", function () {
  return gulp.watch("style/less/*.less", function () {
    gulp.src("style/less/*.less")
      .pipe(plumber())
      .pipe(less())
      .pipe(postCSS([autoprefixer({version: ['last 2 versions']})]))
      .pipe(min())
      .pipe(gulp.dest("style/css/"));
  });
});

gulp.task("default", ["js", "css"]);<|endoftext|>


<commit_before>'use strict';

var gulp        = require('gulp'),
	browserSync = require('browser-sync').create(),
	SSI 		= require('browsersync-ssi'),
	minifyCss   = require('gulp-clean-css'),
	minify   	= require('gulp-minify'),
	plumber     = require('gulp-plumber'),
	sass        = require('gulp-sass'),
	Tmaker      = require('gulp-tmaker'),
	rm      	= require('gulp-rm'),
	yargs      	= require('yargs'),
	wjson		= require('write-json'),
	verAppend 	= require('gulp-version-number'),
	fs			= require('fs'),
	useref		= require('gulp-useref'),
	gulpif 		= require('gulp-if'),
	projectInfo	= require('./projectInfo.json');

var switchProjectName = '_init',
	archiveName = '_init';

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

	browserSync.init({
		server: {
			baseDir:["./dist"],
			middleware:SSI({
				baseDir:'./dist',
				ext:'.shtml',
				version:'2.10.0'
			})
		}
	});

	gulp.watch("app/scss/**/*.scss", ['sass']);
	gulp.watch("app/scss/*.+(jpg|png|gif)", ['asset']);
	gulp.watch("app/data/*.*", ['preview-data']);
	gulp.watch("app/scripts/**/*.js", ['js']);
	gulp.watch("app/**/*.html", ['Tmaker']);
	console.log('当前项目 :' + projectInfo.projectName);
});

gulp.task('Tmaker',function () {
	return gulp.src("app/**/*.html")
		.pipe(plumber())
		.pipe(Tmaker({isPreview:true}))
		.pipe(gulp.dest('dist/'))
		.pipe(browserSync.stream());
});

// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
	return gulp.src("app/scss/**/*.scss")
		.pipe(plumber())
		.pipe(sass.sync().on('error', sass.logError))
		.pipe(sass({outputStyle:"compact"}))
		.pipe(gulp.dest("dist/styles"))
		.pipe(browserSync.stream());
});

// javscript files operate
gulp.task('js', function(){
	return gulp.src('app/scripts/**/*.js')
		.pipe(plumber())
		.pipe(gulp.dest("dist/scripts"))
		.pipe(browserSync.stream());
});

gulp.task('preview-data', function () {
	return gulp.src('./app/data/*.*')
		.pipe(gulp.dest('dist/data'));
});

gulp.task('asset', function () {
	return gulp.src('./app/scss/*.+(jpg|png|gif)')
		.pipe(gulp.dest('dist/styles'));
});

// publish
function semverUpdate(key){

	var versionJson,
		semver = {
			major:0,
			minor:1,
			patch:2
		},
		semverArr;

	if(fs.existsSync('./app/version.json')){
		versionJson  = require('./app/version.json');
	} else {
		versionJson = { "version":	"1.0.0"}
	}

	semverArr = versionJson.version.split('.');
	semverArr[semver[key]] = (parseInt(semverArr[semver[key]]) + 1).toString();

	semverArr[1] = semver[key] < 1 ? 0 : semverArr[1];
	semverArr[2] = semver[key] < 2 ? 0 : semverArr[2];

	versionJson.version = semverArr.join('.');
	wjson.sync('./app/version.json',versionJson);
	return versionJson.version;
}

gulp.task('asset-publish',function () {
	return gulp.src('./app/scss/*.+(jpg|png)')
		.pipe(gulp.dest('dist/'));
});

gulp.task('publish', ['asset-publish'], function(){
	if(projectInfo.projectName == 'null'){
		console.log('\n 请先执行 "gulp --switch projectName" 新建一个项目\n');
		return null;
	}
	var key = (yargs.argv.major && 'major') || (yargs.argv.minor && 'minor') || (yargs.argv.patch && 'patch') || 'patch';
	var version = semverUpdate(key);
	gulp.src('app/**/*.html')
		.pipe(plumber())
		.pipe(Tmaker({isPreview:false}))
		.pipe(useref({ searchPath: './dist' }))
		.pipe(gulpif('*.js', minify()))
        .pipe(gulpif('*.css', minifyCss()))
		.pipe(verAppend({'append':{key:'v',to:[['css','%MD5%'],['js','%MD5%']]}}))
		.pipe(gulp.dest('release/'+projectInfo.projectName + '-' + version))
		.on('end',function(){console.log('已发布项目 ' + projectInfo.projectName + '-' + version)});
});

// switch project
gulp.task('switch', function(cb){

	// 切换/新建 项目
	if(yargs.argv.switch == 'null'){
		console.log('\n 项目名不能为 null');
		return ;
	}

	if(yargs.argv.switch){
		switchProjectName = yargs.argv.switch;
		if(switchProjectName == projectInfo.projectName){
			return ;
		}
		// 存档
		if(projectInfo.projectName != '_init'){

			console.log('存档 '+ projectInfo.projectName+ ' 项目');

			if(fs.existsSync('archive/'+ projectInfo.projectName))
			{
				gulp.src('archive/' + projectInfo.projectName).pipe(rm({async:false}));
			}

			gulp.src('app/**/*',{ dot: true })
				.pipe(plumber())
				.pipe(gulp.dest('archive/'+ projectInfo.projectName))
				.on('end',function(){
					// 清理 app & dist
					console.log('清理 app & dist 目录');
					gulp.src('app/**/*').pipe(rm({async:false}));
					gulp.src('dist/**/*').pipe(rm({async:false}))

					// 切换项目
					if(fs.existsSync('archive/'+ switchProjectName))
					{
						console.log('读取 '+switchProjectName+' 项目数据');
						archiveName = switchProjectName;
					}
					else
					{
						console.log('新建 '+switchProjectName+' 项目');
					}

					gulp.src('archive/'+ archiveName +'/**/*',{ dot: true })
						.pipe(gulp.dest('app'))
						.on('end',function () {
							projectInfo.projectName = switchProjectName;
							wjson.sync('projectInfo.json',projectInfo);
							console.log('已切换到项目 ' + switchProjectName);
							gulp.start(['Tmaker','sass','js','asset','preview-data']);
							console.log('已完成项目初始化 ')
						});
				});
		}
		return;
	}

	if(projectInfo.projectName == 'null'){
		console.log('\n 请先执行 "gulp --switch projectName" 新建一个项目');
		return ;
	}

	// 显示当前项目列表
	if(yargs.argv.show)
	{
		console.log('\n 当前项目 :\n');
		console.log(' * ' + projectInfo.projectName + '\n\n 已存档项目 :\n');
		fs.readdirSync('archive/').forEach(function(item) {

			if(item == '_init') {return;}
			console.log('   ' + item);
		})
		return console.log('\n 已列出所有项目\n');
	}

	if(yargs.argv.archive){
		console.log('\n 开始存档 ' + projectInfo.projectName + ' 项目');
		gulp.src('archive/' + projectInfo.projectName + '/**/*')
			.pipe(rm({async:false}));

		gulp.src('app/**/*')
			.pipe(plumber())
			.pipe(gulp.dest('archive/'+ projectInfo.projectName));

		return console.log('\n 已列存档当前项目\n');
	}

	gulp.start('serve');
});

gulp.task('default',['switch']);
<commit_msg>修复 附件的发布位置<commit_after>'use strict';

var gulp        = require('gulp'),
	browserSync = require('browser-sync').create(),
	SSI 		= require('browsersync-ssi'),
	minifyCss   = require('gulp-clean-css'),
	minify   	= require('gulp-minify'),
	plumber     = require('gulp-plumber'),
	sass        = require('gulp-sass'),
	Tmaker      = require('gulp-tmaker'),
	rm      	= require('gulp-rm'),
	yargs      	= require('yargs'),
	wjson		= require('write-json'),
	verAppend 	= require('gulp-version-number'),
	fs			= require('fs'),
	useref		= require('gulp-useref'),
	gulpif 		= require('gulp-if'),
	projectInfo	= require('./projectInfo.json');

var switchProjectName = '_init',
	archiveName = '_init';

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

	browserSync.init({
		server: {
			baseDir:["./dist"],
			middleware:SSI({
				baseDir:'./dist',
				ext:'.shtml',
				version:'2.10.0'
			})
		}
	});

	gulp.watch("app/scss/**/*.scss", ['sass']);
	gulp.watch("app/scss/*.+(jpg|png|gif)", ['asset']);
	gulp.watch("app/data/*.*", ['preview-data']);
	gulp.watch("app/scripts/**/*.js", ['js']);
	gulp.watch("app/**/*.html", ['Tmaker']);
	console.log('当前项目 :' + projectInfo.projectName);
});

gulp.task('Tmaker',function () {
	return gulp.src("app/**/*.html")
		.pipe(plumber())
		.pipe(Tmaker({isPreview:true}))
		.pipe(gulp.dest('dist/'))
		.pipe(browserSync.stream());
});

// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
	return gulp.src("app/scss/**/*.scss")
		.pipe(plumber())
		.pipe(sass.sync().on('error', sass.logError))
		.pipe(sass({outputStyle:"compact"}))
		.pipe(gulp.dest("dist/styles"))
		.pipe(browserSync.stream());
});

// javscript files operate
gulp.task('js', function(){
	return gulp.src('app/scripts/**/*.js')
		.pipe(plumber())
		.pipe(gulp.dest("dist/scripts"))
		.pipe(browserSync.stream());
});

gulp.task('preview-data', function () {
	return gulp.src('./app/data/*.*')
		.pipe(gulp.dest('dist/data'));
});

gulp.task('asset', function () {
	return gulp.src('./app/scss/*.+(jpg|png|gif)')
		.pipe(gulp.dest('dist/styles'));
});

// publish
function semverUpdate(key){

	var versionJson,
		semver = {
			major:0,
			minor:1,
			patch:2
		},
		semverArr;

	if(fs.existsSync('./app/version.json')){
		versionJson  = require('./app/version.json');
	} else {
		versionJson = { "version":	"1.0.0"}
	}

	semverArr = versionJson.version.split('.');
	semverArr[semver[key]] = (parseInt(semverArr[semver[key]]) + 1).toString();

	semverArr[1] = semver[key] < 1 ? 0 : semverArr[1];
	semverArr[2] = semver[key] < 2 ? 0 : semverArr[2];

	versionJson.version = semverArr.join('.');
	wjson.sync('./app/version.json',versionJson);
	return versionJson.version;
}

gulp.task('publish', function(){
	if(projectInfo.projectName == 'null'){
		console.log('\n 请先执行 "gulp --switch projectName" 新建一个项目\n');
		return null;
	}
	var key = (yargs.argv.major && 'major') || (yargs.argv.minor && 'minor') || (yargs.argv.patch && 'patch') || 'patch';
	var version = semverUpdate(key);

	gulp.src('./app/scss/*.+(jpg|png)')
		.pipe(gulp.dest('release/'+projectInfo.projectName + '-' + version));

	gulp.src('app/**/*.html')
		.pipe(plumber())
		.pipe(Tmaker({isPreview:false}))
		.pipe(useref({ searchPath: './dist' }))
		.pipe(gulpif('*.js', minify()))
        .pipe(gulpif('*.css', minifyCss()))
		.pipe(verAppend({'append':{key:'v',to:[['css','%MD5%'],['js','%MD5%']]}}))
		.pipe(gulp.dest('release/'+projectInfo.projectName + '-' + version))
		.on('end',function(){console.log('已发布项目 ' + projectInfo.projectName + '-' + version)});
});

// switch project
gulp.task('switch', function(cb){

	// 切换/新建 项目
	if(yargs.argv.switch == 'null'){
		console.log('\n 项目名不能为 null');
		return ;
	}

	if(yargs.argv.switch){
		switchProjectName = yargs.argv.switch;
		if(switchProjectName == projectInfo.projectName){
			return ;
		}
		// 存档
		if(projectInfo.projectName != '_init'){

			console.log('存档 '+ projectInfo.projectName+ ' 项目');

			if(fs.existsSync('archive/'+ projectInfo.projectName))
			{
				gulp.src('archive/' + projectInfo.projectName).pipe(rm({async:false}));
			}

			gulp.src('app/**/*',{ dot: true })
				.pipe(plumber())
				.pipe(gulp.dest('archive/'+ projectInfo.projectName))
				.on('end',function(){
					// 清理 app & dist
					console.log('清理 app & dist 目录');
					gulp.src('app/**/*').pipe(rm({async:false}));
					gulp.src('dist/**/*').pipe(rm({async:false}))

					// 切换项目
					if(fs.existsSync('archive/'+ switchProjectName))
					{
						console.log('读取 '+switchProjectName+' 项目数据');
						archiveName = switchProjectName;
					}
					else
					{
						console.log('新建 '+switchProjectName+' 项目');
					}

					gulp.src('archive/'+ archiveName +'/**/*',{ dot: true })
						.pipe(gulp.dest('app'))
						.on('end',function () {
							projectInfo.projectName = switchProjectName;
							wjson.sync('projectInfo.json',projectInfo);
							console.log('已切换到项目 ' + switchProjectName);
							gulp.start(['Tmaker','sass','js','asset','preview-data']);
							console.log('已完成项目初始化 ')
						});
				});
		}
		return;
	}

	if(projectInfo.projectName == 'null'){
		console.log('\n 请先执行 "gulp --switch projectName" 新建一个项目');
		return ;
	}

	// 显示当前项目列表
	if(yargs.argv.show)
	{
		console.log('\n 当前项目 :\n');
		console.log(' * ' + projectInfo.projectName + '\n\n 已存档项目 :\n');
		fs.readdirSync('archive/').forEach(function(item) {

			if(item == '_init') {return;}
			console.log('   ' + item);
		})
		return console.log('\n 已列出所有项目\n');
	}

	if(yargs.argv.archive){
		console.log('\n 开始存档 ' + projectInfo.projectName + ' 项目');
		gulp.src('archive/' + projectInfo.projectName + '/**/*')
			.pipe(rm({async:false}));

		gulp.src('app/**/*')
			.pipe(plumber())
			.pipe(gulp.dest('archive/'+ projectInfo.projectName));

		return console.log('\n 已列存档当前项目\n');
	}

	gulp.start('serve');
});

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


<commit_before>'use strict'

var babelify = require('babelify');
var browserSync = require('browser-sync');
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var changed = require('gulp-changed');
var copy = require('gulp-copy');
var csso = require('gulp-csso');
var del = require('del');
var electron = require('gulp-electron');
var gulp = require('gulp');
var notify = require('gulp-notify');
var packageJson = require('./package.json');
var sass = require('gulp-sass');
var shell = require('gulp-shell');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');

var o = {
  jsx: 'app/scripts/app.jsx',
  scss: 'app/styles/main.scss',
  bundle: 'app.js',
  distJs: 'dist/app/js',
  distCss: 'dist/app/css'
};

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

gulp.task('copy', function () {
  return gulp.src(['app/index.html', 'app/index.js', 'package.json'])
    .pipe(gulp.dest('dist/app'));
});

gulp.task('browserify', function () {
  return browserify(o.jsx)
    .transform(babelify)
    .bundle()
    .pipe(source(o.bundle))
    .pipe(buffer())
    .pipe(uglify())
    .pipe(gulp.dest(o.distJs));
});

gulp.task('browserifyDev', function () {
  return browserify(o.jsx)
    .transform(babelify)
    .bundle()
    .pipe(source(o.bundle))
    .pipe(gulp.dest(o.distJs));
});

gulp.task('styles', function () {
  return gulp.src(o.scss)
    .pipe(changed(o.distCss))
    .pipe(sass({errLogToConsole: true}))
    .on('error', notify.onError())
    .pipe(csso())
    .pipe(gulp.dest(o.distCss));
});

gulp.task('browserSync', function () {
  var bs = browserSync.create();
  bs.watch("app/**/*").on("change", function () {
    gulp.start(['browserifyDev', 'copy', 'styles']);
  });
});

gulp.task('electron', ['browserifyDev'], shell.task([
  './node_modules/electron-prebuilt/dist/Electron.app/Contents/MacOS/Electron dist/app'
]));

gulp.task('release', ['browserify'], function() {
  gulp.src("")
    .pipe(electron({
      src: './dist/app',
      packageJson: packageJson,
      release: './release',
      cache: './cache',
      version: 'v0.25.3',
      rebuild: false,
      platforms: ['win32-ia32', 'darwin-x64']
    }))
    .pipe(gulp.dest(""));
});

gulp.task('watch', ['clean'], function () {
  gulp.start(['browserifyDev', 'copy', 'styles', 'browserSync', 'electron']);
});

gulp.task('build', ['clean'], function () {
  process.env.NODE_ENV = 'production';
  gulp.start(['browserify', 'copy', 'styles', 'release']);
});

gulp.task('default', function () {
  console.log('Run `gulp watch` or `gulp build`');
});

<commit_msg>support windows<commit_after>'use strict'

var babelify = require('babelify');
var browserSync = require('browser-sync');
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var changed = require('gulp-changed');
var copy = require('gulp-copy');
var csso = require('gulp-csso');
var del = require('del');
var electron = require('gulp-electron');
var gulp = require('gulp');
var notify = require('gulp-notify');
var packageJson = require('./package.json');
var sass = require('gulp-sass');
var shell = require('gulp-shell');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');

var o = {
  jsx: 'app/scripts/app.jsx',
  scss: 'app/styles/main.scss',
  bundle: 'app.js',
  distJs: 'dist/app/js',
  distCss: 'dist/app/css'
};

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

gulp.task('copy', function () {
  return gulp.src(['app/index.html', 'app/index.js', 'package.json'])
    .pipe(gulp.dest('dist/app'));
});

gulp.task('browserify', function () {
  return browserify(o.jsx)
    .transform(babelify)
    .bundle()
    .pipe(source(o.bundle))
    .pipe(buffer())
    .pipe(uglify())
    .pipe(gulp.dest(o.distJs));
});

gulp.task('browserifyDev', function () {
  return browserify(o.jsx)
    .transform(babelify)
    .bundle()
    .pipe(source(o.bundle))
    .pipe(gulp.dest(o.distJs));
});

gulp.task('styles', function () {
  return gulp.src(o.scss)
    .pipe(changed(o.distCss))
    .pipe(sass({errLogToConsole: true}))
    .on('error', notify.onError())
    .pipe(csso())
    .pipe(gulp.dest(o.distCss));
});

gulp.task('browserSync', function () {
  var bs = browserSync.create();
  bs.watch('app/**/*').on('change', function () {
    gulp.start(['browserifyDev', 'copy', 'styles']);
  });
});

gulp.task('electron', ['browserifyDev'], function () {
  var cmd = '';
  switch (process.platform) {
    case 'darwin':
      cmd = './node_modules/electron-prebuilt/dist/Electron.app/Contents/MacOS/Electron dist/app';
      break;
    case 'win32':
      cmd = 'node_modules\\electron-prebuilt\\dist\\electron.exe dist\\app';
      break;
    default:
      console.log(process.platform + ' is not supported.');
      return;
  }

  return gulp.src('', {read: false})
    .pipe(shell(cmd));
});

gulp.task('release', ['browserify'], function () {
  gulp.src('')
    .pipe(electron({
      src: './dist/app',
      packageJson: packageJson,
      release: './release',
      cache: './cache',
      version: 'v0.25.3',
      rebuild: false,
      platforms: ['win32-ia32', 'darwin-x64']
    }))
    .pipe(gulp.dest(''));
});

gulp.task('watch', ['clean'], function () {
  gulp.start(['browserifyDev', 'copy', 'styles', 'browserSync', 'electron']);
});

gulp.task('build', ['clean'], function () {
  process.env.NODE_ENV = 'production';
  gulp.start(['browserify', 'copy', 'styles', 'release']);
});

gulp.task('default', function () {
  console.log('Run `gulp watch` or `gulp build`');
});

<|endoftext|>


<commit_before>var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');

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

gulp.task('watch', function(){
  gulp.watch(['hint.js', '!./dist/*.js'], ['browserify']);
});

gulp.task('browserify', function() {
  var bundleStream = browserify('./' + main).bundle().pipe(source(main));
  return bundleStream.pipe(gulp.dest('./dist'));
});

gulp.task('default', ['browserify']);<commit_msg>style(gulp): add missing newline<commit_after>var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');

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

gulp.task('watch', function(){
  gulp.watch(['hint.js', '!./dist/*.js'], ['browserify']);
});

gulp.task('browserify', function() {
  var bundleStream = browserify('./' + main).bundle().pipe(source(main));
  return bundleStream.pipe(gulp.dest('./dist'));
});

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


<commit_before>'use strict';

var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var argv = require('yargs').argv;
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var del = require('del');
var extender = require('gulp-html-extend');
var size = require('gulp-size');
var gulpif = require('gulp-if');
var htmlreplace = require('gulp-html-replace');
var jshint = require('gulp-jshint');
var minifyCSS = require('gulp-minify-css');
var reload = browserSync.reload;
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var sourcemaps = require('gulp-sourcemaps');

var basePaths = {
	src: 'src/',
	dest: 'build/'
};

var paths = {
	styles: {
		src: basePaths.src + 'styles/',
		dest: basePaths.dest + 'css/'
	},
	scripts: {
		src: basePaths.src + 'scripts/',
		dest: basePaths.dest + 'js/'
	},
	images: {
		src: basePaths.src + 'images/',
		dest: basePaths.dest + 'img/'
	},
	fonts: {
		src: basePaths.src + 'fonts/',
		dest: basePaths.dest + 'css/fonts/'
	}
};

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

gulp.task('html', function () {
	gulp.src(basePaths.src + '*.html')
	.pipe(extender({annotations:true,verbose:false})) // default options
	.pipe(gulpif(argv.production, htmlreplace({
		'styles_production': 'css/styles.min.css',
		'js_production': 'js/app.min.js'
	})))
	.pipe(gulp.dest((basePaths.dest)));
});

gulp.task('styles', function () {
	return gulp.src(paths.styles.src + '**/*.scss')
	.pipe(gulpif(argv.dev, sourcemaps.init()))
	.pipe(sass({errLogToConsole: true}))
	.pipe(autoprefixer({
		autoprefixer: {browsers: ['last 2 versions']}
	}))
	.pipe(gulpif(argv.production, rename({suffix: '.min'})))
	.pipe(gulpif(argv.production, minifyCSS({keepBreaks:false})))
	.pipe(gulpif(argv.dev, sourcemaps.write()))
	.pipe(gulp.dest((paths.styles.dest)))
	.pipe(reload({stream: true}))
	.pipe(size({title: 'styles'}));
});

gulp.task('scripts', function () {
	return gulp.src([
		paths.scripts.src + 'vendors/jquery-1.11.3.min.js',
		paths.scripts.src + 'vendors/bootstrap.min.js',
		paths.scripts.src + '*.js'
		])
	.pipe(jshint('.jshintrc'))
	.pipe(jshint.reporter('default'))
	.pipe(size({title: 'scripts'}))
	.pipe(gulpif(argv.production, concat('app.js')))
	.pipe(gulpif(argv.production, rename({suffix: '.min'})))
	.pipe(gulpif(argv.production, uglify({preserveComments: 'some'})))// Keep some comments
	.pipe(gulp.dest((paths.scripts.dest)));
});

gulp.task('images', function () {
	return gulp.src(paths.images.src + '**/*.*')
	.pipe(imagemin({
		progressive: true,
		optimizationLevel : 8
	}))
	.pipe(gulp.dest(paths.images.dest))
	.pipe(size({title: 'images'}));
});

gulp.task('fonts', function() {
	gulp.src(paths.fonts.src + '**/*.*')
	.pipe(gulp.dest('build/fonts/'))
	.pipe(size({title: 'fonts'}));
});

gulp.task('default', ['builder'], function() {
	browserSync({
		server: {
			baseDir: basePaths.dest
		}
	});
	gulp.watch(paths.styles.src + '**/*.scss', ['styles']);
	gulp.watch(paths.scripts.src + '**/*.js', ['scripts', reload]);
	gulp.watch(paths.images.src + '**/*.*', ['images', reload]);
	gulp.watch(paths.fonts.src + '**/*', ['fonts', reload]);
	gulp.watch(basePaths.src + '**/*.html', ['html', reload]);
});

gulp.task('builder', ['clean'], function (cb) {
	runSequence(['html','styles', 'scripts', 'images', 'fonts'], cb);
});
<commit_msg>update gulpfile<commit_after>'use strict';

var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var argv = require('yargs').argv;
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var del = require('del');
var extender = require('gulp-html-extend');
var size = require('gulp-size');
var gulpif = require('gulp-if');
var htmlreplace = require('gulp-html-replace');
var jshint = require('gulp-jshint');
var minifyCSS = require('gulp-minify-css');
var reload = browserSync.reload;
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var sourcemaps = require('gulp-sourcemaps');

var basePaths = {
	src: 'src/',
	dest: 'build/'
};

var paths = {
	styles: {
		src: basePaths.src + 'styles/',
		dest: basePaths.dest + 'css/'
	},
	scripts: {
		src: basePaths.src + 'scripts/',
		dest: basePaths.dest + 'js/'
	},
	images: {
		src: basePaths.src + 'images/',
		dest: basePaths.dest + 'img/'
	},
	fonts: {
		src: basePaths.src + 'fonts/',
		dest: basePaths.dest + 'css/fonts/'
	}
};

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

gulp.task('html', function () {
	gulp.src(basePaths.src + '*.html')
	.pipe(extender({annotations:true,verbose:false})) // default options
	.pipe(gulpif(argv.production, htmlreplace({
		'styles_production': 'css/styles.min.css',
		'js_production': 'js/app.min.js'
	})))
	.pipe(gulp.dest((basePaths.dest)));
});

gulp.task('styles', function () {
	return gulp.src(paths.styles.src + '**/*.scss')
	.pipe(gulpif(argv.dev, sourcemaps.init()))
	.pipe(sass({errLogToConsole: true}))
	.pipe(autoprefixer({
		autoprefixer: {browsers: ['last 2 versions']}
	}))
	.pipe(gulpif(argv.production, rename({suffix: '.min'})))
	.pipe(gulpif(argv.production, minifyCSS({keepBreaks:false})))
	.pipe(gulpif(argv.dev, sourcemaps.write()))
	.pipe(gulp.dest((paths.styles.dest)))
	.pipe(reload({stream: true}))
	.pipe(size({title: 'styles'}));
});

gulp.task('scripts', function () {
	return gulp.src([
		paths.scripts.src + 'vendors/jquery-1.11.3.min.js',
		paths.scripts.src + 'vendors/bootstrap.min.js',
		paths.scripts.src + '*.js'
		])
	.pipe(jshint('.jshintrc'))
	.pipe(jshint.reporter('default'))
	.pipe(size({title: 'scripts'}))
	.pipe(gulpif(argv.production, concat('app.js')))
	.pipe(gulpif(argv.production, rename({suffix: '.min'})))
	.pipe(gulpif(argv.production, uglify({preserveComments: 'some'})))// Keep some comments
	.pipe(gulp.dest((paths.scripts.dest)));
});

gulp.task('images', function () {
	return gulp.src(paths.images.src + '**/*.*')
	.pipe(imagemin({
		progressive: true,
		optimizationLevel : 8
	}))
	.pipe(gulp.dest(paths.images.dest))
	.pipe(size({title: 'images'}));
});

gulp.task('fonts', function() {
	gulp.src(paths.fonts.src + '**/*.*')
	.pipe(gulp.dest('build/fonts/'))
	.pipe(size({title: 'fonts'}));
});

gulp.task('server', function() {
  browserSync({
    server: {
      baseDir: basePaths.dest
    }
  });
  gulp.watch(paths.styles.src + '**/*.scss', ['styles']);
  gulp.watch(paths.scripts.src + '**/*.js', ['scripts', reload]);
  gulp.watch(paths.images.src + '**/*.*', ['images', reload]);
  gulp.watch(paths.fonts.src + '**/*', ['fonts', reload]);
  gulp.watch(basePaths.src + '**/*.html', ['html', reload]);
});

gulp.task('watch', ['clean'], function (cb) {
  runSequence(['server','html','styles', 'scripts', 'images', 'fonts'], cb);
});

gulp.task('build', ['clean'], function (cb) {
  runSequence(['html','styles', 'scripts', 'images', 'fonts'], cb);
});
<|endoftext|>


<commit_before>/*
 * isomorphic-backbone-starter-kit
 *
 * https://github.com/jostw/isomorphic-backbone-starter-kit
 *
 * Copyright (c) 2015 jos
 * Licensed under the MIT license.
 */

"use strict";

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

var wiredep = require("wiredep");

var browserify = require("browserify");
var source = require("vinyl-source-stream");

gulp.task("copy:vendor", function() {
    gulp.src([
        "bower_components/html5shiv/dist/html5shiv.min.js",
        "bower_components/respond/dest/respond.min.js"
    ])
    .pipe(gulp.dest("public/js/vendor/"));
});

gulp.task("copy:bower", function() {
    gulp.src([
        "bower_components/**/*.{css,js}",
        "!bower_components/{html5shiv,respond,modernizr}/**/*.{css,js}"
    ])
    .pipe(gulp.dest("public/bower_components/"));
});

gulp.task("uglify:modernizr", function() {
    gulp.src([
        "bower_components/modernizr/modernizr.js"
    ])
    .pipe(plugins.uglify())
    .pipe(plugins.rename("modernizr.min.js"))
    .pipe(gulp.dest("public/js/vendor/"));
});

gulp.task("build:html", ["copy:bower"], function() {
    gulp.src([
        "template/index.hbs"
    ])
    .pipe(plugins.htmlhint(".htmlhintrc"))
    .pipe(plugins.htmlhint.failReporter())
    .pipe(wiredep.stream({
        ignorePath: "..",
        exclude: /html5shiv|respond|modernizr/
    }))
    .pipe(plugins.inject(gulp.src([
        "template/*.hbs",
        "!template/index.hbs"
    ]), {
        starttag: "<!-- inject:hbs -->",
        transform: function(filePath, file) {
            var fileName = filePath.match("template/(.+).hbs")[1];

            return "<script id='template-" + fileName + "' type='text/template'>" + file.contents.toString("utf8") + "</script>";
        }
    }))
    .pipe(gulp.dest("public/"));
});

gulp.task("build:css", function() {
    gulp.src([
        "scss/style.scss"
    ])
    .pipe(plugins.sass().on("error", plugins.sass.logError))
    .pipe(plugins.csslint(".csslintrc"))
    .pipe(plugins.csslint.reporter())
    .pipe(plugins.csslint.failReporter())
    .pipe(plugins.autoprefixer())
    .pipe(gulp.dest("public/css/"));
});

gulp.task("lint:js", function() {
    return gulp.src([
        "gulpfile.js",
        "app.js",
        "js/**/*.js",
        "!js/vendor/*.js"
    ])
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter(require("jshint-stylish")))
    .pipe(plugins.eslint())
    .pipe(plugins.eslint.format())
    .pipe(plugins.eslint.failOnError())
    .pipe(plugins.jscs());
});

gulp.task("build:js", ["lint:js"], function() {
    browserify("./js/app.js")
        .bundle()
        .pipe(source("script.js"))
        .pipe(gulp.dest("public/js/"));
});

gulp.task("watch", ["copy:vendor", "uglify:modernizr"], function() {
    gulp.watch("template/*.hbs", ["build:html"]);

    gulp.watch("scss/**/*.scss", ["build:css"]);

    gulp.watch("js/**/*.js", ["build:js"]);

    gulp.watch([
        "app.js",
        "public/index.hbs",
        "public/css/style.css",
        "public/js/script.js"
    ]).on("change", function(file) {
        plugins.livereload.changed(file.path);
    });
});

gulp.task("default", ["watch"], function() {
    plugins.livereload.listen();

    plugins.nodemon({
        script: "app.js",
        ext: "js hbs",
        ignore: [
            "gulpfile.js",
            "node_modules/",
            "bower_components/",
            "public/"
        ]
    });
});

gulp.task("build", [
    "copy:vendor", "uglify:modernizr",
    "build:html", "build:css", "build:js"
]);
<commit_msg>Update: jshint with fail<commit_after>/*
 * isomorphic-backbone-starter-kit
 *
 * https://github.com/jostw/isomorphic-backbone-starter-kit
 *
 * Copyright (c) 2015 jos
 * Licensed under the MIT license.
 */

"use strict";

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

var wiredep = require("wiredep");

var browserify = require("browserify");
var source = require("vinyl-source-stream");

gulp.task("copy:vendor", function() {
    gulp.src([
        "bower_components/html5shiv/dist/html5shiv.min.js",
        "bower_components/respond/dest/respond.min.js"
    ])
    .pipe(gulp.dest("public/js/vendor/"));
});

gulp.task("copy:bower", function() {
    gulp.src([
        "bower_components/**/*.{css,js}",
        "!bower_components/{html5shiv,respond,modernizr}/**/*.{css,js}"
    ])
    .pipe(gulp.dest("public/bower_components/"));
});

gulp.task("uglify:modernizr", function() {
    gulp.src([
        "bower_components/modernizr/modernizr.js"
    ])
    .pipe(plugins.uglify())
    .pipe(plugins.rename("modernizr.min.js"))
    .pipe(gulp.dest("public/js/vendor/"));
});

gulp.task("build:html", ["copy:bower"], function() {
    gulp.src([
        "template/index.hbs"
    ])
    .pipe(plugins.htmlhint(".htmlhintrc"))
    .pipe(plugins.htmlhint.failReporter())
    .pipe(wiredep.stream({
        ignorePath: "..",
        exclude: /html5shiv|respond|modernizr/
    }))
    .pipe(plugins.inject(gulp.src([
        "template/*.hbs",
        "!template/index.hbs"
    ]), {
        starttag: "<!-- inject:hbs -->",
        transform: function(filePath, file) {
            var fileName = filePath.match("template/(.+).hbs")[1];

            return "<script id='template-" + fileName + "' type='text/template'>" + file.contents.toString("utf8") + "</script>";
        }
    }))
    .pipe(gulp.dest("public/"));
});

gulp.task("build:css", function() {
    gulp.src([
        "scss/style.scss"
    ])
    .pipe(plugins.sass().on("error", plugins.sass.logError))
    .pipe(plugins.csslint(".csslintrc"))
    .pipe(plugins.csslint.reporter())
    .pipe(plugins.csslint.failReporter())
    .pipe(plugins.autoprefixer())
    .pipe(gulp.dest("public/css/"));
});

gulp.task("lint:js", function() {
    return gulp.src([
        "gulpfile.js",
        "app.js",
        "js/**/*.js",
        "!js/vendor/*.js"
    ])
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter("jshint-stylish"))
    .pipe(plugins.jshint.reporter("fail"))
    .pipe(plugins.eslint())
    .pipe(plugins.eslint.format())
    .pipe(plugins.eslint.failOnError())
    .pipe(plugins.jscs());
});

gulp.task("build:js", ["lint:js"], function() {
    browserify("./js/app.js")
        .bundle()
        .pipe(source("script.js"))
        .pipe(gulp.dest("public/js/"));
});

gulp.task("watch", ["copy:vendor", "uglify:modernizr"], function() {
    gulp.watch("template/*.hbs", ["build:html"]);

    gulp.watch("scss/**/*.scss", ["build:css"]);

    gulp.watch("js/**/*.js", ["build:js"]);

    gulp.watch([
        "app.js",
        "public/index.hbs",
        "public/css/style.css",
        "public/js/script.js"
    ]).on("change", function(file) {
        plugins.livereload.changed(file.path);
    });
});

gulp.task("default", ["watch"], function() {
    plugins.livereload.listen();

    plugins.nodemon({
        script: "app.js",
        ext: "js hbs",
        ignore: [
            "gulpfile.js",
            "node_modules/",
            "bower_components/",
            "public/"
        ]
    });
});

gulp.task("build", [
    "copy:vendor", "uglify:modernizr",
    "build:html", "build:css", "build:js"
]);
<|endoftext|>


<commit_before>'use strict';

var gulp 			= require('gulp');
var postcss    		= require('gulp-postcss');
var sass 			= require('gulp-sass');
var autoprefixer 	= require('autoprefixer');
var cssnano 		= require('cssnano');

var templateCache 	= require('gulp-angular-templatecache');
var ngAnnotate      = require('gulp-ng-annotate');

var babel 			= require('gulp-babel');
var Builder 		= require('systemjs-builder');

var runSequence 	= require('run-sequence');
var clean 			= require('gulp-clean');
var sourcemaps 		= require('gulp-sourcemaps');

var config = {
	templates: {
		src: './src/**/*.html',
		dist: './dist'
	},
	js: {
		src: './src/**/*.js',
		dist: './tmp'
	},
	sass: {
		src: './src/**/*.scss',
		dist: './dist'
	},
	autoprefixer: {
		browsers: ['last 2 versions']
	},
	babel: {
		presets: ['es2015']
	},
	systemJs: {
		entry: 'index.js',
		dev: {
			dist: './dist/component.js',
			options: {
				runtime: false,
				minify: false
			}
		},
		production: {
			dist: './dist/component.min.js',
			options: {
				runtime: false,
				minify: true
			}
		}
	}
};

/**
 * STYLES
 */
gulp.task('styles', function() {
	var processors = [
		autoprefixer(config.autoprefixer),
		cssnano
	];

	return gulp.src(config.sass.src)
		.pipe( sourcemaps.init() )
		.pipe( sass().on('error', sass.logError) )
		.pipe( postcss(processors) )
		.pipe( sourcemaps.write('.') )
		.pipe( gulp.dest(config.sass.dist) );
});

gulp.task('styles:watch', function() {
	gulp.watch(config.sass.src, ['styles']);
});

/**
 * Angular
 */
gulp.task('ng-annotate', function() {
	return gulp.src(config.js.dist + '/**/*.js')
		.pipe( ngAnnotate() )
		.pipe( gulp.dest(config.js.dist) );
});

gulp.task('angular-templates', function(){
	return gulp.src(config.templates.src)
		.pipe( templateCache() )
		.pipe( gulp.dest(config.templates.dist) )
});

/**
 * Javascript
 */
gulp.task('babel', function(){
	return gulp.src(config.js.src)
		.pipe( babel(config.babel) )
		.pipe( gulp.dest(config.js.dist) );
});

gulp.task('systemJS:dev', function(callback){
	var builder = new Builder('./');
	var entry = config.js.dist + '/' + config.systemJs.entry;

	builder.buildStatic(entry, config.systemJs.dev.dist, config.systemJs.dev.options).then(function() {
		callback();
	}).catch(function(error) {
		console.log(error);
	});
});

gulp.task('systemJS:dist', function(callback){
	var builder = new Builder('./');
	var entry = config.js.dist + '/' + config.systemJs.entry;

	builder.buildStatic(entry, config.systemJs.production.dist, config.systemJs.production.options).then(function() {
		callback();
	}).catch(function(error) {
		console.log(error);
	});
});

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

gulp.task('build', function() {
	runSequence('clean', 'babel', 'ng-annotate', ['systemJS:dev', 'systemJS:dist', 'angular-templates'], 'clean');
});<commit_msg>fix(build): Added safe flag for cssnano<commit_after>'use strict';

var gulp 			= require('gulp');
var postcss    		= require('gulp-postcss');
var sass 			= require('gulp-sass');
var autoprefixer 	= require('autoprefixer');
var cssnano 		= require('cssnano');

var templateCache 	= require('gulp-angular-templatecache');
var ngAnnotate      = require('gulp-ng-annotate');

var babel 			= require('gulp-babel');
var Builder 		= require('systemjs-builder');

var runSequence 	= require('run-sequence');
var clean 			= require('gulp-clean');
var sourcemaps 		= require('gulp-sourcemaps');

var config = {
	templates: {
		src: './src/**/*.html',
		dist: './dist'
	},
	js: {
		src: './src/**/*.js',
		dist: './tmp'
	},
	sass: {
		src: './src/**/*.scss',
		dist: './dist'
	},
	autoprefixer: {
		browsers: ['last 2 versions']
	},
	cssnano: {
		safe: true
	},
	babel: {
		presets: ['es2015']
	},
	systemJs: {
		entry: 'index.js',
		dev: {
			dist: './dist/component.js',
			options: {
				runtime: false,
				minify: false
			}
		},
		production: {
			dist: './dist/component.min.js',
			options: {
				runtime: false,
				minify: true
			}
		}
	}
};

/**
 * STYLES
 */
gulp.task('styles', function() {
	var processors = [
		autoprefixer(config.autoprefixer),
		cssnano(config.cssnano)
	];

	return gulp.src(config.sass.src)
		.pipe( sourcemaps.init() )
		.pipe( sass().on('error', sass.logError) )
		.pipe( postcss(processors) )
		.pipe( sourcemaps.write('.') )
		.pipe( gulp.dest(config.sass.dist) );
});

gulp.task('styles:watch', function() {
	gulp.watch(config.sass.src, ['styles']);
});

/**
 * Angular
 */
gulp.task('ng-annotate', function() {
	return gulp.src(config.js.dist + '/**/*.js')
		.pipe( ngAnnotate() )
		.pipe( gulp.dest(config.js.dist) );
});

gulp.task('angular-templates', function(){
	return gulp.src(config.templates.src)
		.pipe( templateCache() )
		.pipe( gulp.dest(config.templates.dist) )
});

/**
 * Javascript
 */
gulp.task('babel', function(){
	return gulp.src(config.js.src)
		.pipe( babel(config.babel) )
		.pipe( gulp.dest(config.js.dist) );
});

gulp.task('systemJS:dev', function(callback){
	var builder = new Builder('./');
	var entry = config.js.dist + '/' + config.systemJs.entry;

	builder.buildStatic(entry, config.systemJs.dev.dist, config.systemJs.dev.options).then(function() {
		callback();
	}).catch(function(error) {
		console.log(error);
	});
});

gulp.task('systemJS:dist', function(callback){
	var builder = new Builder('./');
	var entry = config.js.dist + '/' + config.systemJs.entry;

	builder.buildStatic(entry, config.systemJs.production.dist, config.systemJs.production.options).then(function() {
		callback();
	}).catch(function(error) {
		console.log(error);
	});
});

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

gulp.task('build', function() {
	runSequence('clean', 'babel', 'ng-annotate', ['systemJS:dev', 'systemJS:dist', 'angular-templates'], 'clean');
});<|endoftext|>


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

var distBasePath = './dist';
var assetsBasePath = distBasePath + '/assets';

var srcHtml = './src/*.html';
var srcComponents = './src/components/*.vue';
var srcJs = './src/js/**/*.js';

var tasks = ['html-clean', 'js-clean', 'webpack', 'copy-html-src'];
var watchHtml = ['copy-html-src'];
var watchJs = ['webpack'];

gulp.task('js-clean', function(){
    return gulp.src(distBasePath + 'assets/js', {read: false})
        .pipe(clean());
});

gulp.task('html-clean', function() {
    return gulp.src(distBasePath + '/*.html', {read: false})
    .pipe(clean());
});

gulp.task('webpack', ['js-clean'], function() {
    return webpack(require('./webpack.config.js'));
});

gulp.task('copy-html-src', ['html-clean'], function() {
    return gulp.src(srcHtml)
    .pipe(gulp.dest(distBasePath));
});

gulp.task('default', tasks, function() {
    gulp.watch([srcComponents, srcJs], watchJs);
    gulp.watch([srcHtml], watchHtml);
});
<commit_msg>fix gulpfile<commit_after>var gulp = require('gulp');
var webpack = require('gulp-webpack');
var clean = require('gulp-clean');

var distBasePath = './dist';
var assetsBasePath = distBasePath + '/assets';

var srcHtml = './src/*.html';
var srcComponents = './src/components/*.vue';
var srcJs = './src/js/**/*.js';

var tasks = ['html-clean', 'js-clean', 'webpack', 'copy-html-src'];
var watchHtml = ['copy-html-src'];
var watchJs = ['webpack'];

gulp.task('js-clean', function(){
    return gulp.src(distBasePath + 'assets/js', {read: false})
        .pipe(clean());
});

gulp.task('html-clean', function() {
    return gulp.src(distBasePath + '/*.html', {read: false})
    .pipe(clean());
});

gulp.task('webpack', ['js-clean'], function() {
    return webpack(require('./webpack.config.js'))
    .pipe(gulp.dest(assetsBasePath + '/js'));
});

gulp.task('copy-html-src', ['html-clean'], function() {
    return gulp.src(srcHtml)
    .pipe(gulp.dest(distBasePath));
});

gulp.task('default', tasks, function() {
    gulp.watch([srcComponents, srcJs], watchJs);
    gulp.watch([srcHtml], watchHtml);
});
<|endoftext|>


<commit_before>var Path = require('path');

var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var rename = require('gulp-rename');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglifyjs');
var concat = require('gulp-concat');
var qunit = require('gulp-qunit');
var preprocess = require('gulp-preprocess');

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

var paths = {
    src: [
        'src/__intro.js',

        'src/editor/pre-define.js',

        // javascript extends
        'src/definition.js',
        'src/core.js',
        'src/math.js',
        'src/intersection.js',
        'src/callbacks-invoker.js',

        // basic classes
        'src/utils.js',
        'src/attribute.js',
        'src/class.js',
        'src/path.js',
        'src/object.js',
        'src/hash-object.js',
        'src/vec2.js',
        'src/matrix23.js',
        'src/rect.js',
        'src/polygon.js',
        'src/color.js',
        'src/deserialize.js',
        'src/instantiate.js',

        // assets
        'src/asset/asset.js',
        'src/asset/custom-asset.js',
        'src/asset/texture.js',
        'src/asset/sprite.js',
        'src/asset/atlas.js',
        'src/asset/atlas-utils.js',
        'src/asset/json-asset.js',
        'src/asset/text-asset.js',
        'src/asset/bitmap-font.js',

        // editor utils
        'src/editor/serialize.js',
        'src/editor/serialize-nicify.js',

        'src/__outro.js'
    ],
    player_dev: 'bin/core.player.dev.js',
    player: 'bin/core.player.js',

    test: {
        src: 'test/unit/**/*.js',
        runner: 'test/lib/runner.html',
        lib_dev: [
            'bin/dev/core.js',
        ],
        lib_min: [
            'bin/min/core.js',
        ],
    },

    ref: {
        src: [
            'test/lib/*.js',
            'test/unit/_*.js',
        ],
        dest: '_references.js',
    },
};

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

// js-hint
gulp.task('jshint', function() {
    return gulp.src(paths.src.concat( ['!**/__intro.js','!**/__outro.js'] ))
    .pipe(jshint({
        forin: false,
        multistr: true,
    }))
    .pipe(jshint.reporter(stylish))
    ;
});

// js dev
gulp.task('js-dev', function() {
    return gulp.src(paths.src)
    .pipe(preprocess({context: { EDITOR: true, DEBUG: true, DEV: true }}))
    .pipe(concat('core.js'))
    .pipe(gulp.dest('bin/dev'))
    ;
});

// js min
gulp.task('js-min', function() {
    return gulp.src(paths.src)
    .pipe(preprocess({context: { EDITOR: true, DEV: true }}))
    .pipe(concat('core.js'))
    .pipe(uglify({
            compress: {
                dead_code: false,
                unused: false
            }
        }))
    .pipe(gulp.dest('bin/min'))
    ;
});

// player dev
gulp.task('js-player-dev', function() {
    return gulp.src(paths.src.concat('!**/editor/**'))
    .pipe(preprocess({context: { PLAYER: true, DEBUG: true, DEV: true }}))
    .pipe(concat(Path.basename(paths.player_dev)))
    .pipe(gulp.dest(Path.dirname(paths.player_dev)))
    ;
});

// player
gulp.task('js-player', function() {
    return gulp.src(paths.src.concat('!**/editor/**'))
    .pipe(preprocess({context: { PLAYER: true }}))
    .pipe(concat(Path.basename(paths.player)))
    .pipe(gulp.dest(Path.dirname(paths.player)))
    ;
});

gulp.task('dev', ['jshint', 'js-dev', 'js-player-dev']);
gulp.task('min', ['jshint', 'js-min', 'js-player']);
gulp.task('default', ['dev', 'min']);

/////////////////////////////////////////////////////////////////////////////
// test
/////////////////////////////////////////////////////////////////////////////

gulp.task('unit-runner', function() {
    var js = paths.test.src;
    var dest = paths.test.src.split('*')[0];
    return gulp.src(js, { read: false, base: './' })
               .pipe(fb.toFileList())
               .pipe(fb.generateRunner(paths.test.runner,
                                         dest,
                                         'Fireball Core Test Suite',
                                         paths.test.lib_min,
                                         paths.test.lib_dev,
                                         paths.src))
               .pipe(gulp.dest(dest))
               ;
});

gulp.task('test', ['js-min', 'unit-runner'], function() {
    var timeOutInSeconds = 5;
    return gulp.src(['test/unit/**/*.html', '!**/*.dev.*'], { read: false })
               .pipe(qunit({ timeout: timeOutInSeconds }))
               ;
});

/////////////////////////////////////////////////////////////////////////////
// tasks
/////////////////////////////////////////////////////////////////////////////

// ref
gulp.task('ref', function() {
    var src = paths.src;//.concat(['!src/__intro.js', '!src/__outro.js']);
    var files = paths.ref.src.concat(src);
    var destPath = paths.ref.dest;
    return fb.generateReference(files, destPath);
});

gulp.task('all', ['default', 'test', 'ref'] );
gulp.task('ci', ['jshint', 'test'] );

// watch
gulp.task('watch', function() {
    gulp.watch(paths.src, ['dev']).on( 'error', gutil.log );
});
<commit_msg>Make sure we build js-player-dev and js-player in both dev and min<commit_after>var Path = require('path');

var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var rename = require('gulp-rename');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglifyjs');
var concat = require('gulp-concat');
var qunit = require('gulp-qunit');
var preprocess = require('gulp-preprocess');

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

var paths = {
    src: [
        'src/__intro.js',

        'src/editor/pre-define.js',

        // javascript extends
        'src/definition.js',
        'src/core.js',
        'src/math.js',
        'src/intersection.js',
        'src/callbacks-invoker.js',

        // basic classes
        'src/utils.js',
        'src/attribute.js',
        'src/class.js',
        'src/path.js',
        'src/object.js',
        'src/hash-object.js',
        'src/vec2.js',
        'src/matrix23.js',
        'src/rect.js',
        'src/polygon.js',
        'src/color.js',
        'src/deserialize.js',
        'src/instantiate.js',

        // assets
        'src/asset/asset.js',
        'src/asset/custom-asset.js',
        'src/asset/texture.js',
        'src/asset/sprite.js',
        'src/asset/atlas.js',
        'src/asset/atlas-utils.js',
        'src/asset/json-asset.js',
        'src/asset/text-asset.js',
        'src/asset/bitmap-font.js',

        // editor utils
        'src/editor/serialize.js',
        'src/editor/serialize-nicify.js',

        'src/__outro.js'
    ],
    player_dev: 'bin/core.player.dev.js',
    player: 'bin/core.player.js',

    test: {
        src: 'test/unit/**/*.js',
        runner: 'test/lib/runner.html',
        lib_dev: [
            'bin/dev/core.js',
        ],
        lib_min: [
            'bin/min/core.js',
        ],
    },

    ref: {
        src: [
            'test/lib/*.js',
            'test/unit/_*.js',
        ],
        dest: '_references.js',
    },
};

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

// js-hint
gulp.task('jshint', function() {
    return gulp.src(paths.src.concat( ['!**/__intro.js','!**/__outro.js'] ))
    .pipe(jshint({
        forin: false,
        multistr: true,
    }))
    .pipe(jshint.reporter(stylish))
    ;
});

// js dev
gulp.task('js-dev', function() {
    return gulp.src(paths.src)
    .pipe(preprocess({context: { EDITOR: true, DEBUG: true, DEV: true }}))
    .pipe(concat('core.js'))
    .pipe(gulp.dest('bin/dev'))
    ;
});

// js min
gulp.task('js-min', function() {
    return gulp.src(paths.src)
    .pipe(preprocess({context: { EDITOR: true, DEV: true }}))
    .pipe(concat('core.js'))
    .pipe(uglify({
            compress: {
                dead_code: false,
                unused: false
            }
        }))
    .pipe(gulp.dest('bin/min'))
    ;
});

// player dev
gulp.task('js-player-dev', function() {
    return gulp.src(paths.src.concat('!**/editor/**'))
    .pipe(preprocess({context: { PLAYER: true, DEBUG: true, DEV: true }}))
    .pipe(concat(Path.basename(paths.player_dev)))
    .pipe(gulp.dest(Path.dirname(paths.player_dev)))
    ;
});

// player
gulp.task('js-player', function() {
    return gulp.src(paths.src.concat('!**/editor/**'))
    .pipe(preprocess({context: { PLAYER: true }}))
    .pipe(concat(Path.basename(paths.player)))
    .pipe(gulp.dest(Path.dirname(paths.player)))
    ;
});

gulp.task('dev', ['jshint', 'js-dev', 'js-player-dev', 'js-player']);
gulp.task('min', ['jshint', 'js-min', 'js-player-dev', 'js-player']);
gulp.task('default', ['dev', 'min']);

/////////////////////////////////////////////////////////////////////////////
// test
/////////////////////////////////////////////////////////////////////////////

gulp.task('unit-runner', function() {
    var js = paths.test.src;
    var dest = paths.test.src.split('*')[0];
    return gulp.src(js, { read: false, base: './' })
               .pipe(fb.toFileList())
               .pipe(fb.generateRunner(paths.test.runner,
                                         dest,
                                         'Fireball Core Test Suite',
                                         paths.test.lib_min,
                                         paths.test.lib_dev,
                                         paths.src))
               .pipe(gulp.dest(dest))
               ;
});

gulp.task('test', ['js-min', 'unit-runner'], function() {
    var timeOutInSeconds = 5;
    return gulp.src(['test/unit/**/*.html', '!**/*.dev.*'], { read: false })
               .pipe(qunit({ timeout: timeOutInSeconds }))
               ;
});

/////////////////////////////////////////////////////////////////////////////
// tasks
/////////////////////////////////////////////////////////////////////////////

// ref
gulp.task('ref', function() {
    var src = paths.src;//.concat(['!src/__intro.js', '!src/__outro.js']);
    var files = paths.ref.src.concat(src);
    var destPath = paths.ref.dest;
    return fb.generateReference(files, destPath);
});

gulp.task('all', ['default', 'test', 'ref'] );
gulp.task('ci', ['jshint', 'test'] );

// watch
gulp.task('watch', function() {
    gulp.watch(paths.src, ['dev']).on( 'error', gutil.log );
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var Server = require('karma').Server;

gulp.task('build', function () {
});

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

gulp.task('default', ['build', 'test']);
<commit_msg>gulp test will be used locally so disable singleRun<commit_after>var gulp = require('gulp');
var Server = require('karma').Server;

gulp.task('build', function () {
});

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

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


<commit_before>/* -------------------------------------------------------------------------------------------------

Build Configuration
Contributors: Luan Gjokaj

-------------------------------------------------------------------------------------------------- */
'use strict';
var babel = require('gulp-babel');
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var connect = require('gulp-connect-php');
var cssnano = require('cssnano');
var cssnext = require('postcss-cssnext');
var del = require('del');
var fs = require('fs');
var gulp = require('gulp');
var gutil = require('gulp-util');
var inject = require('gulp-inject-string');
var partialimport = require('postcss-easy-import');
var plumber = require('gulp-plumber');
var postcss = require('gulp-postcss');
var remoteSrc = require('gulp-remote-src');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var unzip = require('gulp-unzip');
var zip = require('gulp-zip');
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
PostCSS Plugins
-------------------------------------------------------------------------------------------------- */
var pluginsDev = [
	partialimport,
	cssnext({
		features: {
			colorHexAlpha: false
		}
	})
];
var pluginsProd = [
	partialimport,
	cssnext({
		features: {
			colorHexAlpha: false
		}
	})
];
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Header & Footer JavaScript Boundles
-------------------------------------------------------------------------------------------------- */
var headerJS = [
	'node_modules/jquery/dist/jquery.js',
	'node_modules/nprogress/nprogress.js',
	'node_modules/aos/dist/aos.js',
	'node_modules/isotope-layout/dist/isotope.pkgd.js'
];
var footerJS = [
	'src/js/**'
];
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Theme Name
-------------------------------------------------------------------------------------------------- */
var themeName = 'wordpressify';
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Installation Tasks
-------------------------------------------------------------------------------------------------- */
gulp.task('default');

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

gulp.task('download-wordpress', function () {
	remoteSrc(['latest.zip'], {
		base: 'https://wordpress.org/'
	})
		.pipe(gulp.dest('build/'));
});

gulp.task('setup', [
	'unzip-wordpress',
	'copy-config'
]);

gulp.task('unzip-wordpress', function () {
	gulp.src('build/latest.zip')
		.pipe(unzip())
		.pipe(gulp.dest('build/'))
});

gulp.task('copy-config', function () {
	gulp.src('wp-config.php')
		.pipe(gulp.dest('build/wordpress'));
});

gulp.task('disable-cron', function () {
	gulp.src('build/wordpress/wp-config.php')
		.pipe(inject.after('define(\'DB_COLLATE\', \'\');', '\ndefine(\'DISABLE_WP_CRON\', true);'))
		.pipe(gulp.dest('build/wordpress'))
		.on('end', function () {
			console.log(devServerReady);
			console.log(thankYou);
		});
});
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Development Tasks
-------------------------------------------------------------------------------------------------- */
gulp.task('build-dev', [
	'copy-theme-dev',
	'copy-fonts-dev',
	'style-dev',
	'header-scripts-dev',
	'footer-scripts-dev',
	'watch'

], function () {
	connect.server({
		base: 'build/wordpress',
		port: '3020'
	}, function () {
		browserSync({
			proxy: '127.0.0.1:3020'
		});
	});
});

gulp.task('copy-theme-dev', function () {
	if (!fs.existsSync('./build')) {
		console.log(buildNotFound);
		process.exit(1);
	} else {
		gulp.src('src/theme/**')
			.pipe(gulp.dest('build/wordpress/wp-content/themes/' + themeName));
	}
});

gulp.task('copy-fonts-dev', function () {
	gulp.src('src/fonts/**')
		.pipe(gulp.dest('build/wordpress/wp-content/themes/' + themeName + '/fonts'))
});

gulp.task('style-dev', function () {
	return gulp.src('src/style/style.css')
		.pipe(plumber({ errorHandler: onError }))
		.pipe(sourcemaps.init())
		.pipe(postcss(pluginsDev))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('build/wordpress/wp-content/themes/' + themeName))
		.pipe(browserSync.stream({ match: '**/*.css' }));
});

gulp.task('header-scripts-dev', function () {
	return gulp.src(headerJS)
		.pipe(plumber({ errorHandler: onError }))
		.pipe(sourcemaps.init())
		.pipe(concat('header-bundle.js'))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('build/wordpress/wp-content/themes/' + themeName + '/js'));
});

gulp.task('footer-scripts-dev', function () {
	return gulp.src(footerJS)
		.pipe(plumber({ errorHandler: onError }))
		.pipe(sourcemaps.init())
		.pipe(babel({
			presets: ['env']
		}))
		.pipe(concat('footer-bundle.js'))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('build/wordpress/wp-content/themes/' + themeName + '/js'));
});

gulp.task('reload-js', ['footer-scripts-dev', 'header-scripts-dev'], function (done) {
	browserSync.reload();
	done();
});

gulp.task('reload-fonts', ['copy-fonts-dev'], function (done) {
	browserSync.reload();
	done();
});

gulp.task('reload-theme', ['copy-theme-dev'], function (done) {
	browserSync.reload();
	done();
});

gulp.task('watch', function () {
	gulp.watch(['src/style/**/*.css'], ['style-dev']);
	gulp.watch(['src/js/**'], ['reload-js']);
	gulp.watch(['src/fonts/**'], ['reload-fonts']);
	gulp.watch(['src/theme/**'], ['reload-theme']);
});
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Production Tasks
-------------------------------------------------------------------------------------------------- */
gulp.task('build-prod', [
	'copy-theme-prod',
	'copy-fonts-prod',
	'style-prod',
	'header-scripts-prod',
	'footer-scripts-prod',
	'zip-theme'
], function () {
	console.log(filesGenerated);
	console.log(thankYou);
});

gulp.task('copy-theme-prod', function () {
	gulp.src('src/theme/**')
		.pipe(gulp.dest('dist/themes/' + themeName))
});

gulp.task('copy-fonts-prod', function () {
	gulp.src('src/fonts/**')
		.pipe(gulp.dest('dist/themes/' + themeName + '/fonts'))
});

gulp.task('style-prod', function () {
	return gulp.src('src/style/style.css')
		.pipe(plumber({ errorHandler: onError }))
		.pipe(postcss(pluginsProd))
		.pipe(gulp.dest('dist/themes/' + themeName))
});

gulp.task('header-scripts-prod', function () {
	return gulp.src(headerJS)
		.pipe(plumber({ errorHandler: onError }))
		.pipe(concat('header-bundle.js'))
		.pipe(uglify())
		.pipe(gulp.dest('dist/themes/' + themeName + '/js'));
});

gulp.task('footer-scripts-prod', function () {
	return gulp.src(footerJS)
		.pipe(plumber({ errorHandler: onError }))
		.pipe(babel({
			presets: ['env']
		}))
		.pipe(concat('footer-bundle.js'))
		.pipe(uglify())
		.pipe(gulp.dest('dist/themes/' + themeName + '/js'));
});

gulp.task('zip-theme', ['copy-theme-prod', 'copy-fonts-prod', 'style-prod', 'header-scripts-prod', 'footer-scripts-prod'], function () {
	gulp.src('dist/themes/' + themeName + '/**')
		.pipe(zip(themeName + '.zip'))
		.pipe(gulp.dest('dist'))
});
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Utilitie Tasks
 ------------------------------------------------------------------------------------------------- */
var onError = function (err) {
	gutil.beep();
	console.log(err.toString());
	this.emit('end');
};

var date = new Date().toLocaleDateString('en-GB').replace(/\//g, '.');
var devServerReady = 'Your development server is ready, start the workflow with the command: $ \x1b[1m npm run dev\x1b[0m';
var buildNotFound = '⚠　- You need to install WordPress first. Run the command: $ \x1b[1mnpm run install:wordpress\x1b[0m';
var filesGenerated = 'Your ZIP template file was generated in: \x1b[1m' + __dirname + '/dist/' + themeName + '.zip\x1b[0m - ✅';
var thankYou = 'Thank you for using \x1b[42m\x1b[1mWordPressify\x1b[0m';

gulp.task('backup', function () {
	if (!fs.existsSync('./build')) {
		console.log(buildNotFound);
		process.exit(1);
	} else {
		gulp.src('build/wordpress/**')
			.pipe(zip(date + '.zip'))
			.pipe(gulp.dest('backups'))
			.on('end', function () {
				console.log('Your backup was generated in: \x1b[1m' + __dirname + '/dist/backups/' + date + '.zip\x1b[0m - ✅');
			});
	}
});
/* -------------------------------------------------------------------------------------------------
End of all Tasks
-------------------------------------------------------------------------------------------------- */
<commit_msg>Fix link.<commit_after>/* -------------------------------------------------------------------------------------------------

Build Configuration
Contributors: Luan Gjokaj

-------------------------------------------------------------------------------------------------- */
'use strict';
var babel = require('gulp-babel');
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var connect = require('gulp-connect-php');
var cssnano = require('cssnano');
var cssnext = require('postcss-cssnext');
var del = require('del');
var fs = require('fs');
var gulp = require('gulp');
var gutil = require('gulp-util');
var inject = require('gulp-inject-string');
var partialimport = require('postcss-easy-import');
var plumber = require('gulp-plumber');
var postcss = require('gulp-postcss');
var remoteSrc = require('gulp-remote-src');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var unzip = require('gulp-unzip');
var zip = require('gulp-zip');
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
PostCSS Plugins
-------------------------------------------------------------------------------------------------- */
var pluginsDev = [
	partialimport,
	cssnext({
		features: {
			colorHexAlpha: false
		}
	})
];
var pluginsProd = [
	partialimport,
	cssnext({
		features: {
			colorHexAlpha: false
		}
	})
];
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Header & Footer JavaScript Boundles
-------------------------------------------------------------------------------------------------- */
var headerJS = [
	'node_modules/jquery/dist/jquery.js',
	'node_modules/nprogress/nprogress.js',
	'node_modules/aos/dist/aos.js',
	'node_modules/isotope-layout/dist/isotope.pkgd.js'
];
var footerJS = [
	'src/js/**'
];
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Theme Name
-------------------------------------------------------------------------------------------------- */
var themeName = 'wordpressify';
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Installation Tasks
-------------------------------------------------------------------------------------------------- */
gulp.task('default');

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

gulp.task('download-wordpress', function () {
	remoteSrc(['latest.zip'], {
		base: 'https://wordpress.org/'
	})
		.pipe(gulp.dest('build/'));
});

gulp.task('setup', [
	'unzip-wordpress',
	'copy-config'
]);

gulp.task('unzip-wordpress', function () {
	gulp.src('build/latest.zip')
		.pipe(unzip())
		.pipe(gulp.dest('build/'))
});

gulp.task('copy-config', function () {
	gulp.src('wp-config.php')
		.pipe(gulp.dest('build/wordpress'));
});

gulp.task('disable-cron', function () {
	gulp.src('build/wordpress/wp-config.php')
		.pipe(inject.after('define(\'DB_COLLATE\', \'\');', '\ndefine(\'DISABLE_WP_CRON\', true);'))
		.pipe(gulp.dest('build/wordpress'))
		.on('end', function () {
			console.log(devServerReady);
			console.log(thankYou);
		});
});
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Development Tasks
-------------------------------------------------------------------------------------------------- */
gulp.task('build-dev', [
	'copy-theme-dev',
	'copy-fonts-dev',
	'style-dev',
	'header-scripts-dev',
	'footer-scripts-dev',
	'watch'

], function () {
	connect.server({
		base: 'build/wordpress',
		port: '3020'
	}, function () {
		browserSync({
			proxy: '127.0.0.1:3020'
		});
	});
});

gulp.task('copy-theme-dev', function () {
	if (!fs.existsSync('./build')) {
		console.log(buildNotFound);
		process.exit(1);
	} else {
		gulp.src('src/theme/**')
			.pipe(gulp.dest('build/wordpress/wp-content/themes/' + themeName));
	}
});

gulp.task('copy-fonts-dev', function () {
	gulp.src('src/fonts/**')
		.pipe(gulp.dest('build/wordpress/wp-content/themes/' + themeName + '/fonts'))
});

gulp.task('style-dev', function () {
	return gulp.src('src/style/style.css')
		.pipe(plumber({ errorHandler: onError }))
		.pipe(sourcemaps.init())
		.pipe(postcss(pluginsDev))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('build/wordpress/wp-content/themes/' + themeName))
		.pipe(browserSync.stream({ match: '**/*.css' }));
});

gulp.task('header-scripts-dev', function () {
	return gulp.src(headerJS)
		.pipe(plumber({ errorHandler: onError }))
		.pipe(sourcemaps.init())
		.pipe(concat('header-bundle.js'))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('build/wordpress/wp-content/themes/' + themeName + '/js'));
});

gulp.task('footer-scripts-dev', function () {
	return gulp.src(footerJS)
		.pipe(plumber({ errorHandler: onError }))
		.pipe(sourcemaps.init())
		.pipe(babel({
			presets: ['env']
		}))
		.pipe(concat('footer-bundle.js'))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('build/wordpress/wp-content/themes/' + themeName + '/js'));
});

gulp.task('reload-js', ['footer-scripts-dev', 'header-scripts-dev'], function (done) {
	browserSync.reload();
	done();
});

gulp.task('reload-fonts', ['copy-fonts-dev'], function (done) {
	browserSync.reload();
	done();
});

gulp.task('reload-theme', ['copy-theme-dev'], function (done) {
	browserSync.reload();
	done();
});

gulp.task('watch', function () {
	gulp.watch(['src/style/**/*.css'], ['style-dev']);
	gulp.watch(['src/js/**'], ['reload-js']);
	gulp.watch(['src/fonts/**'], ['reload-fonts']);
	gulp.watch(['src/theme/**'], ['reload-theme']);
});
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Production Tasks
-------------------------------------------------------------------------------------------------- */
gulp.task('build-prod', [
	'copy-theme-prod',
	'copy-fonts-prod',
	'style-prod',
	'header-scripts-prod',
	'footer-scripts-prod',
	'zip-theme'
], function () {
	console.log(filesGenerated);
	console.log(thankYou);
});

gulp.task('copy-theme-prod', function () {
	gulp.src('src/theme/**')
		.pipe(gulp.dest('dist/themes/' + themeName))
});

gulp.task('copy-fonts-prod', function () {
	gulp.src('src/fonts/**')
		.pipe(gulp.dest('dist/themes/' + themeName + '/fonts'))
});

gulp.task('style-prod', function () {
	return gulp.src('src/style/style.css')
		.pipe(plumber({ errorHandler: onError }))
		.pipe(postcss(pluginsProd))
		.pipe(gulp.dest('dist/themes/' + themeName))
});

gulp.task('header-scripts-prod', function () {
	return gulp.src(headerJS)
		.pipe(plumber({ errorHandler: onError }))
		.pipe(concat('header-bundle.js'))
		.pipe(uglify())
		.pipe(gulp.dest('dist/themes/' + themeName + '/js'));
});

gulp.task('footer-scripts-prod', function () {
	return gulp.src(footerJS)
		.pipe(plumber({ errorHandler: onError }))
		.pipe(babel({
			presets: ['env']
		}))
		.pipe(concat('footer-bundle.js'))
		.pipe(uglify())
		.pipe(gulp.dest('dist/themes/' + themeName + '/js'));
});

gulp.task('zip-theme', ['copy-theme-prod', 'copy-fonts-prod', 'style-prod', 'header-scripts-prod', 'footer-scripts-prod'], function () {
	gulp.src('dist/themes/' + themeName + '/**')
		.pipe(zip(themeName + '.zip'))
		.pipe(gulp.dest('dist'))
});
//--------------------------------------------------------------------------------------------------
/* -------------------------------------------------------------------------------------------------
Utilitie Tasks
 ------------------------------------------------------------------------------------------------- */
var onError = function (err) {
	gutil.beep();
	console.log(err.toString());
	this.emit('end');
};

var date = new Date().toLocaleDateString('en-GB').replace(/\//g, '.');
var devServerReady = 'Your development server is ready, start the workflow with the command: $ \x1b[1m npm run dev\x1b[0m';
var buildNotFound = '⚠　- You need to install WordPress first. Run the command: $ \x1b[1mnpm run install:wordpress\x1b[0m';
var filesGenerated = 'Your ZIP template file was generated in: \x1b[1m' + __dirname + '/dist/' + themeName + '.zip\x1b[0m - ✅';
var thankYou = 'Thank you for using \x1b[42m\x1b[1mWordPressify\x1b[0m';

gulp.task('backup', function () {
	if (!fs.existsSync('./build')) {
		console.log(buildNotFound);
		process.exit(1);
	} else {
		gulp.src('build/wordpress/**')
			.pipe(zip(date + '.zip'))
			.pipe(gulp.dest('backups'))
			.on('end', function () {
				console.log('Your backup was generated in: \x1b[1m' + __dirname + '/backups/' + date + '.zip\x1b[0m - ✅');
			});
	}
});
/* -------------------------------------------------------------------------------------------------
End of all Tasks
-------------------------------------------------------------------------------------------------- */
<|endoftext|>


<commit_before>'use strict';

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

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

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

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

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

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

gulp.task('watch', ['build-js', 'build-css'], function () {
    watch(config.watchJS, function() {
        gulp.start('build-js');
    });
    watch(config.watchCSS, function() {
        gulp.start('build-css');
    });
});
<commit_msg>feat: Use gulp to serve local files<commit_after>'use strict';

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

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

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

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

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

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

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

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