aboutsummaryrefslogtreecommitdiffstats
path: root/web/gulpfile.js
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-12-12 17:49:10 +0100
committerMaximilian Hils <git@maximilianhils.com>2014-12-12 17:49:10 +0100
commitcb45296377972bafc3d283a8dcf00c7ebb976551 (patch)
treea6f26bc93d42f04e83b6f7aa291413b6d65869f5 /web/gulpfile.js
parent01fa5d3f07d26d52e5ad7eef139e1ed6f9b7dae1 (diff)
downloadmitmproxy-cb45296377972bafc3d283a8dcf00c7ebb976551.tar.gz
mitmproxy-cb45296377972bafc3d283a8dcf00c7ebb976551.tar.bz2
mitmproxy-cb45296377972bafc3d283a8dcf00c7ebb976551.zip
web: implement filters
Diffstat (limited to 'web/gulpfile.js')
-rw-r--r--web/gulpfile.js68
1 files changed, 41 insertions, 27 deletions
diff --git a/web/gulpfile.js b/web/gulpfile.js
index f7df820d..8dc888e7 100644
--- a/web/gulpfile.js
+++ b/web/gulpfile.js
@@ -7,6 +7,7 @@ var less = require("gulp-less");
var livereload = require("gulp-livereload");
var minifyCSS = require('gulp-minify-css');
var notify = require("gulp-notify");
+var peg = require("gulp-peg");
var plumber = require("gulp-plumber");
var qunit = require("gulp-qunit");
var react = require("gulp-react");
@@ -15,9 +16,9 @@ var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
-var dont_break_on_errors = function(){
- return plumber(function(error){
- notify.onError("Error: <%= error.message %>").apply(this, arguments);
+var dont_break_on_errors = function () {
+ return plumber(function (error) {
+ notify.onError("<%= error.message %>").apply(this, arguments);
this.emit('end');
});
};
@@ -35,6 +36,7 @@ var path = {
'js/utils.js',
'js/dispatcher.js',
'js/actions.js',
+ 'js/filt/filt.js',
'js/flow/utils.js',
'js/store/store.js',
'js/store/view.js',
@@ -53,13 +55,18 @@ var path = {
'js/app.js',
],
},
+ peg: "js/filt/filt.pegjs",
css: {
vendor: ["css/vendor.less"],
- app: ["css/app.less"]
+ app: ["css/app.less"],
+ all: ["css/**"]
},
+ vendor: ["vendor/**"],
fonts: ["src/vendor/fontawesome/fontawesome-webfont.*"],
- html: ["src/*.html", "!src/benchmark.html", "!src/test.html"],
- images: "src/images",
+ html: ["*.html", "!benchmark.html", "!test.html"],
+ images: ["images/**"],
+ test: ["test.html"],
+ opts: {base: "src", cwd: "src"}
};
@@ -70,13 +77,13 @@ gulp.task("fonts", function () {
function styles_dev(files) {
- return (gulp.src(files, {base: "src", cwd: "src"})
+ return (gulp.src(files, path.opts)
.pipe(dont_break_on_errors())
.pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write(".", {sourceRoot: "/static"}))
.pipe(gulp.dest(path.dist + "static"))
- .pipe(livereload({ auto: false })));
+ .pipe(livereload({auto: false})));
}
gulp.task("styles-app-dev", styles_dev.bind(undefined, path.css.app));
gulp.task("styles-vendor-dev", styles_dev.bind(undefined, path.css.vendor));
@@ -84,13 +91,13 @@ gulp.task("styles-dev", ["styles-app-dev", "styles-vendor-dev"]);
function styles_prod(files) {
- return (gulp.src(files, {base: "src", cwd: "src"})
+ return (gulp.src(files, path.opts)
.pipe(less())
// No sourcemaps support yet :-/
// https://github.com/jonathanepollack/gulp-minify-css/issues/34
.pipe(minifyCSS())
.pipe(gulp.dest(path.dist + "static"))
- .pipe(livereload({ auto: false })));
+ .pipe(livereload({auto: false})));
}
gulp.task("styles-app-prod", styles_prod.bind(undefined, path.css.app));
gulp.task("styles-vendor-prod", styles_prod.bind(undefined, path.css.vendor));
@@ -98,14 +105,14 @@ gulp.task("styles-prod", ["styles-app-prod", "styles-vendor-prod"]);
function scripts_dev(files, filename) {
- return gulp.src(files, {base: "src", cwd: "src"})
+ return gulp.src(files, path.opts)
.pipe(dont_break_on_errors())
.pipe(sourcemaps.init())
.pipe(react())
.pipe(concat(filename))
.pipe(sourcemaps.write(".", {sourceRoot: "/static"}))
.pipe(gulp.dest(path.dist + "static/js"))
- .pipe(livereload({ auto: false }));
+ .pipe(livereload({auto: false}));
}
gulp.task("scripts-app-dev", scripts_dev.bind(undefined, path.js.app, "app.js"));
gulp.task("scripts-vendor-dev", scripts_dev.bind(undefined, path.js.vendor, "vendor.js"));
@@ -113,12 +120,12 @@ gulp.task("scripts-dev", ["scripts-app-dev", "scripts-vendor-dev"]);
function scripts_prod(files, filename) {
- return gulp.src(files, {base: "src", cwd: "src"})
+ return gulp.src(files, path.opts)
.pipe(react())
.pipe(concat(filename))
.pipe(uglify())
.pipe(gulp.dest(path.dist + "static/js"))
- .pipe(livereload({ auto: false }));
+ .pipe(livereload({auto: false}));
}
gulp.task("scripts-app-prod", scripts_prod.bind(undefined, path.js.app, "app.js"));
gulp.task("scripts-vendor-prod", scripts_prod.bind(undefined, path.js.vendor, "vendor.js"));
@@ -126,41 +133,48 @@ gulp.task("scripts-prod", ["scripts-app-prod", "scripts-vendor-prod"]);
gulp.task("jshint", function () {
- return gulp.src(["src/js/**"])
+ return gulp.src(path.js.app.concat(["!"+path.peg.replace("pegjs","js")]), path.opts)
.pipe(dont_break_on_errors())
.pipe(react())
.pipe(jshint())
.pipe(jshint.reporter("jshint-stylish"));
});
+gulp.task("peg", function () {
+ return gulp.src(path.peg, path.opts)
+ .pipe(dont_break_on_errors())
+ .pipe(peg({exportVar:"Filt"}))
+ .pipe(gulp.dest(".", path.opts));
+});
+
gulp.task("images", function () {
//(spriting code in commit 4ca720b55680e40b3a4361141a2ad39f9de81111)
- return gulp.src(["src/images/**"])
- .pipe(gulp.dest(path.dist + "static/images"));
+ return gulp.src(path.images, path.opts)
+ .pipe(gulp.dest(path.dist + "static"));
});
gulp.task("html", function () {
- return gulp.src(path.html)
+ return gulp.src(path.html, path.opts)
.pipe(gulp.dest(path.dist + "templates"))
- .pipe(livereload({ auto: false }));
+ .pipe(livereload({auto: false}));
});
-gulp.task('test', function() {
- return gulp.src('src/test.html')
+gulp.task('test', function () {
+ return gulp.src(path.test, path.opts)
.pipe(qunit({verbose: true}));
});
-common = ["fonts", "html", "jshint", "images"];
+common = ["fonts", "html", "jshint", "peg", "images"];
gulp.task("dev", common.concat(["styles-dev", "scripts-dev"]));
gulp.task("prod", common.concat(["styles-prod", "scripts-prod"]));
gulp.task("default", ["dev"], function () {
livereload.listen({auto: true});
- gulp.watch(["src/vendor/**"], ["scripts-vendor-dev", "styles-vendor-dev"]);
- gulp.watch(["src/js/**"], ["scripts-app-dev", "jshint"]);
- gulp.watch(["src/css/**"], ["styles-app-dev"]);
- gulp.watch(["src/images/**", "src/css/sprites.less"], ["sprites"]);
- gulp.watch(["src/*.html"], ["html"]);
+ gulp.watch(path.vendor, path.opts, ["scripts-vendor-dev", "styles-vendor-dev"]);
+ gulp.watch(path.js.app, path.opts, ["scripts-app-dev", "jshint"]);
+ gulp.watch(path.peg, path.opts, ["peg"]);
+ gulp.watch(path.css.all, path.opts, ["styles-app-dev"]);
+ gulp.watch(path.html, path.opts, ["html"]);
});