<commit_before>var async = require("async");
var browserify = require("browserify");
var chalk = require("chalk");
var chmod = require("gulp-chmod");
var dateformat = require("dateformat");
var ejs = require("gulp-ejs");
var fs = require("fs");
var gulp = require("gulp");
var httpServer = require("http-server");
var rename = require("gulp-rename");
var slimerPath = require("slimerjs").path;
var source = require("vinyl-source-stream");
var spawn = require("child_process").spawn;

var log = function() {
	var time = "[" + chalk.blue(dateformat(new Date(), "HH:MM:ss")) + "]";
	var args = Array.prototype.slice.call(arguments);
	args.unshift(time);
	console.log.apply(console, args);
};

var runBrowserify = function(dir, callback) {
	var src = "./src/" + dir;
	var file = src + "/main.js";
	var dest = "./dist/examples/" + dir;

	var bundler = browserify(file);

	log("browserify " + chalk.cyan(dir) + " started");

	bundler.transform({ global: true }, "brfs");
	bundler.ignore("plask");

	bundler.on("log", function(data) {
		var logString = data.split(" ").map(function(word) {
			word = word.replace(/\(|\)/g, "");
			return !isNaN(word) ? chalk.magenta(word) : word;
		}).join(" ");

		log("browserify " + chalk.cyan(dir) + " " + logString);
	});

	bundler.on("error", function(error) {
		log(chalk.red(error.message));
	});

	bundler
		.bundle()
		.pipe(source("main.min.js"))
		.pipe(chmod(644))
		.pipe(gulp.dest(dest))
		.on("finish", function() {
			log("browserify " + chalk.cyan(dir) + " finished!");
			callback();
		});
};

var exampleHtml = function(dir, callback) {
	var src = "./templates/example.ejs";
	var dest = "./dist/examples/" + dir;

	gulp.src(src)
		.pipe(ejs({ title: dir }))
		.pipe(rename("index.html"))
		.pipe(gulp.dest(dest))
		.on("finish", callback);
};

var mkdir = function(dir, callback) {
	spawn("mkdir", [ "-p", dir ]).on("exit", callback);
};

gulp.task("browserify", [ "file-structure" ], function(callback) {
	var limit = 4;

	fs.readdir("./src/", function(error, directories) {
		if (error) { return console.error(error); }

		async.eachLimit(
			directories,
			limit,
			function(dir, callback) {
				fs.stat("./src/" + dir, function(error, stat) {
					if (error) { return callback(error); }
					if (!stat.isDirectory()) { return callback(); }

					async.series(
						[
							mkdir.bind(this, "./dist/examples/" + dir),
							exampleHtml.bind(this, dir),
							runBrowserify.bind(this, dir)
						],
						callback
					);
				});
			},
			callback
		);
	});
});

gulp.task("file-structure", function(callback) {
	log(chalk.cyan("file structure") + " building");

	async.each(
		[ "./dist/examples", "./dist/assets" ],
		mkdir,
		function() {
			gulp
				.src("./assets/**")
				.pipe(gulp.dest("./dist/assets/"))
				.on("finish", function() {
					log(chalk.cyan("file structure") + " done");
					callback();
				});
		}
	);
});

var startHttpServer = function(dir, callback) {
	var server = httpServer.createServer({ root: dir });
	server.listen(3000, function(err) {
		callback(err, dir, server);
	});
};

var slimerScreenshot = function(dir, serverInstance, callback) {
	var serverAddress = serverInstance.server.address();
	var url = "http://" + serverAddress.address + ":" + serverAddress.port;
	var thumbPath = dir + "/thumb.jpg";
  var spawned = spawn(slimerPath, [ "./utils/slimer-script.js", url, thumbPath ]);

	spawned.stdout.on("data", function(data) {
		log("slimer " + chalk.cyan(dir) + "\n" + data.toString());
  });

  spawned.on("exit", function(err) {
  	callback(err, dir, serverInstance);
  });
};

/*

gulp.task("make-screenshots", function(callback) {
	fs.readdir("./dist/examples/", function(error, directories) {
		if (error) { return console.error(error); }

		async.eachSeries(
			directories,

			function(dir, callback) {
				fs.stat("./dist/examples/" + dir, function(error, stat) {
					if (error) { return callback(error); }
					if (!stat.isDirectory()) { return callback(); }

					var server = null;
					dir = "./dist/examples/" + dir;

					async.series(
						[
							function(callback) {
								startHttpServer(dir, function(instance) {
									server = instance;
									callback();
								});
							},

							slimerScreenshot.bind(this, dir),
							moveScreenshot.bind(this, dir)
						],
						function() {
							server.close();
							callback();
						}
					);
				});
			},

			callback
		);
	});
});
*/

gulp.task("make-screenshots", function(callback) {
	var dirs = fs.readdirSync("./dist/examples/");

	dirs = dirs.map(function(dir) {
		return "./dist/examples/" + dir;
	});

	dirs = dirs.filter(function(dir) {
		var stat = fs.statSync(dir);
		if (!stat) return false;
		if (!stat.isDirectory) return false;
		return true;
	});

	async.eachSeries(
		dirs,
		function(dir, callback) {
			async.waterfall(
				[
					startHttpServer.bind(this, dir),
					slimerScreenshot
				],
				function(err, dir, serverInstance) {
					serverInstance.close();
					callback();
				}
			);
		},
		callback
	);
});

gulp.task("build-index", function(callback) {
	var src = "./templates/index.ejs";
	var dest = "./dist/";

	fs.readdir("./dist/examples/", function(error, directories) {
		if (error) { return console.error(error); }

		async.filter(
			directories,

			function(dir, callback) {
				fs.stat("./dist/examples/" + dir, function(error, stat) {
					if (error) { return callback(error); }
					callback(stat.isDirectory());
				});
			},

			function(examples) {
				gulp
					.src(src)
					.pipe(ejs({ examples: examples }))
					.pipe(gulp.dest(dest))
					.on("finish", callback);
			}
		);
	});
});

gulp.task("dist", function() {
	async.eachSeries(
		[
			"browserify",
			"make-screenshots",
			"build-index"
		],
		function(task, callback) {
			gulp.run(task, callback);
		}
	);
});
<commit_msg>Drastically simplified screenshot creation<commit_after>var async = require("async");
var browserify = require("browserify");
var chalk = require("chalk");
var chmod = require("gulp-chmod");
var dateformat = require("dateformat");
var ejs = require("gulp-ejs");
var fs = require("fs");
var gulp = require("gulp");
var httpServer = require("http-server");
var rename = require("gulp-rename");
var slimerPath = require("slimerjs").path;
var source = require("vinyl-source-stream");
var spawn = require("child_process").spawn;
var path = require('path');

var log = function() {
	var time = "[" + chalk.blue(dateformat(new Date(), "HH:MM:ss")) + "]";
	var args = Array.prototype.slice.call(arguments);
	args.unshift(time);
	console.log.apply(console, args);
};

var listSubDirs = function(parentDir) {
	var dirs = fs.readdirSync(parentDir);
	dirs = dirs.filter(function(dir) {
		var stat = fs.statSync(path.join(parentDir, dir));
		if (!stat) return false;
		if (!stat.isDirectory) return false;
		return true;
	});
	return dirs;
}

var runBrowserify = function(dir, callback) {
	var src = "./src/" + dir;
	var file = src + "/main.js";
	var dest = "./dist/examples/" + dir;

	var bundler = browserify(file);

	log("browserify " + chalk.cyan(dir) + " started");

	bundler.transform({ global: true }, "brfs");
	bundler.ignore("plask");

	bundler.on("log", function(data) {
		var logString = data.split(" ").map(function(word) {
			word = word.replace(/\(|\)/g, "");
			return !isNaN(word) ? chalk.magenta(word) : word;
		}).join(" ");

		log("browserify " + chalk.cyan(dir) + " " + logString);
	});

	bundler.on("error", function(error) {
		log(chalk.red(error.message));
	});

	bundler
		.bundle()
		.pipe(source("main.min.js"))
		.pipe(chmod(644))
		.pipe(gulp.dest(dest))
		.on("finish", function() {
			log("browserify " + chalk.cyan(dir) + " finished!");
			callback();
		});
};

var exampleHtml = function(dir, callback) {
	var src = "./templates/example.ejs";
	var dest = "./dist/examples/" + dir;

	gulp.src(src)
		.pipe(ejs({ title: dir }))
		.pipe(rename("index.html"))
		.pipe(gulp.dest(dest))
		.on("finish", callback);
};

var mkdir = function(dir, callback) {
	spawn("mkdir", [ "-p", dir ]).on("exit", callback);
};

gulp.task("browserify", [ "file-structure" ], function(callback) {
	var limit = 4;

	fs.readdir("./src/", function(error, directories) {
		if (error) { return console.error(error); }

		async.eachLimit(
			directories,
			limit,
			function(dir, callback) {
				fs.stat("./src/" + dir, function(error, stat) {
					if (error) { return callback(error); }
					if (!stat.isDirectory()) { return callback(); }

					async.series(
						[
							mkdir.bind(this, "./dist/examples/" + dir),
							exampleHtml.bind(this, dir),
							runBrowserify.bind(this, dir)
						],
						callback
					);
				});
			},
			callback
		);
	});
});

gulp.task("file-structure", function(callback) {
	log(chalk.cyan("file structure") + " building");

	async.each(
		[ "./dist/examples", "./dist/assets" ],
		mkdir,
		function() {
			gulp
				.src("./assets/**")
				.pipe(gulp.dest("./dist/assets/"))
				.on("finish", function() {
					log(chalk.cyan("file structure") + " done");
					callback();
				});
		}
	);
});

var slimerScreenshot = function(url, thumbPath, callback) {
	var spawned = spawn(slimerPath, [ "./utils/slimer-script.js", url, thumbPath ]);

	spawned.stdout.on("data", function(data) {
		log("slimer " + chalk.cyan(url) + "\n" + data.toString());
  });

  spawned.on("exit", callback);
};

gulp.task("make-screenshots", function(callback) {
	var examplesPath = "./dist/examples";
	var port = 3000;

	var dirs = listSubDirs(examplesPath);

	var server = httpServer.createServer({ root: "./dist/" });
	server.listen(port, function(err) {
		makeScreenshots();
	});

	function makeScreenshots() {
		async.eachSeries(
			dirs,
			function(dir, callback) {
				var url = "http://localhost:" + port + "/examples/" + dir + "/";
				var thumbPath = path.join(examplesPath, dir, "thumb.jpg");
				slimerScreenshot(url, thumbPath, callback)
			},
			function() {
				server.close();
				callback();
			}
		);
	}
});

gulp.task("build-index", function(callback) {
	var src = "./templates/index.ejs";
	var dest = "./dist/";

	fs.readdir("./dist/examples/", function(error, directories) {
		if (error) { return console.error(error); }

		async.filter(
			directories,

			function(dir, callback) {
				fs.stat("./dist/examples/" + dir, function(error, stat) {
					if (error) { return callback(error); }
					callback(stat.isDirectory());
				});
			},

			function(examples) {
				gulp
					.src(src)
					.pipe(ejs({ examples: examples }))
					.pipe(gulp.dest(dest))
					.on("finish", callback);
			}
		);
	});
});

gulp.task("dist", function() {
	async.eachSeries(
		[
			"browserify",
			"make-screenshots",
			"build-index"
		],
		function(task, callback) {
			gulp.run(task, callback);
		}
	);
});
<|endoftext|>


<commit_before>let gulp = require('gulp'),
    //Gulp packages
    concat = require('gulp-concat'),
    rename = require('gulp-rename'),
    uglify = require('gulp-uglify'),
    util = require('gulp-util'),
    cleanCSS = require('gulp-clean-css');
    connect = require('gulp-connect-php'),
    browserSync = require('browser-sync'),
    jshint = require('gulp-jshint');

    //Directories - modify to fit your app structure
    jsFiles = 'assets/js/*.js',
    jsDest = 'dist/scripts',
    stylesFiles = 'assets/css/*.css',
    stylesDest  = 'dist/styles',
    appURL = 'localhost:3000';

//Concat - Minify - Uglify JS
gulp.task('scripts', () => {
  return gulp.src(jsFiles)
    .pipe(concat('scripts.js'))
    .pipe(gulp.dest(jsDest))
    .pipe(rename('scripts.min.js'))
    .pipe(uglify().on('error', util.log))
    .pipe(gulp.dest(jsDest));
});

//Minify Styles
gulp.task('styles', () => {
  return gulp.src(stylesFiles)
    .pipe(cleanCSS({compatibility: 'ie8'}))
    .pipe(gulp.dest('dist/styles'));
});

//Lint JS files
gulp.task('jslint', () => {
  return gulp.src('assets/js/*.js')
    .pipe(jshint({ linter: require('jshint').JSXHINT }))
   .pipe(jshint.reporter('default'));
});

//Compress Images
gulp.task('images', () => {
  return gulp.src('assets/images/**/*.+(png|jpg|jpeg|gif|svg)')
    .pipe(imagemin({
      interlaced: true
    }))
    .pipe(gulp.dest('dist/images'));
});

//Livereload with BrowserSync
gulp.task('livereload', () => {
  connect.server({}, () => {
    browserSync({
      proxy: appURL
    });
  });
  gulp.watch('**/*.*').on('change', () =>  {
    browserSync.reload();
  });
});

//The default gulp task when running gulp in the cli
gulp.task('default', ['jslint', 'livereload']);
<commit_msg>Changes util variable name to avoid nodejs conflicts<commit_after>let gulp = require('gulp'),
    //Gulp packages
    concat = require('gulp-concat'),
    rename = require('gulp-rename'),
    uglify = require('gulp-uglify'),
    gutil = require('gulp-util'),
    cleanCSS = require('gulp-clean-css');
    connect = require('gulp-connect-php'),
    browserSync = require('browser-sync'),
    jshint = require('gulp-jshint');

    //Directories - modify to fit your app structure
    jsFiles = 'assets/js/*.js',
    jsDest = 'dist/scripts',
    stylesFiles = 'assets/css/*.css',
    stylesDest  = 'dist/styles',
    appURL = 'localhost:3000';

//Concat - Minify - Uglify JS
gulp.task('scripts', () => {
  return gulp.src(jsFiles)
    .pipe(concat('scripts.js'))
    .pipe(gulp.dest(jsDest))
    .pipe(rename('scripts.min.js'))
    .pipe(uglify().on('error', util.log))
    .pipe(gulp.dest(jsDest));
});

//Minify Styles
gulp.task('styles', () => {
  return gulp.src(stylesFiles)
    .pipe(cleanCSS({compatibility: 'ie8'}))
    .pipe(gulp.dest('dist/styles'));
});

//Lint JS files
gulp.task('jslint', () => {
  return gulp.src('assets/js/*.js')
    .pipe(jshint({ linter: require('jshint').JSXHINT }))
   .pipe(jshint.reporter('default'));
});

//Compress Images
gulp.task('images', () => {
  return gulp.src('assets/images/**/*.+(png|jpg|jpeg|gif|svg)')
    .pipe(imagemin({
      interlaced: true
    }))
    .pipe(gulp.dest('dist/images'));
});

//Livereload with BrowserSync
gulp.task('livereload', () => {
  connect.server({}, () => {
    browserSync({
      proxy: appURL
    });
  });
  gulp.watch('**/*.*').on('change', () =>  {
    browserSync.reload();
  });
});

//The default gulp task when running gulp in the cli
gulp.task('default', ['jslint', 'livereload']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var istanbul = require('gulp-istanbul');
var mocha = require('gulp-mocha'); // Using mocha here, but any test framework will work

gulp.task('test', function (cb) {
  gulp.src(['db/**/*.js', 'main.js'])
    .pipe(istanbul()) // Covering files
    .on('finish', function () {
      gulp.src(['test/*.js'])
        .pipe(mocha())
        .pipe(istanbul.writeReports()) // Creating the reports after tests runned
        .on('end', cb);
    });
});<commit_msg>add gulp for code coverage<commit_after>var gulp = require('gulp');
var istanbul = require('gulp-istanbul');
var mocha = require('gulp-mocha'); // Using mocha here, but any test framework will work

gulp.task('test', function (cb) {
  gulp.src(['db/**/*.js'])
    .pipe(istanbul()) // Covering files
    .on('finish', function () {
      gulp.src(['test/*.js'])
        .pipe(mocha())
        .pipe(istanbul.writeReports()) // Creating the reports after tests runned
        .on('end', cb);
    });
});<|endoftext|>


<commit_before>'use strict';
// Generated on 2014-03-21 using generator-browserify 0.2.2

var path = require('path'),
    gulp = require('gulp'),
    bower = 'app/bower_components',
    config = require(path.resolve(__dirname, 'package')).devConfig;

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

// Styles
gulp.task('styles', function () {
    return gulp.src('app/less/app.less')
    // Leaving out recess support due to string interpolation missing in less v1.3 (which recess is dependent on)
    // .pipe($.recess())
    .pipe($.less({
        style: 'expanded',
        loadPath: [bower]
    }))
        .pipe($.autoprefixer('last 1 version'))
        .pipe($.csso())
        .pipe(gulp.dest('dist/styles'))
        .pipe($.size())
        .pipe($.connect.reload());
});

// Scripts
gulp.task('scripts', function () {
    var stringify = require('stringify'),
        condition = typeof gulp.tasks.release !== 'undefined' ? gulp.tasks.release.running : false;
    return gulp.src('app/scripts/main.js')
        .pipe($.browserify({
            debug: true,
            transform: [
        'debowerify',
        stringify(['.html'])
      ],
            // Note: At this time it seems that you will also have to
            // setup browserify-shims in package.json to correctly handle
            // the exclusion of vendor vendor libraries from your bundle
            extensions: ['.js'],
            external: ['lodash','jquery']
        }))
    .pipe($.if(condition, $.uglify()))
    .pipe(gulp.dest('dist/scripts'))
        .pipe($.size())
        .pipe($.connect.reload());
});

// HTML
gulp.task('html', function () {
    return gulp.src('app/*.html')
        .pipe(gulp.dest('dist'))
        .pipe($.size())
        .pipe($.connect.reload());
});

// Lint
gulp.task('lint', function () {
    return gulp.src('app/scripts/**/*.js')
        .pipe($.jshint('.jshintrc'))
        .pipe($.jshint.reporter(require('jshint-stylish')));
});

// Images
gulp.task('images', function () {
    return gulp.src(['app/images/**/*', bower + '/leaflet-bower/dist/images/*'])
        .pipe($.cache($.imagemin({
            optimizationLevel: 3,
            progressive: true,
            interlaced: true
        })))
        .pipe(gulp.dest('dist/images'))
        .pipe($.size());
});

// Clean
gulp.task('clean', function () {
    return gulp.src(['dist/styles', 'dist/scripts', 'dist/images'], {
        read: false
    }).pipe($.clean());
});

// Connect
gulp.task('connect', $.connect.server({
    root: __dirname + '/dist',
    port: 9000,
    livereload: {
        port: 35729
    },
    open: {
        file: 'index.html',
        browser: 'Google Chrome'
    },
    middleware: function connect(connect, o) {
        if (config.proxy.enabled === true) {
            var proxy = require('proxy-middleware'),
                memorize = require('connect-memorize'),
                url = require('url');

            var baseURL = config.proxy.backendURL,
                middlewares = [];

            config.proxy.routes.forEach(function(route) {
                middlewares.push(memorize({
                    match: '/' + route, // handle only urls starting with $expression
                    memorize: true, // store stuff
                    recall: true, // serve previously stored
                    storageDir: config.proxy.cacheDir
                }));
                middlewares.push(connect().use('/' + route, proxy(url.parse(baseURL + route))));
            });

            return middlewares;
        }
    }
}));

// Watch
gulp.task('watch', ['connect'], function () {
    // Watch for changes in `app` folder
    gulp.watch([
        'app/less/**/*.less',
        'app/scripts/**/*.js',
        'app/images/**/*',
    ], $.connect.reload);

    // Watch .less files
    gulp.watch('app/less/**/*.less', ['styles']);

    // Watch .js files
    gulp.watch('app/scripts/**/*.js', ['scripts']);

    // Watch image files
    gulp.watch('app/images/**/*', ['images']);

    // Watch .html files
    gulp.watch('app/**/*.html', ['html']);
});

gulp.task('deploy', function() {
    var rsync = require('rsyncwrapper').rsync,
        path = require('path');

    return rsync({
        src: path.resolve(__dirname, 'dist/*'),
        dest: config.deployURI,
        ssh: true,
        recursive: true,
    }, function(error, stdout, stderr, cmd) {
        if (error) console.log(error.message);
    });
});

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

// Dev Server
gulp.task('dev', ['clean', 'build', 'connect', 'watch']);

// Release task
gulp.task('release', ['build']);

// Default task
gulp.task('default', ['dev']);
<commit_msg>fixing release bug, now is minifying<commit_after>'use strict';
// Generated on 2014-03-21 using generator-browserify 0.2.2

var path = require('path'),
    gulp = require('gulp'),
    bower = 'app/bower_components',
    config = require(path.resolve(__dirname, 'package')).devConfig;

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

// Styles
gulp.task('styles', function () {
    return gulp.src('app/less/app.less')
    // Leaving out recess support due to string interpolation missing in less v1.3 (which recess is dependent on)
    // .pipe($.recess())
    .pipe($.less({
        style: 'expanded',
        loadPath: [bower]
    }))
        .pipe($.autoprefixer('last 1 version'))
        .pipe($.csso())
        .pipe(gulp.dest('dist/styles'))
        .pipe($.size())
        .pipe($.connect.reload());
});

// Scripts
gulp.task('scripts', function () {
    var stringify = require('stringify'),
        condition = typeof gulp.tasks.release !== 'undefined' ? gulp.tasks.release.running : false;
    return gulp.src('app/scripts/main.js')
        .pipe($.browserify({
            debug: true,
            transform: [
        'debowerify',
        stringify(['.html'])
      ],
            // Note: At this time it seems that you will also have to
            // setup browserify-shims in package.json to correctly handle
            // the exclusion of vendor vendor libraries from your bundle
            extensions: ['.js'],
            external: ['lodash','jquery']
        }))
    .pipe($.if(condition, $.uglify()))
    .pipe(gulp.dest('dist/scripts'))
        .pipe($.size())
        .pipe($.connect.reload());
});

// HTML
gulp.task('html', function () {
    return gulp.src('app/*.html')
        .pipe(gulp.dest('dist'))
        .pipe($.size())
        .pipe($.connect.reload());
});

// Lint
gulp.task('lint', function () {
    return gulp.src('app/scripts/**/*.js')
        .pipe($.jshint('.jshintrc'))
        .pipe($.jshint.reporter(require('jshint-stylish')));
});

// Images
gulp.task('images', function () {
    return gulp.src(['app/images/**/*', bower + '/leaflet-bower/dist/images/*'])
        .pipe($.cache($.imagemin({
            optimizationLevel: 3,
            progressive: true,
            interlaced: true
        })))
        .pipe(gulp.dest('dist/images'))
        .pipe($.size());
});

// Clean
gulp.task('clean', function () {
    return gulp.src(['dist/styles', 'dist/scripts', 'dist/images'], {
        read: false
    }).pipe($.clean());
});

// Connect
gulp.task('connect', $.connect.server({
    root: __dirname + '/dist',
    port: 9000,
    livereload: {
        port: 35729
    },
    open: {
        file: 'index.html',
        browser: 'Google Chrome'
    },
    middleware: function connect(connect, o) {
        if (config.proxy.enabled === true) {
            var proxy = require('proxy-middleware'),
                memorize = require('connect-memorize'),
                url = require('url');

            var baseURL = config.proxy.backendURL,
                middlewares = [];

            config.proxy.routes.forEach(function(route) {
                middlewares.push(memorize({
                    match: '/' + route, // handle only urls starting with $expression
                    memorize: true, // store stuff
                    recall: true, // serve previously stored
                    storageDir: config.proxy.cacheDir
                }));
                middlewares.push(connect().use('/' + route, proxy(url.parse(baseURL + route))));
            });

            return middlewares;
        }
    }
}));

// Watch
gulp.task('watch', ['connect'], function () {
    // Watch for changes in `app` folder
    gulp.watch([
        'app/less/**/*.less',
        'app/scripts/**/*.js',
        'app/images/**/*',
    ], $.connect.reload);

    // Watch .less files
    gulp.watch('app/less/**/*.less', ['styles']);

    // Watch .js files
    gulp.watch('app/scripts/**/*.js', ['scripts']);

    // Watch image files
    gulp.watch('app/images/**/*', ['images']);

    // Watch .html files
    gulp.watch('app/**/*.html', ['html']);
});

gulp.task('deploy', function() {
    var rsync = require('rsyncwrapper').rsync,
        path = require('path');

    return rsync({
        src: path.resolve(__dirname, 'dist/*'),
        dest: config.deployURI,
        ssh: true,
        recursive: true,
    }, function(error, stdout, stderr, cmd) {
        if (error) console.log(error.message);
    });
});

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

// Dev Server
gulp.task('dev', ['clean', 'build', 'connect', 'watch']);

// Release task
gulp.task('release', function() {
    gulp.start('build');
});

// Default task
gulp.task('default', ['dev']);
<|endoftext|>


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

gulp.task('jshint', function() {
    gulp.src(['./lib/**/*.js', './*.js'])
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('default', ['jshint'], function() {});
<commit_msg>Added clean task to gulpfile<commit_after>var gulp = require('gulp');
var jshint = require('gulp-jshint');
var del = require('del');

gulp.task('clean', function() {
    del(['node_modules', 'coverage'], function(err, delfiles) {
        return err;
    });
});

gulp.task('jshint', function() {
    gulp.src(['./lib/**/*.js', './*.js'])
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('default', ['jshint'], function() {});
<|endoftext|>


<commit_before>const path = require('path')
const gulp = require('gulp')
const mono = require('gulp-tasks-monorepo')
const babel = require('gulp-babel')
const del = require('del')

const repo = mono({
  dir: path.join(__dirname, 'packages'),
  quiet: true
})

//------------------------------
// Helpers
//------------------------------

const pkgGlob = (pkg, glob, negate = false) =>
  `${negate ? '!' : ''}${path.join(pkg.location(), glob)}`

const srcGlob = (pkg) => [
  pkgGlob(pkg, 'src/**/*.js'),
  pkgGlob(pkg, 'src/**/*.test.js', true)
]

//------------------------------
// Tasks
//------------------------------

repo.task('clean', (pkg) => {
  return del(pkgGlob(pkg, 'dist'))
})

repo.task('reset', [ 'clean' ], (pkg) => {
  return del(pkgGlob(pkg, '?(node_modules|yarn.lock)'))
})

repo.task('build', [ 'clean' ], (pkg) => {
  return gulp
    .src(srcGlob(pkg))
    .pipe(babel())
    .pipe(gulp.dest(pkgGlob(pkg, 'dist')))
})
<commit_msg>updated tasks<commit_after>const path = require('path')
const monorepo = require('gulp-tasks-monorepo')
const babel = require('gulp-babel')
const gulp = require('gulp')
const del = require('del')

const mono = monorepo({
  dir: path.join(__dirname, 'packages'),
  quiet: true
})

//------------------------------
// Helpers
//------------------------------

const pkgGlob = (pkg, glob, negate = false) =>
  `${negate ? '!' : ''}${path.join(pkg.location(), glob)}`

const srcGlob = (pkg) => [
  pkgGlob(pkg, 'src/**/*.js'),
  pkgGlob(pkg, 'src/**/*.test.js', true)
]

//------------------------------
// Tasks
//------------------------------

mono.task('mono:clean', (pkg) => {
  return del(pkgGlob(pkg, 'dist'))
})

mono.task('mono:reset', [ 'mono:clean' ], (pkg) => {
  return del(pkgGlob(pkg, '?(node_modules|yarn.lock)'))
})

mono.task('mono:build', [ 'mono:clean' ], (pkg) => {
  return gulp
    .src(srcGlob(pkg))
    .pipe(babel())
    .pipe(gulp.dest(pkgGlob(pkg, 'dist')))
})

gulp.task('build', [ 'mono:build' ])
gulp.task('clean', [ 'mono:clean' ])
gulp.task('reset', [ 'mono:reset' ], () => {
  return del('?(node_modules|yarn.lock)')
})
<|endoftext|>


<commit_before>var fs        = require('fs');
var path      = require('path');
var jshint    = require('gulp-jshint');
var stylish   = require('jshint-stylish');
var concat    = require('gulp-concat');
var uglify    = require('gulp-uglify');
var imagemin  = require('gulp-imagemin');
var sourcemaps = require('gulp-sourcemaps');
var notify    = require('gulp-notify');
var rename    = require('gulp-rename');
var cache     = require('gulp-cache');
var minifycss = require('gulp-minify-css');
var less      = require('gulp-less');
var path      = require('path');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var webserver = require('gulp-webserver');
var plumber   = require('gulp-plumber');
var gulp      = require('gulp');
var Server = require('karma').Server;
var plugins   = require('gulp-load-plugins')(); // Load all gulp plugins
                                              // automatically and attach
                                              // them to the `plugins` object

var runSequence = require('run-sequence');    // Temporary solution until gulp 4
                                              // https://github.com/gulpjs/gulp/issues/355

var pkg  = require('./package.json');
var dirs = pkg['h5bp-configs'].directories;

// ---------------------------------------------------------------------
// | Helper tasks                                                      |
// ---------------------------------------------------------------------

gulp.task('archive:create_archive_dir', function () {
    fs.mkdirSync(path.resolve(dirs.archive), '0755');
});

gulp.task('archive:zip', function (done) {

    var archiveName = path.resolve(dirs.archive, pkg.name + '_v' + pkg.version + '.zip');
    var archiver = require('archiver')('zip');
    var files = require('glob').sync('**/*.*', {
        'cwd': dirs.dist,
        'dot': true // include hidden files
    });
    var output = fs.createWriteStream(archiveName);

    archiver.on('error', function (error) {
        done();
        throw error;
    });

    output.on('close', done);

    files.forEach(function (file) {

        var filePath = path.resolve(dirs.dist, file);

        // `archiver.bulk` does not maintain the file
        // permissions, so we need to add files individually
        archiver.append(fs.createReadStream(filePath), {
            'name': file,
            'mode': fs.statSync(filePath)
        });

    });

    archiver.pipe(output);
    archiver.finalize();

});

gulp.task('clean', function (done) {
    require('del')([
        dirs.archive,
        dirs.dist
    ], done);
});

gulp.task('copy', [
    'copy:.htaccess',
    'copy:index.html',
    'copy:jquery',
    'copy:license',
    'copy:main.css',
    'copy:misc',
    'copy:normalize'
]);

gulp.task('copy:.htaccess', function () {
    return gulp.src('node_modules/apache-server-configs/dist/.htaccess')
               .pipe(plugins.replace(/# ErrorDocument/g, 'ErrorDocument'))
               .pipe(gulp.dest(dirs.dist));
});

gulp.task('copy:index.html', function () {
    return gulp.src(dirs.src + '/index.html')
               .pipe(plugins.replace(/{{JQUERY_VERSION}}/g, pkg.devDependencies.jquery))
               .pipe(gulp.dest(dirs.dist));
});

gulp.task('copy:jquery', function () {
    return gulp.src(['node_modules/jquery/dist/jquery.min.js'])
               .pipe(plugins.rename('jquery-' + pkg.devDependencies.jquery + '.min.js'))
               .pipe(gulp.dest(dirs.dist + '/js/vendor'));
});

gulp.task('copy:license', function () {
    return gulp.src('LICENSE.txt')
               .pipe(gulp.dest(dirs.dist));
});

gulp.task('copy:main.css', function () {

    var banner = '/*! HTML5 Boilerplate v' + pkg.version +
                    ' | ' + pkg.license.type + ' License' +
                    ' | ' + pkg.homepage + ' */\n\n';

    return gulp.src(dirs.src + '/css/main.css')
               .pipe(plugins.header(banner))
               .pipe(plugins.autoprefixer({
                   browsers: ['last 2 versions', 'ie >= 8', '> 1%'],
                   cascade: false
               }))
               .pipe(gulp.dest(dirs.dist + '/css'));
});

gulp.task('copy:misc', function () {
    return gulp.src([

        // Copy all files
        dirs.src + '/**/*',

        // Exclude the following files
        // (other tasks will handle the copying of these files)
        '!' + dirs.src + '/css/main.css',
        '!' + dirs.src + '/index.html'

    ], {

        // Include hidden files by default
        dot: true

    }).pipe(gulp.dest(dirs.dist));
});

gulp.task('copy:normalize', function () {
    return gulp.src('node_modules/normalize.css/normalize.css')
               .pipe(gulp.dest(dirs.dist + '/css'));
});

gulp.task('lint:js', function () {
    return gulp.src([
        'gulpfile.js',
        dirs.src + '/js/**/*.js'
    ]).pipe(plugins.jscs())
      .pipe(plugins.jshint())
      .pipe(plugins.jshint.reporter('jshint-stylish'))
      .pipe(plugins.jshint.reporter('fail'));
});

gulp.task('webserver', function () {
    gulp.src('src')
    .pipe(webserver({
        livereload: true,
        directoryListing: false,
        open: true
    }));
});

gulp.task('jshint', function () {
    return gulp.src('src/js/**/*.js')
    .pipe(plumber())
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(concat('main.js'))
    .pipe(gulp.dest('dist/js'))
    .pipe(rename({suffix: '.min'}))
    .pipe(uglify())
    .pipe(gulp.dest('dist/js'))
    .pipe(browserSync.stream({stream:true}))
    .pipe(notify({ message: 'Jshint task complete'}));
});

gulp.task('less', function () {
    return gulp.src('src/less/main.less')
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(less())
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('src/css'))
    .pipe(rename({suffix: '.min'}))
    .pipe(minifycss())
    .pipe(gulp.dest('dist/css'))
    .pipe(browserSync.stream({stream:true}))
    .pipe(notify({ message: 'Less task complete'}));
});

gulp.task('images', function () {
    return gulp.src('src/img/**/*')
    .pipe(plumber())
    .pipe(cache(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true })))
    .pipe(gulp.dest('dist/img'))
    .pipe(browserSync.stream({stream:true}))
    .pipe(notify({ message: 'Image task complete'}));
});

gulp.task('html', function (){
    return gulp.src('src/*.html')
    .pipe(plumber())
    .pipe(gulp.dest('dist/'))
    .pipe(browserSync.stream({stream:true}))
    .pipe(notify({ message: 'Html task complete'}));
});

gulp.task('watch', function () {
    gulp.watch('src/img/**/*', ['images'], browserSync.reload);
    gulp.watch('src/js/**/*.js', ['jshint'], browserSync.reload);
    gulp.watch('src/less/*.less', ['less'], browserSync.reload);
    gulp.watch('src/js/app/*.spec.js', ['test'], browserSync.reload);
    gulp.watch('src/*.html', ['html'], browserSync.reload);
    gulp.watch('src/*.html').on('change', browserSync.reload);
});

gulp.task('serve', function () {
     browserSync.init({
        server: {
            baseDir: "src/.",
            open: "local",
            browser: "google chrome"
        }
    });

    gulp.watch('src/img/**/*', ['images']);
    gulp.watch('src/js/**/*.js', ['jshint']);
    gulp.watch('src/less/*.less', ['less']);
    gulp.watch('src/js/app/*.spec.js', ['test']);
    gulp.watch('src/*.html', ['html']);
    gulp.watch('src/*.html').on('change', browserSync.reload);
});

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

gulp.task('archive', function (done) {
    runSequence(
        'build',
        'archive:create_archive_dir',
        'archive:zip',
    done);
});

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

gulp.task('default', ['clean'], function(){
    gulp.start('serve', 'test', 'watch', 'images', 'jshint', 'html', 'less', browserSync.reload);
});
<commit_msg>Master - Changes to the gulpfile.js<commit_after>var fs        = require('fs');
var path      = require('path');
var jshint    = require('gulp-jshint');
var stylish   = require('jshint-stylish');
var concat    = require('gulp-concat');
var uglify    = require('gulp-uglify');
var imagemin  = require('gulp-imagemin');
var sourcemaps = require('gulp-sourcemaps');
var notify    = require('gulp-notify');
var rename    = require('gulp-rename');
var cache     = require('gulp-cache');
var minifycss = require('gulp-minify-css');
var less      = require('gulp-less');
var path      = require('path');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var webserver = require('gulp-webserver');
var plumber   = require('gulp-plumber');
var gulp      = require('gulp');
var Server = require('karma').Server;
var plugins   = require('gulp-load-plugins')(); // Load all gulp plugins
                                              // automatically and attach
                                              // them to the `plugins` object

var runSequence = require('run-sequence');    // Temporary solution until gulp 4
                                              // https://github.com/gulpjs/gulp/issues/355

var pkg  = require('./package.json');
var dirs = pkg['h5bp-configs'].directories;

// ---------------------------------------------------------------------
// | Helper tasks                                                      |
// ---------------------------------------------------------------------

gulp.task('archive:create_archive_dir', function () {
    fs.mkdirSync(path.resolve(dirs.archive), '0755');
});

gulp.task('archive:zip', function (done) {

    var archiveName = path.resolve(dirs.archive, pkg.name + '_v' + pkg.version + '.zip');
    var archiver = require('archiver')('zip');
    var files = require('glob').sync('**/*.*', {
        'cwd': dirs.dist,
        'dot': true // include hidden files
    });
    var output = fs.createWriteStream(archiveName);

    archiver.on('error', function (error) {
        done();
        throw error;
    });

    output.on('close', done);

    files.forEach(function (file) {

        var filePath = path.resolve(dirs.dist, file);

        // `archiver.bulk` does not maintain the file
        // permissions, so we need to add files individually
        archiver.append(fs.createReadStream(filePath), {
            'name': file,
            'mode': fs.statSync(filePath)
        });

    });

    archiver.pipe(output);
    archiver.finalize();

});

gulp.task('clean', function (done) {
    require('del')([
        dirs.archive,
        dirs.dist
    ], done);
});

gulp.task('copy', [
    'copy:.htaccess',
    'copy:index.html',
    'copy:jquery',
    'copy:license',
    'copy:main.css',
    'copy:misc',
    'copy:normalize'
]);

gulp.task('copy:.htaccess', function () {
    return gulp.src('node_modules/apache-server-configs/dist/.htaccess')
               .pipe(plugins.replace(/# ErrorDocument/g, 'ErrorDocument'))
               .pipe(gulp.dest(dirs.dist));
});

gulp.task('copy:index.html', function () {
    return gulp.src(dirs.src + '/index.html')
               .pipe(plugins.replace(/{{JQUERY_VERSION}}/g, pkg.devDependencies.jquery))
               .pipe(gulp.dest(dirs.dist));
});

gulp.task('copy:jquery', function () {
    return gulp.src(['node_modules/jquery/dist/jquery.min.js'])
               .pipe(plugins.rename('jquery-' + pkg.devDependencies.jquery + '.min.js'))
               .pipe(gulp.dest(dirs.dist + '/js/vendor'));
});

gulp.task('copy:license', function () {
    return gulp.src('LICENSE.txt')
               .pipe(gulp.dest(dirs.dist));
});

gulp.task('copy:main.css', function () {

    var banner = '/*! HTML5 Boilerplate v' + pkg.version +
                    ' | ' + pkg.license.type + ' License' +
                    ' | ' + pkg.homepage + ' */\n\n';

    return gulp.src(dirs.src + '/css/main.css')
               .pipe(plugins.header(banner))
               .pipe(plugins.autoprefixer({
                   browsers: ['last 2 versions', 'ie >= 8', '> 1%'],
                   cascade: false
               }))
               .pipe(gulp.dest(dirs.dist + '/css'));
});

gulp.task('copy:misc', function () {
    return gulp.src([

        // Copy all files
        dirs.src + '/**/*',

        // Exclude the following files
        // (other tasks will handle the copying of these files)
        '!' + dirs.src + '/css/main.css',
        '!' + dirs.src + '/index.html'

    ], {

        // Include hidden files by default
        dot: true

    }).pipe(gulp.dest(dirs.dist));
});

gulp.task('copy:normalize', function () {
    return gulp.src('node_modules/normalize.css/normalize.css')
               .pipe(gulp.dest(dirs.dist + '/css'));
});

gulp.task('lint:js', function () {
    return gulp.src([
        'gulpfile.js',
        dirs.src + '/js/**/*.js'
    ]).pipe(plugins.jscs())
      .pipe(plugins.jshint())
      .pipe(plugins.jshint.reporter('jshint-stylish'))
      .pipe(plugins.jshint.reporter('fail'));
});

gulp.task('webserver', function () {
    gulp.src('src')
    .pipe(webserver({
        livereload: true,
        directoryListing: false,
        open: true
    }));
});

gulp.task('jshint', function () {
    return gulp.src('src/js/**/*.js')
    .pipe(plumber())
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(concat('main.js'))
    .pipe(gulp.dest('dist/js'))
    .pipe(rename({suffix: '.min'}))
    .pipe(uglify())
    .pipe(gulp.dest('dist/js'))
    .pipe(browserSync.stream({stream:true}))
    .pipe(notify({ message: 'Jshint task complete'}));
});

gulp.task('less', function () {
    return gulp.src('src/less/main.less')
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(less())
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('src/css'))
    .pipe(rename({suffix: '.min'}))
    .pipe(minifycss())
    .pipe(gulp.dest('dist/css'))
    .pipe(browserSync.stream({stream:true}))
    .pipe(notify({ message: 'Less task complete'}));
});

gulp.task('images', function () {
    return gulp.src('src/img/**/*')
    .pipe(plumber())
    .pipe(cache(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true })))
    .pipe(gulp.dest('dist/img'))
    .pipe(browserSync.stream({stream:true}))
    .pipe(notify({ message: 'Image task complete'}));
});

gulp.task('html', function (){
    return gulp.src('src/*.html')
    .pipe(plumber())
    .pipe(gulp.dest('dist/'))
    .pipe(browserSync.stream({stream:true}))
    .pipe(notify({ message: 'Html task complete'}));
});

gulp.task('watch', function () {
    gulp.watch('src/img/**/*', ['images'], browserSync.reload);
    gulp.watch('src/js/**/*.js', ['jshint'], browserSync.reload);
    gulp.watch('src/less/*.less', ['less'], browserSync.reload);
    gulp.watch('src/js/app/*.spec.js', ['test'], browserSync.reload);
    gulp.watch('src/*.html', ['html'], browserSync.reload);
    gulp.watch('src/*.html').on('change', browserSync.reload);
});

gulp.task('serve', ['images', 'jshint', 'html', 'less'], function () {
     browserSync.init({
        server: {
            baseDir: "src/.",
            open: "local",
            browser: "google chrome"
        }
    });

    gulp.watch('src/img/**/*', ['images']);
    gulp.watch('src/js/**/*.js', ['jshint']);
    gulp.watch('src/less/*.less', ['less']);
    gulp.watch('src/js/app/*.spec.js', ['test']);
    gulp.watch('src/*.html', ['html']);
    gulp.watch('src/*.html').on('change', browserSync.reload);
});

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

gulp.task('archive', function (done) {
    runSequence(
        'build',
        'archive:create_archive_dir',
        'archive:zip',
    done);
});

gulp.task('build', ['images', 'jshint', 'less', 'html']);

gulp.task('default', ['clean'], function(){
    gulp.start('serve', 'test', 'watch', browserSync.reload);
});
<|endoftext|>


<commit_before>const gulp = require('gulp')
const babel = require('gulp-babel')
const concat = require('gulp-concat')
const nodemon = require('gulp-nodemon')
const forever = require('forever-monitor')
const rename = require('gulp-rename')
const props2json = require('gulp-props2json')
const insert = require('gulp-insert')
const clean = require('gulp-clean')
const extReplace = require('gulp-ext-replace')
const webpack = require('webpack-stream')
const gulpSync = require('gulp-sync')(gulp)

/****************** CONST ******************/

const dir_client_translation = './src/client/vuex/modules/locale/translations'
const dir_asset_src = './src/client/resource/*'
const dir_asset_dest = './public'
const file_front_app = './src/server/front/app.js'
const file_back_app = './src/server/back/app.js'

const nodemon_common_ignore = [
    // nodemon is only listening for .js and .vue files
    'gulpfile.js', 'node-modules', 'public', 'src/test', '.git', 'src/client/', 'package.json'
]
const files_front_nodemon_ignore = nodemon_common_ignore.concat([
    'src/server/back/'
])
const files_back_nodemon_ignore = nodemon_common_ignore.concat([
    'src/server/front/'
])

/****************** FOREVER ******************/

gulp.task('back-run-forever', () => {
    return new (forever.Monitor)(file_back_app, {
            'env': {
                NODE_ENV : 'production',
                APP_TYPE : 'back'
            },
            'killTree': true, //kills the entire child process tree on `exit`
        })
        .start()
})

gulp.task('front-run-forever', () => {
    return new (forever.Monitor)(file_front_app, {
            'env': {
                NODE_ENV : 'production',
                APP_TYPE : 'front'
            },
            'killTree': true, //kills the entire child process tree on `exit`
            //'max': 2 //remove it, for testing purpose
        })
        .start()
})

/****************** NODEMON ******************/

gulp.task('back-run-nodemon', () => {
    return nodemon({
            exec : 'node --debug', //node-inspector & node --inspect
            script : file_back_app,
            ext : 'js',
            env : {
                'NODE_ENV': 'development',
                'APP_TYPE': 'back'
            },
            ignore : files_back_nodemon_ignore
        })
})

gulp.task('front-run-nodemon', () => {
    return nodemon({
            exec : 'node --debug',
            verbose: true,
            script : file_front_app,
            ext : 'js vue css html',
            env : {
                'NODE_ENV': 'development',
                'APP_TYPE': 'front'
            },
            tasks : [ /* 'webpack' */ ],
            ignore : files_front_nodemon_ignore
        })
})

/****************** START ******************/

gulp.task('start-back-prod', gulpSync.sync([
    'back-run-forever'
]))

gulp.task('start-front-prod', gulpSync.sync([
    'front-translations',
    'webpack-prod',
    'front-run-forever'
]))

gulp.task('start-back-dev', gulpSync.sync([
    'back-run-nodemon'
]))

gulp.task('start-front-dev', gulpSync.sync([
    'front-translations',
    'webpack-dev',
    'front-run-nodemon'
]))

gulp.task('start-both-prod-no-build', gulpSync.sync([
    'back-run-forever',
    'front-run-forever'
]))

gulp.task('start-both-prod', gulpSync.sync([
    'start-back-prod',
    'start-front-prod'
]))

/****************** BUILD ******************/

gulp.task('build', gulpSync.sync([
    'front-translations',
    'webpack-prod',
]))

/****************** LOG ******************/

const fs = require('fs')
const path = require('path')
const dir = './log'
const files = [
    'app.back.log',
    'app.front.log'
]

gulp.task('create-log-files', () => {
    if (!fs.existsSync(dir)){
        fs.mkdirSync(dir)
    }
    files.forEach((file) => {
        if (!fs.existsSync(file)){
            fs.writeFile(path.join(dir, file));
        }
    })
})

/****************** WEBPACK ******************/

gulp.task('webpack-dev', () => {
    const webpackConfig = require('./webpack/dev.js')
    return gulp.src('src/client/app.js')
        .pipe(webpack(webpackConfig))
        .pipe(gulp.dest('public/assets'));
})

gulp.task('webpack-prod', () => {
    const webpackConfig = require('./webpack/prod.js')
    return gulp.src('src/client/app.js')
        .pipe(webpack(webpackConfig))
        .pipe(gulp.dest('public/assets'));
})

/****************** FRONT TRANSLATIONS ******************/

gulp.task('front-translations', gulpSync.sync([
    'front-translation-prop-to-json',
    'front-translation-add-js-variable',
    'front-translation-rename-json-to-js',
    'front-translation-remove-temp-files'
]))

gulp.task('front-translation-remove-temp-files', () => {
    return gulp.src([
            dir_client_translation+'/json',
            dir_client_translation+'/*.json'
        ], {read: false})
        .pipe(clean())
})

gulp.task('front-translation-rename-json-to-js', () => {
    return gulp.src(dir_client_translation+'/*.json')
        .pipe(extReplace('js'))
        .pipe(gulp.dest(dir_client_translation))
})

gulp.task('front-translation-add-js-variable', () => {
    return gulp.src(dir_client_translation+'/json/*')
        .pipe(insert.transform(function(contents, file) {
            return 'export default '+contents+'\r\n'
        }))
        .pipe(gulp.dest(dir_client_translation))
})

gulp.task('front-translation-prop-to-json', () => {
    return gulp.src('./translations/client/*.properties')
        .pipe(props2json({ minify : false }))
        .pipe(gulp.dest(dir_client_translation+'/json'))
})

/****************** BACK TRANSLATIONS ******************/

gulp.task('back-translations', gulpSync.sync([ '' ]))<commit_msg>remove unused script in gulpfile<commit_after>const gulp = require('gulp')
const babel = require('gulp-babel')
const concat = require('gulp-concat')
const nodemon = require('gulp-nodemon')
const forever = require('forever-monitor')
const rename = require('gulp-rename')
const props2json = require('gulp-props2json')
const insert = require('gulp-insert')
const clean = require('gulp-clean')
const extReplace = require('gulp-ext-replace')
const webpack = require('webpack-stream')
const gulpSync = require('gulp-sync')(gulp)

/****************** CONST ******************/

const dir_client_translation = './src/client/vuex/modules/locale/translations'
const dir_asset_src = './src/client/resource/*'
const dir_asset_dest = './public'
const file_front_app = './src/server/front/app.js'
const file_back_app = './src/server/back/app.js'

/****************** FOREVER ******************/

gulp.task('back-run-forever', () => {
    return new (forever.Monitor)(file_back_app, {
            'env': {
                NODE_ENV : 'production',
                APP_TYPE : 'back'
            },
            'killTree': true, //kills the entire child process tree on `exit`
        })
        .start()
})

gulp.task('front-run-forever', () => {
    return new (forever.Monitor)(file_front_app, {
            'env': {
                NODE_ENV : 'production',
                APP_TYPE : 'front'
            },
            'killTree': true, //kills the entire child process tree on `exit`
            //'max': 2 //remove it, for testing purpose
        })
        .start()
})

/****************** NODEMON ******************/

const nodemon_common_ignore = [
    // nodemon is only listening for .js and .vue files
    'gulpfile.js', 'node-modules', 'public', 'src/test', '.git', 'src/client/', 'package.json'
]
const files_front_nodemon_ignore = nodemon_common_ignore.concat([
    'src/server/back/'
])
const files_back_nodemon_ignore = nodemon_common_ignore.concat([
    'src/server/front/'
])

gulp.task('back-run-nodemon', () => {
    return nodemon({
            exec : 'node --debug', //node-inspector & node --inspect
            script : file_back_app,
            ext : 'js',
            env : {
                'NODE_ENV': 'development',
                'APP_TYPE': 'back'
            },
            ignore : files_back_nodemon_ignore
        })
})

gulp.task('front-run-nodemon', () => {
    return nodemon({
            exec : 'node --debug',
            verbose: true,
            script : file_front_app,
            ext : 'js vue css html',
            env : {
                'NODE_ENV': 'development',
                'APP_TYPE': 'front'
            },
            tasks : [ /* 'webpack' */ ],
            ignore : files_front_nodemon_ignore
        })
})

/****************** START ******************/

gulp.task('start-back-prod', gulpSync.sync([
    'back-run-forever'
]))

gulp.task('start-front-prod', gulpSync.sync([
    'front-translations',
    'webpack-prod',
    'front-run-forever'
]))

gulp.task('start-back-dev', gulpSync.sync([
    'back-run-nodemon'
]))

gulp.task('start-front-dev', gulpSync.sync([
    'front-translations',
    'webpack-dev',
    'front-run-nodemon'
]))

gulp.task('start-both-prod-no-build', gulpSync.sync([
    'back-run-forever',
    'front-run-forever'
]))

gulp.task('start-both-prod', gulpSync.sync([
    'start-back-prod',
    'start-front-prod'
]))

/****************** BUILD ******************/

gulp.task('build', gulpSync.sync([
    'front-translations',
    'webpack-prod',
]))

/****************** WEBPACK ******************/

gulp.task('webpack-dev', () => {
    const webpackConfig = require('./webpack/dev.js')
    return gulp.src('src/client/app.js')
        .pipe(webpack(webpackConfig))
        .pipe(gulp.dest('public/assets'));
})

gulp.task('webpack-prod', () => {
    const webpackConfig = require('./webpack/prod.js')
    return gulp.src('src/client/app.js')
        .pipe(webpack(webpackConfig))
        .pipe(gulp.dest('public/assets'));
})

/****************** FRONT TRANSLATIONS ******************/

gulp.task('front-translations', gulpSync.sync([
    'front-translation-prop-to-json',
    'front-translation-add-js-variable',
    'front-translation-rename-json-to-js',
    'front-translation-remove-temp-files'
]))

gulp.task('front-translation-remove-temp-files', () => {
    return gulp.src([
            dir_client_translation+'/json',
            dir_client_translation+'/*.json'
        ], {read: false})
        .pipe(clean())
})

gulp.task('front-translation-rename-json-to-js', () => {
    return gulp.src(dir_client_translation+'/*.json')
        .pipe(extReplace('js'))
        .pipe(gulp.dest(dir_client_translation))
})

gulp.task('front-translation-add-js-variable', () => {
    return gulp.src(dir_client_translation+'/json/*')
        .pipe(insert.transform(function(contents, file) {
            return 'export default '+contents+'\r\n'
        }))
        .pipe(gulp.dest(dir_client_translation))
})

gulp.task('front-translation-prop-to-json', () => {
    return gulp.src('./translations/client/*.properties')
        .pipe(props2json({ minify : false }))
        .pipe(gulp.dest(dir_client_translation+'/json'))
})

/****************** BACK TRANSLATIONS ******************/

gulp.task('back-translations', gulpSync.sync([ '' ]))<|endoftext|>


<commit_before>var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var uglifycss = require('gulp-uglifycss');
var rimraf = require('gulp-rimraf');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var templateCache = require('gulp-angular-templatecache');
var translate = require('gulp-angular-translate');

gulp.task('default', ['build', 'watch']);
gulp.task('test', test);
gulp.task('build', ['jshint', 'build:vendor', 'build:source', 'css:vendor', 'css:source']);

gulp.task('build:vendor', buildVendor);
gulp.task('build:source', ['templates', 'translate'], buildSource);
gulp.task('css:vendor', buildCssVendor);
gulp.task('css:source', buildCssSource);
gulp.task('jshint', jshintFunction);
gulp.task('watch', watchFunction);
gulp.task('templates', templates);
gulp.task('translate', translateFunction);
// Estas tarefas devem ser executadas separadamente
gulp.task('clean', clean);

/////////////////////////////////////////////////////
var baseDir = 'angular/';
var paths = {
    baseDir: baseDir,
    source: [
        baseDir + 'app.module.js',
        baseDir + '**/*.module.js',
        baseDir + '**/*.js'
    ],
    vendor: [
        'node_modules/angular/angular.min.js',
        'node_modules/angular-animate/angular-animate.min.js',
        'node_modules/angular-sanitize/angular-sanitize.min.js',
        'node_modules/angular-aria/angular-aria.min.js',
        'node_modules/angular-material/angular-material.min.js',
        'node_modules/angular-material-icons/angular-material-icons.min.js',
        'node_modules/angular-material/angular-material-mocks.min.js',
        'node_modules/angular-messages/angular-messages.min.js',
        'node_modules/angular-translate/dist/angular-translate.min.js',
        'node_modules/angular-ui-router/build/angular-ui-router.min.js',
        'node_modules/angular-loading-bar/build/loading-bar.min.js',
        'node_modules/angular-input-masks/releases/angular-input-masks-standalone.min.js',
        'node_modules/ngstorage/ngStorage.min.js',
        'node_modules/restangular/dist/restangular.min.js',
    ],
    vendorCss: [
        'node_modules/angular-material/angular-material.min.css',
        'node_modules/angular-material/angular-material.layouts.min.css',
        'node_modules/angular-loading-bar/build/loading-bar.min.css'
    ],
    sourceCss: [
        'assets/**/*.css'
    ],
    dist: './public/'
};

function test() {
    console.log('karma...');
}

function buildVendor() {
    return gulp.src(paths.vendor)
        .pipe(concat('vendor.min.js'))
        .pipe(gulp.dest(paths.dist + 'js/'));
}

function buildSource() {
    return gulp.src(paths.source)
        .pipe(concat('app.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest(paths.dist + 'js/'));
}

function buildCssVendor() {
    return gulp.src(paths.vendorCss)
        .pipe(concat('vendor.min.css'))
        .pipe(gulp.dest(paths.dist + 'css/'));
}

function buildCssSource() {
    return gulp.src(paths.sourceCss)
        .pipe(concat('app.min.css'))
        .pipe(uglifycss())
        .pipe(gulp.dest(paths.dist + 'css/'));
}

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

function jshintFunction() {
    gulp.src(paths.source.concat([
        '!./angular/templates.js',
        '!./angular/translations.js'
    ]))
        .pipe(jshint())
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(jshint.reporter("fail"));
}

function templates() {
    return gulp.src(paths.baseDir + 'components/**/*.html')
        .pipe(templateCache('templates.js', {
            standalone: true,
            module: 'app.templates'
        }))
        .pipe(gulp.dest(paths.baseDir));
}

function translateFunction() {
    gulp.src('./angular/**/*.json')
        .pipe(translate())
        .pipe(gulp.dest(paths.baseDir));
}

function watchFunction() {
    gulp.watch([paths.baseDir + '**/*'], ['build']);
    gulp.watch(paths.sourceCss, ['build']);
}<commit_msg>[add] modulo angular-loading-bar ao projeto<commit_after>var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var uglifycss = require('gulp-uglifycss');
var rimraf = require('gulp-rimraf');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var templateCache = require('gulp-angular-templatecache');
var translate = require('gulp-angular-translate');

gulp.task('default', ['build', 'watch']);
gulp.task('test', test);
gulp.task('build', ['jshint', 'build:vendor', 'build:source', 'css:vendor', 'css:source']);

gulp.task('build:vendor', buildVendor);
gulp.task('build:source', ['templates', 'translate'], buildSource);
gulp.task('css:vendor', buildCssVendor);
gulp.task('css:source', buildCssSource);
gulp.task('jshint', jshintFunction);
gulp.task('watch', watchFunction);
gulp.task('templates', templates);
gulp.task('translate', translateFunction);
// Estas tarefas devem ser executadas separadamente
gulp.task('clean', clean);

/////////////////////////////////////////////////////
var baseDir = 'angular/';
var paths = {
    baseDir: baseDir,
    source: [
        baseDir + 'app.module.js',
        baseDir + '**/*.module.js',
        baseDir + '**/*.js'
    ],
    vendor: [
        'node_modules/angular/angular.min.js',
        'node_modules/angular-animate/angular-animate.min.js',
        'node_modules/angular-sanitize/angular-sanitize.min.js',
        'node_modules/angular-aria/angular-aria.min.js',
        'node_modules/angular-material/angular-material.min.js',
        'node_modules/angular-material-icons/angular-material-icons.min.js',
        'node_modules/angular-material/angular-material-mocks.min.js',
        'node_modules/angular-messages/angular-messages.min.js',
        'node_modules/angular-translate/dist/angular-translate.min.js',
        'node_modules/angular-ui-router/build/angular-ui-router.min.js',
        'node_modules/angular-loading-bar/build/loading-bar.min.js',
        'node_modules/angular-input-masks/releases/angular-input-masks-standalone.min.js',
        'node_modules/ngstorage/ngStorage.min.js',
        'node_modules/restangular/dist/restangular.min.js',
        'node_modules/angular-loading-bar/build/loading-bar.min.js',
    ],
    vendorCss: [
        'node_modules/angular-material/angular-material.min.css',
        'node_modules/angular-material/angular-material.layouts.min.css',
        'node_modules/angular-loading-bar/build/loading-bar.min.css',
    ],
    sourceCss: [
        'assets/**/*.css'
    ],
    dist: './public/'
};

function test() {
    console.log('karma...');
}

function buildVendor() {
    return gulp.src(paths.vendor)
        .pipe(concat('vendor.min.js'))
        .pipe(gulp.dest(paths.dist + 'js/'));
}

function buildSource() {
    return gulp.src(paths.source)
        .pipe(concat('app.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest(paths.dist + 'js/'));
}

function buildCssVendor() {
    return gulp.src(paths.vendorCss)
        .pipe(concat('vendor.min.css'))
        .pipe(gulp.dest(paths.dist + 'css/'));
}

function buildCssSource() {
    return gulp.src(paths.sourceCss)
        .pipe(concat('app.min.css'))
        .pipe(uglifycss())
        .pipe(gulp.dest(paths.dist + 'css/'));
}

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

function jshintFunction() {
    gulp.src(paths.source.concat([
        '!./angular/templates.js',
        '!./angular/translations.js'
    ]))
        .pipe(jshint())
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(jshint.reporter("fail"));
}

function templates() {
    return gulp.src(paths.baseDir + 'components/**/*.html')
        .pipe(templateCache('templates.js', {
            standalone: true,
            module: 'app.templates'
        }))
        .pipe(gulp.dest(paths.baseDir));
}

function translateFunction() {
    gulp.src('./angular/**/*.json')
        .pipe(translate())
        .pipe(gulp.dest(paths.baseDir));
}

function watchFunction() {
    gulp.watch([paths.baseDir + '**/*'], ['build']);
    gulp.watch(paths.sourceCss, ['build']);
}<|endoftext|>


<commit_before>var elixir = require('laravel-elixir');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */
elixir.config.sourcemaps = false;
elixir(function(mix) {
    // mix.sass('app.scss');

    mix.scripts([
    	'app.js'
    ],'public/elixir/js/app.js');

    mix.scripts([
    	'controllers/userController.js',
        'controllers/globalController.js',
        'controllers/navController.js'
    ],'public/elixir/js/controller.js');

    mix.scripts([
    	'models/userModel.js'
    ],'public/elixir/js/models.js');
});
<commit_msg>update gulp script<commit_after>var elixir = require('laravel-elixir');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */
 //to not create *.map file
elixir.config.sourcemaps = false;
elixir(function(mix) {
    // mix.sass('app.scss');

    mix.scripts([
    	'app.js'
    ],'public/elixir/js/app.js');

    mix.scripts([
    	'controllers/userController.js',
        'controllers/globalController.js',
        'controllers/navController.js'
    ],'public/elixir/js/controller.js');

    mix.scripts([
    	'models/userModel.js'
    ],'public/elixir/js/models.js');
});
<|endoftext|>


<commit_before>(function main() {

    var mainModule = 'component/ReactShadow.js',
        vendorDest = 'example/vendor/react-shadow',
        devDist    = 'react-shadow.js',
        minDist    = 'react-shadow.min.js';

    var gulp    = require('gulp'),
        uglify  = require('gulp-uglify'),
        rename  = require('gulp-rename'),
        jshint  = require('gulp-jshint'),
        karma   = require('gulp-karma');

    gulp.task('compile', function gulpCompile() {

        return gulp.src(mainModule)
            .pipe(rename(devDist))
            .pipe(gulp.dest('dist'))
            .pipe(rename(minDist))
            .pipe(uglify())
            .pipe(gulp.dest('dist'));

    });

    gulp.task('vendor', function gulpVendor() {

        return gulp.src(mainModule)
                   .pipe(rename(devDist + 'x'))
                   .pipe(gulp.dest(vendorDest));

    });

    gulp.task('karma', function gulpKarma() {

        return gulp.src([])
            .pipe(karma({
                configFile: 'karma.conf.js',
                action: 'run'
            }))
            .on('error', function onError(error) {
                throw error;
            });

    });

    gulp.task('hint', function gulpHint() {

        return gulp.src(mainModule)
            .pipe(jshint('.jshintrc'))
            .pipe(jshint.reporter('default'));

    });

    //gulp.task('test', ['hint', 'karma']);
    gulp.task('test', ['hint']);
    gulp.task('build', ['compile', 'vendor']);
    gulp.task('default', ['test', 'build']);

})();<commit_msg>Added 'watch' to Gulp build process<commit_after>(function main() {

    var mainModule = 'component/ReactShadow.js',
        vendorDest = 'example/vendor/react-shadow',
        devDist    = 'react-shadow.js',
        minDist    = 'react-shadow.min.js';

    var gulp    = require('gulp'),
        uglify  = require('gulp-uglify'),
        rename  = require('gulp-rename'),
        jshint  = require('gulp-jshint'),
        karma   = require('gulp-karma');

    gulp.task('compile', function gulpCompile() {

        return gulp.src(mainModule)
            .pipe(rename(devDist))
            .pipe(gulp.dest('dist'))
            .pipe(rename(minDist))
            .pipe(uglify())
            .pipe(gulp.dest('dist'));

    });

    gulp.task('vendor', function gulpVendor() {

        return gulp.src(mainModule)
                   .pipe(rename(devDist + 'x'))
                   .pipe(gulp.dest(vendorDest));

    });

    gulp.task('karma', function gulpKarma() {

        return gulp.src([])
            .pipe(karma({
                configFile: 'karma.conf.js',
                action: 'run'
            }))
            .on('error', function onError(error) {
                throw error;
            });

    });

    gulp.task('hint', function gulpHint() {

        return gulp.src(mainModule)
            .pipe(jshint('.jshintrc'))
            .pipe(jshint.reporter('default'));

    });

    //gulp.task('test', ['hint', 'karma']);
    gulp.task('test', ['hint']);
    gulp.task('build', ['compile', 'vendor']);
    gulp.task('default', ['test', 'build']);
    gulp.task('watch', function watch() {
        gulp.watch('component/*.js', ['build']);
    });

})();<|endoftext|>


<commit_before>/**********************
 *
 * VARS
 * * * * *
 **********************/
var gulp = require('gulp');
var runSequence = require('run-sequence');
var del = require('del');
var concat = require('gulp-concat');
var riot = require('gulp-riot');
var pug = require('gulp-pug');
var sass = require('gulp-sass');
var liveServer = require('gulp-live-server');

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

/**********************
 *
 * PUG
 * * * * *
 **********************/
gulp.task('delete:index.html', function () {
  return del.sync('app/index.html');
});

gulp.task('compile_pug', ['delete:index.html'], function () {
  gulp.src('./src_app/*.pug')
    .pipe(pug({
      locals: {
        title: packageJson.name
      }
    }))
    .pipe(gulp.dest('./app/'));
});

/**********************
 *
 * SASS
 * * * * *
 **********************/
gulp.task('delete:main.css', function () {
  return del.sync('app/style/main.css');
});

gulp.task('compile_sass', ['delete:main.css'], function () {
  gulp.src('src_app/style/main.sass')
    .pipe(sass())
    .pipe(gulp.dest('app/style'));
});

/**********************
 *
 * RIOT TAGS
 * * * * *
 **********************/
gulp.task('compile_riot_tags', function () {
  return gulp.src('src_app/**/*.tag')
    .pipe(riot())
    .pipe(concat('compiled-tags.tag.js'))
    .pipe(gulp.dest('src_app/.tmp/'));
});

/**********************
 *
 * SCRIPT
 * * * * *
 **********************/
var scripts = [
  'bower_components/detectrtc/DetectRTC.min.js',
  'bower_components/riot/riot.min.js',
  'bower_components/webrtc-adapter/release/adapter.js',
  'bower_components/vex/dist/js/vex.combined.min.js',
  'lib/qr-decoder.js',
  'src_app/.tmp/**/*.js',
  'src_app/**/*.js'
];

gulp.task('delete:js', function () {
  return del.sync('app/js');
});

gulp.task('concat_scripts', ['delete:js'], function () {
  return gulp.src(scripts)
    .pipe(concat('main.js'))
    .pipe(gulp.dest('./app/js/'));
});

/**********************
 *
 * COPY DATA (ASSETS)
 * * * * *
 **********************/
gulp.task('delete:data', function () {
  return del.sync('app/data');
});

var data = {
  img: './src_app/data/img/**/*.*',
  audio: './src_app/data/audio/**/*.*',
  items: './src_app/data/items/**/*.{jpg,png}'
};

gulp.task('copy_data', ['delete:data'], function () {
  gulp.src(data.img)
    .pipe(gulp.dest('./app/data/img'));
  gulp.src(data.audio)
    .pipe(gulp.dest('./app/data/audio'));
  gulp.src(data.items)
    .pipe(gulp.dest('./app/data/items'));
});

var server = null;
/**********************
 *
 * SERVE
 * * * * *
 **********************/
gulp.task('serve', function () {
  var parameter = process.argv[3];
  server = liveServer.static('app');
  switch(parameter) {
    case '-stop':
      server.stop();
      break;
    default:
      server.start();
  }
});

/**********************
 *
 * WATCH
 * * * * *
 **********************/
gulp.task('watch', function () {
  gulp.watch('./src_app/**/*.pug', ['compile_pug']);
  gulp.watch('./src_app/**/*.sass', ['compile_sass']);
  gulp.watch('src_app/**/*.tag', ['compile_riot_tags']);
  gulp.watch('./src_app/{.tmp,**}/*.js', ['concat_scripts']);
});

/**********************
 *
 * DEFAULT / INIT
 * * * * *
 **********************/
gulp.task('default', function (callback) {
  runSequence(
    [
      'compile_pug',
      'compile_sass',
      'compile_riot_tags',
      'concat_scripts',
      'copy_data'
    ],
    'watch',
    callback
  );
});

<commit_msg>refactors: moves folder wit compiled tags into modules folder<commit_after>/**********************
 *
 * VARS
 * * * * *
 **********************/
var gulp = require('gulp');
var runSequence = require('run-sequence');
var del = require('del');
var concat = require('gulp-concat');
var riot = require('gulp-riot');
var pug = require('gulp-pug');
var sass = require('gulp-sass');
var liveServer = require('gulp-live-server');

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

/**********************
 *
 * PUG
 * * * * *
 **********************/
gulp.task('delete:index.html', function () {
  return del.sync('app/index.html');
});

gulp.task('compile_pug', ['delete:index.html'], function () {
  gulp.src('./src_app/*.pug')
    .pipe(pug({
      locals: {
        title: packageJson.name
      }
    }))
    .pipe(gulp.dest('./app/'));
});

/**********************
 *
 * SASS
 * * * * *
 **********************/
gulp.task('delete:main.css', function () {
  return del.sync('app/style/main.css');
});

gulp.task('compile_sass', ['delete:main.css'], function () {
  gulp.src('src_app/style/main.sass')
    .pipe(sass())
    .pipe(gulp.dest('app/style'));
});

/**********************
 *
 * RIOT TAGS
 * * * * *
 **********************/
gulp.task('compile_riot_tags', function () {
  return gulp.src('src_app/**/*.tag')
    .pipe(riot())
    .pipe(concat('compiled-tags.tag.js'))
    .pipe(gulp.dest('src_app/modules/.tmp/'));
});

/**********************
 *
 * SCRIPT
 * * * * *
 **********************/
var scripts = [
  'bower_components/detectrtc/DetectRTC.min.js',
  'bower_components/riot/riot.min.js',
  'bower_components/webrtc-adapter/release/adapter.js',
  'bower_components/vex/dist/js/vex.combined.min.js',
  'lib/qr-decoder.js',
  'src_app/**/*.js',
  'src_app/modules/.tmp/**/*.js'
];

gulp.task('delete:js', function () {
  return del.sync('app/js');
});

gulp.task('concat_scripts', ['delete:js'], function () {
  return gulp.src(scripts)
    .pipe(concat('main.js'))
    .pipe(gulp.dest('./app/js/'));
});

/**********************
 *
 * COPY DATA (ASSETS)
 * * * * *
 **********************/
gulp.task('delete:data', function () {
  return del.sync('app/data');
});

var data = {
  img: './src_app/data/img/**/*.*',
  audio: './src_app/data/audio/**/*.*',
  items: './src_app/data/items/**/*.{jpg,png}'
};

gulp.task('copy_data', ['delete:data'], function () {
  gulp.src(data.img)
    .pipe(gulp.dest('./app/data/img'));
  gulp.src(data.audio)
    .pipe(gulp.dest('./app/data/audio'));
  gulp.src(data.items)
    .pipe(gulp.dest('./app/data/items'));
});

var server = null;
/**********************
 *
 * SERVE
 * * * * *
 **********************/
gulp.task('serve', function () {
  var parameter = process.argv[3];
  server = liveServer.static('app');
  switch(parameter) {
    case '-stop':
      server.stop();
      break;
    default:
      server.start();
  }
});

/**********************
 *
 * WATCH
 * * * * *
 **********************/
gulp.task('watch', function () {
  gulp.watch('./src_app/**/*.pug', ['compile_pug']);
  gulp.watch('./src_app/**/*.sass', ['compile_sass']);
  gulp.watch('src_app/**/*.tag', ['compile_riot_tags']);
  gulp.watch('./src_app/{.tmp,**}/*.js', ['concat_scripts']);
});

/**********************
 *
 * DEFAULT / INIT
 * * * * *
 **********************/
gulp.task('default', function (callback) {
  runSequence(
    [
      'compile_pug',
      'compile_sass',
      'compile_riot_tags',
      'concat_scripts',
      'copy_data'
    ],
    'watch',
    callback
  );
});

<|endoftext|>


<commit_before>// Инициализируем плагины
var gulp = require('gulp'),
	jade = require('gulp-jade'),
	stylus = require('gulp-stylus'),
	autoprefixer = require('gulp-autoprefixer'),
	imagemin = require('gulp-imagemin'),
	webserver = require('gulp-webserver'),
	cssbeautify = require('gulp-cssbeautify'),
	gutil = require('gulp-util'),
	cache = require('gulp-cache'),
	include = require('gulp-include'),
	rename = require("gulp-rename"),
	uglify = require('gulp-uglify'),
	jadeOrig = require('jade');

// Функция обработки ошибок
handleError = function(err) {
	gutil.log(err);
	gutil.beep();
};

// Пути к файлам
path = {
	html: {
		source: ['./source/**/*.jade', '!./source/partials/*.jade', '!./source/blocks/**/*.jade'],
		watch: 'source/**/*.jade',
		destination: './public/',
		basedir: './source'
	},
	css: {
		source: ['./source/css/*.styl', '!./source/css/lib/**/*.styl', '!./source/**/_*.styl'],
		watch: 'source/**/*.styl',
		destination: './public/css/'
	},
	assets: {
		source: './assets/**/*',
		watch: 'assets/**/*',
		destination: './public'
	},
	img: {
		source: './source/img/**/*.{jpg,jpeg,png,gif}',
		watch: 'source/img/**/*',
		destination: './public/img'
	},
	js: {
		plugins: {
			source: './source/js/*.js',
			watch: './source/js/*',
			destination: './public/js'
		}
	}
};

// Локальный сервер
gulp.task('webserver', function() {
	gulp.src('public')
	.pipe(webserver({
		host: 'localhost', // Если нужен сервер в сети ставьте 0.0.0.0
		port: 3000,
		livereload: true,
		open: "/index.html"
	}));
});

// Собираем Stylus
gulp.task('stylus', function() {
	gulp.src(path.css.source)
		.pipe(stylus())
		.pipe(cssbeautify({
			indent: '	',
			autosemicolon: true
		}))
		.pipe(autoprefixer({
			browsers: ["> 5%", "last 2 version", "ie 7"],
			cascade: false
		}))
		.on('error', handleError)
		.pipe(gulp.dest(path.css.destination));
});

// Собираем html из Jade
gulp.task('jade', function() {
	gulp.src(path.html.source)
		.pipe(jade({
			jade: jadeOrig,
			pretty: '\t',
			basedir: path.html.basedir,
			data: gulp.src(['users.json'])
		}))
		.on('error', handleError)
		.pipe(gulp.dest(path.html.destination));
});

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

// Копируем файлы
gulp.task('copy', function() {
	gulp.src(path.assets.source)
		.on('error', handleError)
		.pipe(gulp.dest(path.assets.destination));
});

// Собираем JS
gulp.task('plugins', function() {
	gulp.src(path.js.plugins.source)
		.pipe(include())
		.pipe(gulp.dest(path.js.plugins.destination))
		.pipe(uglify())
		.pipe(rename({
			suffix: ".min"
		}))
		.on('error', handleError)
		.pipe(gulp.dest(path.js.plugins.destination));
});

// Запуск сервера разработки gulp watch
gulp.task("watch", function() {
	gulp.watch(path.css.watch, ['stylus']);
	gulp.watch(path.html.watch, ['jade']);
	gulp.watch(path.img.watch, ['images']);
	gulp.watch(path.js.plugins.watch, ['plugins']);
	gulp.watch(path.assets.watch, ['copy']);
});

gulp.task("build", ['stylus', 'jade', 'images', 'plugins', 'copy']);

gulp.task("default", ["build", "watch", "webserver"]);
<commit_msg>Изенения в autoprefixer<commit_after>// Инициализируем плагины
var gulp = require('gulp'),
	jade = require('gulp-jade'),
	stylus = require('gulp-stylus'),
	autoprefixer = require('gulp-autoprefixer'),
	imagemin = require('gulp-imagemin'),
	webserver = require('gulp-webserver'),
	cssbeautify = require('gulp-cssbeautify'),
	gutil = require('gulp-util'),
	cache = require('gulp-cache'),
	include = require('gulp-include'),
	rename = require("gulp-rename"),
	uglify = require('gulp-uglify'),
	jadeOrig = require('jade');

// Функция обработки ошибок
handleError = function(err) {
	gutil.log(err);
	gutil.beep();
};

// Пути к файлам
path = {
	html: {
		source: ['./source/**/*.jade', '!./source/partials/*.jade', '!./source/blocks/**/*.jade'],
		watch: 'source/**/*.jade',
		destination: './public/',
		basedir: './source'
	},
	css: {
		source: ['./source/css/*.styl', '!./source/css/lib/**/*.styl', '!./source/**/_*.styl'],
		watch: 'source/**/*.styl',
		destination: './public/css/'
	},
	assets: {
		source: './assets/**/*',
		watch: 'assets/**/*',
		destination: './public'
	},
	img: {
		source: './source/img/**/*.{jpg,jpeg,png,gif}',
		watch: 'source/img/**/*',
		destination: './public/img'
	},
	js: {
		plugins: {
			source: './source/js/*.js',
			watch: './source/js/*',
			destination: './public/js'
		}
	}
};

// Локальный сервер
gulp.task('webserver', function() {
	gulp.src('public')
	.pipe(webserver({
		host: 'localhost', // Если нужен сервер в сети ставьте 0.0.0.0
		port: 3000,
		livereload: true,
		open: "/index.html"
	}));
});

// Собираем Stylus
gulp.task('stylus', function() {
	gulp.src(path.css.source)
		.pipe(stylus())
		.pipe(cssbeautify({
			indent: '	',
			autosemicolon: true
		}))
		.pipe(autoprefixer({
			browsers: ['last 2 version', '> 5%', 'safari 5', 'ie 8', 'ie 7', 'opera 12.1', 'ios 6', 'android 4'],
			cascade: false
		}))
		.on('error', handleError)
		.pipe(gulp.dest(path.css.destination));
});

// Собираем html из Jade
gulp.task('jade', function() {
	gulp.src(path.html.source)
		.pipe(jade({
			jade: jadeOrig,
			pretty: '\t',
			basedir: path.html.basedir,
			data: gulp.src(['users.json'])
		}))
		.on('error', handleError)
		.pipe(gulp.dest(path.html.destination));
});

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

// Копируем файлы
gulp.task('copy', function() {
	gulp.src(path.assets.source)
		.on('error', handleError)
		.pipe(gulp.dest(path.assets.destination));
});

// Собираем JS
gulp.task('plugins', function() {
	gulp.src(path.js.plugins.source)
		.pipe(include())
		.pipe(gulp.dest(path.js.plugins.destination))
		.pipe(uglify())
		.pipe(rename({
			suffix: ".min"
		}))
		.on('error', handleError)
		.pipe(gulp.dest(path.js.plugins.destination));
});

// Запуск сервера разработки gulp watch
gulp.task("watch", function() {
	gulp.watch(path.css.watch, ['stylus']);
	gulp.watch(path.html.watch, ['jade']);
	gulp.watch(path.img.watch, ['images']);
	gulp.watch(path.js.plugins.watch, ['plugins']);
	gulp.watch(path.assets.watch, ['copy']);
});

gulp.task("build", ['stylus', 'jade', 'images', 'plugins', 'copy']);

gulp.task("default", ["build", "watch", "webserver"]);
<|endoftext|>


<commit_before>/**
 * @fileOverview Interfaces the application with its current architecture.
 * This could be an extension, mobile app, or a hosted web server.
 *
 **/

/**
 * @namespace
 */
var privlyNetworkService = {

  /**
   * If this variable is assigned, it will be appended as a get parameter
   * on all requests, eg, `?auth_token=AUTH_TOKEN_HERE`. This should never
   * be referenced by anything but the auth token setters.
   */
  authToken: "",

  /**
   * Set the authentication token if a parameter is supplied, or the
   * current platform has a setter function. This may be called from the
   * context of mobile applications or browser extensions.
   */
  setAuthTokenString: function(authTokenString) {
    if (authTokenString !== undefined) {
      privlyNetworkService.authToken = "auth_token=" + authTokenString;
    } else if(privlyNetworkService.platformName() === "ANDROID") {
      privlyNetworkService.authToken = "auth_token=" +
                                              androidJsBridge.fetchAuthToken();
    }
  },

  /**
   * Adds the auth token to the current URL. If the auth token has not been
   * assigned, nothing is added. If the auth token is assigned, it is added
   * as a get parameter.
   *
   * @param string url the URL that may need an auth token added.
   *
   */
  getAuthenticatedUrl: function(url) {
      alert("auth token: " + privlyNetworkService.authToken);

    if(privlyNetworkService.authToken === "") {
      return url;
    }

    // if query parameters already exist on the URL
    if (url.indexOf("?") >= 0 && (url.indexOf("?") < url.indexOf("#") ||
      url.indexOf("#") === -1)) {
      return url.replace("?", "?" + privlyNetworkService.authToken + "&");

    // else if there is an anchor
    } else if(url.indexOf("#") >= 0) {
      return url.replace("#", "?" + privlyNetworkService.authToken + "#");
    } else {
      return url + "?" + privlyNetworkService.authToken;
    }
  },

  /**
   * Determines which platform the script is runing on. This helps determine
   * which request function should be used. The current values are "CHROME"
   * for the Google Chrome extension, and "HOSTED" for all other architectures.
   * HOSTED functions use standard same-origin AJAX requests.
   *
   * @return {string} the name of the platform.
   */
  platformName: function() {
    if (navigator.userAgent.indexOf("iPhone") >= 0 || navigator.userAgent.indexOf("iPad") >= 0) {
      return "IOS";
    } else if(typeof androidJsBridge !== "undefined") {
      return "ANDROID";
    }  else if (typeof chrome !== "undefined" && typeof chrome.extension !== "undefined") {
      return "CHROME";
    } else {
      return "HOSTED";
    }
  },

  /**
   * This function is specific to the privly content server available on GitHub.
   * It initializes a CSRF token, and checks whether the user is logged in.
   * Since the application is not necessarily tied to the privly content
   * server, the failure callback should not necessarily be interpreted as
   * a failure.
   *
   * @param setCSRF boolean indicates whether it should get the CSRF token.
   *
   * @param canPostCallback function the function to execute when
   * initialization is successful.
   *
   * @param loginCallback function the function to execute if the user is
   * not logged in.
   *
   * @param errorCallback function the function to execute if the remote
   * server is not available.
   */
  initPrivlyService: function(setCSRF, canPostCallback, loginCallback, errorCallback) {
    var csrfTokenAddress = privlyNetworkService.contentServerDomain() +
                           "/posts/user_account_data";

    csrfTokenAddress =  privlyNetworkService.getAuthenticatedUrl(csrfTokenAddress);
      alert(csrfTokenAddress);

    if (setCSRF) {
      $.ajax({
        url: csrfTokenAddress,
        dataType: "json",
        success: function (json, textStatus, jqXHR) {
          $.ajaxSetup({
            beforeSend: function(xhr) {
              xhr.setRequestHeader('X-CSRF-Token', json.csrf);
              xhr.setRequestHeader('Accept', 'application/json');
          }});

          if(json.signedIn && json.canPost) {
            canPostCallback(json, textStatus, jqXHR);
          } else if(json.signedIn) {
            cantPostLoginCallback(json, textStatus, jqXHR);
          } else {
            loginCallback(json, textStatus, jqXHR);
          }
        },
        error: function (jqXHR, textStatus, errorThrown) {
          errorCallback(jqXHR, textStatus, errorThrown);
        }
      });
    } else {
      $.ajaxSetup({
        beforeSend: function(xhr) {
          xhr.setRequestHeader('Accept', 'application/json');
      }});
    }
  },

  /**
   * Gives the domain all requests are associated with.
   *
   * @return {string} The domain content is associated with.
   */
  contentServerDomain: function() {
    var protocolDomainPort = location.protocol +
                             '//'+location.hostname +
                             (location.port ? ':'+location.port: '');

    if (privlyNetworkService.platformName() === "HOSTED") {
      return protocolDomainPort;
    } else if (privlyNetworkService.platformName() === "CHROME") {
      return localStorage["posting_content_server_url"];
    } else if (privlyNetworkService.platformName() === "ANDROID") {
      return androidJsBridge.fetchDomainName();
    } else if (privlyNetworkService.platformName() === "IOS") {

      return localStorage["posting_content_server_url"];
    } else {
      return protocolDomainPort;
    }
  },

  /**
   * Make a same-origin get request for content.
   *
   * This request should always proceed a post request.
   *
   * @param {string} url The URL to make a cross domain request for.
   * @param {function} callback The function to execute after the response
   * returns.
   */
  sameOriginGetRequest: function(url, callback) {
    url = privlyNetworkService.getAuthenticatedUrl(url);
    alert(url);
    $.ajax({
      url: url,
      dataType: "json",
      success: function (json, textStatus, jqXHR) {
        callback({json: json, textStatus: textStatus, jqXHR: jqXHR});
      },
      error: function (jqXHR, textStatus, errorThrown) {
        callback({json: {}, textStatus: textStatus, jqXHR: jqXHR});
      }
    });
  },

  /**
   * Make a same-origin post request to the specified server.
   *
   * Warning: Do not use this function without first checking the data returned
   * by a get request for conformance with the application's signature.
   * Basically, you need to see whether the data at the URL expects to interface
   * with your application. The easiest way to do this is to have a version
   * string for your application in the JSON stored on the content server.
   * This prevents some rather nasty cross-site-scripting attacks.
   *
   * @param {string} path The relative path to make a cross domain request for.
   * @param {function} callback The function to execute after the response
   * returns.
   * @param {object} data The data to be sent with the post request.
   */
  sameOriginPostRequest: function(path, callback, data) {

    var url = privlyNetworkService.contentServerDomain() + path;
    url = privlyNetworkService.getAuthenticatedUrl(url);
    alert(url);
    $.ajax({
      url: url,
      cache: false,
      type: "POST",
      data: data,
      dataType: "json",
      success: function (json, textStatus, jqXHR) {
        callback({json: json, textStatus: textStatus, jqXHR: jqXHR});
      },
      error: function (jqXHR, textStatus, errorThrown) {
        callback({json: {}, textStatus: textStatus, jqXHR: jqXHR});
      }
    });
  }
}
<commit_msg>refactored content server block<commit_after>/**
 * @fileOverview Interfaces the application with its current architecture.
 * This could be an extension, mobile app, or a hosted web server.
 *
 **/

/**
 * @namespace
 */
var privlyNetworkService = {

  /**
   * If this variable is assigned, it will be appended as a get parameter
   * on all requests, eg, `?auth_token=AUTH_TOKEN_HERE`. This should never
   * be referenced by anything but the auth token setters.
   */
  authToken: "",

  /**
   * Set the authentication token if a parameter is supplied, or the
   * current platform has a setter function. This may be called from the
   * context of mobile applications or browser extensions.
   */
  setAuthTokenString: function(authTokenString) {
    if (authTokenString !== undefined) {
      privlyNetworkService.authToken = "auth_token=" + authTokenString;
    } else if(privlyNetworkService.platformName() === "ANDROID") {
      privlyNetworkService.authToken = "auth_token=" +
                                              androidJsBridge.fetchAuthToken();
    }
  },

  /**
   * Adds the auth token to the current URL. If the auth token has not been
   * assigned, nothing is added. If the auth token is assigned, it is added
   * as a get parameter.
   *
   * @param string url the URL that may need an auth token added.
   *
   */
  getAuthenticatedUrl: function(url) {

    if(privlyNetworkService.authToken === "") {
      return url;
    }

    // if query parameters already exist on the URL
    if (url.indexOf("?") >= 0 && (url.indexOf("?") < url.indexOf("#") ||
      url.indexOf("#") === -1)) {
      return url.replace("?", "?" + privlyNetworkService.authToken + "&");

    // else if there is an anchor
    } else if(url.indexOf("#") >= 0) {
      return url.replace("#", "?" + privlyNetworkService.authToken + "#");
    } else {
      return url + "?" + privlyNetworkService.authToken;
    }
  },

  /**
   * Determines which platform the script is runing on. This helps determine
   * which request function should be used. The current values are "CHROME"
   * for the Google Chrome extension, and "HOSTED" for all other architectures.
   * HOSTED functions use standard same-origin AJAX requests.
   *
   * @return {string} the name of the platform.
   */
  platformName: function() {
    if (navigator.userAgent.indexOf("iPhone") >= 0 || navigator.userAgent.indexOf("iPad") >= 0) {
      return "IOS";
    } else if(typeof androidJsBridge !== "undefined") {
      return "ANDROID";
    }  else if (typeof chrome !== "undefined" && typeof chrome.extension !== "undefined") {
      return "CHROME";
    } else {
      return "HOSTED";
    }
  },

  /**
   * This function is specific to the privly content server available on GitHub.
   * It initializes a CSRF token, and checks whether the user is logged in.
   * Since the application is not necessarily tied to the privly content
   * server, the failure callback should not necessarily be interpreted as
   * a failure.
   *
   * @param setCSRF boolean indicates whether it should get the CSRF token.
   *
   * @param canPostCallback function the function to execute when
   * initialization is successful.
   *
   * @param loginCallback function the function to execute if the user is
   * not logged in.
   *
   * @param errorCallback function the function to execute if the remote
   * server is not available.
   */
  initPrivlyService: function(setCSRF, canPostCallback, loginCallback, errorCallback) {
    var csrfTokenAddress = privlyNetworkService.contentServerDomain() +
                           "/posts/user_account_data";

    csrfTokenAddress =  privlyNetworkService.getAuthenticatedUrl(csrfTokenAddress);

    if (setCSRF) {
      $.ajax({
        url: csrfTokenAddress,
        dataType: "json",
        success: function (json, textStatus, jqXHR) {
          $.ajaxSetup({
            beforeSend: function(xhr) {
              xhr.setRequestHeader('X-CSRF-Token', json.csrf);
              xhr.setRequestHeader('Accept', 'application/json');
          }});

          if(json.signedIn && json.canPost) {
            canPostCallback(json, textStatus, jqXHR);
          } else if(json.signedIn) {
            cantPostLoginCallback(json, textStatus, jqXHR);
          } else {
            loginCallback(json, textStatus, jqXHR);
          }
        },
        error: function (jqXHR, textStatus, errorThrown) {
          errorCallback(jqXHR, textStatus, errorThrown);
        }
      });
    } else {
      $.ajaxSetup({
        beforeSend: function(xhr) {
          xhr.setRequestHeader('Accept', 'application/json');
      }});
    }
  },

  /**
   * Gives the domain all requests are associated with.
   *
   * @return {string} The domain content is associated with.
   */
  contentServerDomain: function() {
    var protocolDomainPort = location.protocol +
                             '//'+location.hostname +
                             (location.port ? ':'+location.port: '');

    if (privlyNetworkService.platformName() === "HOSTED") {
      return protocolDomainPort;
    } else if (privlyNetworkService.platformName() === "CHROME" ||
              (privlyNetworkService.platformName() === "IOS")) {
      return localStorage["posting_content_server_url"];
    } else if (privlyNetworkService.platformName() === "ANDROID") {
      return androidJsBridge.fetchDomainName();
    } else {
      return protocolDomainPort;
    }
  },

  /**
   * Make a same-origin get request for content.
   *
   * This request should always proceed a post request.
   *
   * @param {string} url The URL to make a cross domain request for.
   * @param {function} callback The function to execute after the response
   * returns.
   */
  sameOriginGetRequest: function(url, callback) {
    url = privlyNetworkService.getAuthenticatedUrl(url);
    alert(url);
    $.ajax({
      url: url,
      dataType: "json",
      success: function (json, textStatus, jqXHR) {
        callback({json: json, textStatus: textStatus, jqXHR: jqXHR});
      },
      error: function (jqXHR, textStatus, errorThrown) {
        callback({json: {}, textStatus: textStatus, jqXHR: jqXHR});
      }
    });
  },

  /**
   * Make a same-origin post request to the specified server.
   *
   * Warning: Do not use this function without first checking the data returned
   * by a get request for conformance with the application's signature.
   * Basically, you need to see whether the data at the URL expects to interface
   * with your application. The easiest way to do this is to have a version
   * string for your application in the JSON stored on the content server.
   * This prevents some rather nasty cross-site-scripting attacks.
   *
   * @param {string} path The relative path to make a cross domain request for.
   * @param {function} callback The function to execute after the response
   * returns.
   * @param {object} data The data to be sent with the post request.
   */
  sameOriginPostRequest: function(path, callback, data) {

    var url = privlyNetworkService.contentServerDomain() + path;
    url = privlyNetworkService.getAuthenticatedUrl(url);
    alert(url);
    $.ajax({
      url: url,
      cache: false,
      type: "POST",
      data: data,
      dataType: "json",
      success: function (json, textStatus, jqXHR) {
        callback({json: json, textStatus: textStatus, jqXHR: jqXHR});
      },
      error: function (jqXHR, textStatus, errorThrown) {
        callback({json: {}, textStatus: textStatus, jqXHR: jqXHR});
      }
    });
  }
}
<|endoftext|>


<commit_before>var gulp = require('gulp');
var gutil = require('gulp-util');
var shell = require('gulp-shell');
var git = require('gulp-git');
var docco = require('gulp-docco');

var cache = require('gulp-cached');
var remember = require('gulp-remember');

// Docs Task
// =========
// The `docs` task builds docco files, switches to the gh-pages
// branch, commits the docs, and switches back to the
// development branch.
//
// Usage: `gulp docs`
//

gulp.task('checkout-master', shell.task(['git checkout master']));

gulp.task('docs-make', ['checkout-master'], function() {
	return gulp.src('./lib/**/*.js')
		.pipe(docco())
		.pipe(cache('docs'))
		.pipe(gulp.dest('./docs/'))
		.on('error', gutil.log);
});

gulp.task('docs-commit', ['docs-make'], shell.task([
	'git checkout gh-pages',
	'git add ./docs',
	'git commit -a -m \"update docs\"',
	'git checkout development'
]));

gulp.task('docs', ['docs-commit'], function() {
	git.push('origin', 'gh-pages');
});

<commit_msg>add test task to gulpfile<commit_after>var gulp = require('gulp');
var gutil = require('gulp-util');
var shell = require('gulp-shell');
var git = require('gulp-git');
var docco = require('gulp-docco');

var cache = require('gulp-cached');
var remember = require('gulp-remember');

var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');

// Testing Task
// ============

gulp.task('lint', function () {
	return gulp.src(['./bin/**/*.js'])
		.pipe(jshint())
		.pipe(jshint.reporter('default'));
});

gulp.task('test', function () {
	return gulp.src(['./test/**/*.spec.js'])
		.pipe(mocha())
		.on('error', gutil.log);
});

gulp.task('watch', function () {
	gulp.watch(['./bin/**/*.js'], ['lint', 'test']);
	gulp.watch(['./test/**/*.spec.js'], ['test']);
});

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

// Docs Task
// =========
// The `docs` task builds docco files, switches to the gh-pages
// branch, commits the docs, and switches back to the
// development branch.
//
// Usage: `gulp docs`
//

gulp.task('checkout-master', shell.task(['git checkout master']));

gulp.task('docs-make', ['checkout-master'], function() {
	return gulp.src('./lib/**/*.js')
		.pipe(docco())
		.pipe(cache('docs'))
		.pipe(gulp.dest('./docs/'))
		.on('error', gutil.log);
});

gulp.task('docs-commit', ['docs-make'], shell.task([
	'git checkout gh-pages',
	'git add ./docs',
	'git commit -a -m \"update docs\"',
	'git checkout development'
]));

gulp.task('docs', ['docs-commit'], function() {
	git.push('origin', 'gh-pages');
});

<|endoftext|>