<commit_before>'use strict'

const gulp = require('gulp')
, pkg = require('./package.json')
, postcss = require('gulp-postcss')
, cssnano = require('cssnano')
, cssnext = require('postcss-cssnext')
, selector = require('postcss-custom-selectors')
, nesting = require('postcss-nesting')
, customMedia = require("postcss-custom-media")
, copyright = `/**
* vishnucss v${pkg.version}
* ${pkg.description}
* https://vishnucss.github.io/vishnu
*/\r\n`
, $ = require('gulp-load-plugins')()
, browserSync = require('browser-sync').create(); // create a browser sync instance.

gulp.task('build', function () {
  let plugins = [
    selector(),
    nesting(),
    customMedia(),
    cssnext({browsers: ['last 1 version']})
  ]
  return gulp.src([
      './src/variables.css',
      './src/reset.css',
      './src/typography.css',
      './src/links.css',
      './src/buttons.css',
      './src/forms.css',
      './src/lists.css',
      './src/tables.css',
      './src/images.css',
      './src/utils.css',
      './src/misc.css',
      './src/grid.css',
      './src/responsive.css'
    ])
    .pipe($.sourcemaps.init())
    .pipe($.concat('vishnu.css'))
    .pipe(postcss(plugins))
    .pipe($.header(copyright + '\n'))
    .pipe($.size())
    .pipe($.sourcemaps.write('.'))
    .pipe(gulp.dest('./dist/'))
})

gulp.task('minify', ['build'], function() {
  let plugins = [
    selector(),
    cssnano(),
    nesting(),
    customMedia(),
    cssnext({browsers: ['last 1 version']})
  ]
  return gulp.src(['./dist/vishnu.css'])
    .pipe($.sourcemaps.init())
    .pipe(postcss(plugins))
    .pipe($.header(copyright))
    .pipe($.size())
    .pipe($.size({
      gzip: true
    }))
    .pipe($.concat('vishnu.min.css'))
    .pipe($.sourcemaps.write('.'))
    .pipe(gulp.dest('./dist/'))
    .pipe(browserSync.reload({stream: true}))
})

gulp.task('browserSync', function() {
  browserSync.init({
    server: {
      baseDir: "./docs"
    }
  })
})

gulp.task('watch', function() {
  gulp.watch(['src/*.css'], ['default'])
  gulp.watch("./docs/*.html").on('change', browserSync.reload)
})

gulp.task('serve', ['browserSync', 'watch'])
gulp.task('default', ['build', 'minify'])
<commit_msg>Organize gulpfile.js<commit_after>/*
* Config Gulpfile
*/

'use strict'

const gulp = require('gulp')
, pkg = require('./package.json')
, symdest = require('gulp-symdest')
, postcss = require('gulp-postcss')
, cssnano = require('cssnano')
, cssnext = require('postcss-cssnext')
, selector = require('postcss-custom-selectors')
, nesting = require('postcss-nesting')
, customMedia = require("postcss-custom-media")
, copyright = `/**
* vishnucss v${pkg.version}
* ${pkg.description}
* https://vishnucss.github.io/vishnu
*/\r\n`
, $ = require('gulp-load-plugins')()
, browserSync = require('browser-sync').create(); // create a browser sync instance.

/*
* Build task
*/
gulp.task('build', function () {
  let plugins = [
    selector(),
    nesting(),
    customMedia(),
    cssnext({browsers: ['last 1 version']})
  ]
  return gulp.src([
      './src/variables.css',
      './src/reset.css',
      './src/typography.css',
      './src/links.css',
      './src/buttons.css',
      './src/forms.css',
      './src/lists.css',
      './src/placeholder.css',
      './src/tables.css',
      './src/images.css',
      './src/utils.css',
      './src/misc.css',
      './src/card.css',
      './src/grid.css',
      './src/responsive.css'
    ])
    .pipe($.sourcemaps.init())
    .pipe($.concat('vishnu.css'))
    .pipe(postcss(plugins))
    .pipe($.header(copyright + '\n'))
    .pipe($.size())
    .pipe($.sourcemaps.write('.'))
    .pipe(gulp.dest('./dist/'))
})

/*
* Minify in build
*/
gulp.task('minify', ['build'], function() {
  let plugins = [
    selector(),
    cssnano(),
    nesting(),
    customMedia(),
    cssnext({browsers: ['last 1 version']})
  ]
  return gulp.src(['./dist/vishnu.css'])
    .pipe($.sourcemaps.init())
    .pipe(postcss(plugins))
    .pipe($.header(copyright))
    .pipe($.size())
    .pipe($.size({
      gzip: true
    }))
    .pipe($.concat('vishnu.min.css'))
    .pipe($.sourcemaps.write('.'))
    .pipe(gulp.dest('./dist/'))
    .pipe(symdest('./docs/'))
    .pipe(browserSync.reload({stream: true}))
})

/*
* Dev to docs web browser
*/
gulp.task('browserSync', function() {
  browserSync.init({
    server: {
      baseDir: "./docs"
    }
  })
})

/*
* Watch tasks
*/
gulp.task('watch', function() {
  gulp.watch(['src/*.css'], ['default'])
  gulp.watch("./docs/*.html").on('change', browserSync.reload)
})

/*
* Running commands to development and build
*/
gulp.task('serve', ['browserSync', 'watch'])
gulp.task('default', ['build', 'minify'])
<|endoftext|>


<commit_before>"use strict";

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

var version = 'chd5-2.1_5.3.0/';

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

var paths = {
	js: {
		src: basePaths.src + 'impala.js',
		dest: basePaths.dest
	},
	thrift: {
		src: basePaths.src + version + '*.thrift',
		dest: basePaths.dest + version
	}
};

// 'gulp' command runs watch task as default
gulp.task('default', ['watch']);

gulp.task('watch', ['js'], () => {
	// Watch changes on impala.js
	gulp.watch(paths.js.src, ['js']);
});

// Generate thrift files
gulp.task('thrift', () => {
	return gulp.src(paths.thrift.src)
		.pipe(thrift({gen:'js:node'}))
		.pipe(gulp.dest(paths.thrift.dest));
});

// Copy impla.js from src/ to lib/
gulp.task('js', () => {
	return gulp.src(paths.js.src)
		.pipe(gulp.dest(paths.js.dest));
});
<commit_msg>Polishing<commit_after>"use strict";

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

var version = 'chd5-2.1_5.3.0/';

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

var paths = {
  js: {
    src: basePaths.src + 'impala.js',
    dest: basePaths.dest
  },
  thrift: {
    src: basePaths.src + version + '*.thrift',
    dest: basePaths.dest + version
  }
};

// 'gulp' command runs watch task as default
gulp.task('default', ['watch']);

gulp.task('watch', ['js'], () => {
  // Watch changes on impala.js
  gulp.watch(paths.js.src, ['js']);
});

// Generate thrift files
gulp.task('thrift', () => {
  return gulp.src(paths.thrift.src)
    .pipe(thrift({gen:'js:node'}))
    .pipe(gulp.dest(paths.thrift.dest));
});

// Copy impla.js from src/ to lib/
gulp.task('js', () => {
  return gulp.src(paths.js.src)
    .pipe(gulp.dest(paths.js.dest));
});
<|endoftext|>


<commit_before>/**
 * gulpfile.js - Gulp-based build
 *
 * Copyright (c) 2015 Cisco Systems, Inc. See LICENSE file.
 */
"use strict";

var ARGV = require("yargs").
    usage("$0 [options] task [task ...]").
    option("browsers", {
      type: "string",
      describe: "browsers to run tests in",
      default: ""
    }).
    option("sauce", {
      type: "boolean",
      describe: "use SauceLabs for tests/reporting",
      default: false
    }).
    help("help").
    argv;

var browserify = require("browserify"),
    clone = require("lodash.clone"),
    del = require("del"),
    doctoc = require("gulp-doctoc"),
    gulp = require("gulp"),
    istanbul = require("gulp-istanbul"),
    karma = require("karma"),
    merge = require("lodash.merge"),
    mocha = require("gulp-mocha"),
    runSequence = require("run-sequence");

// ### 'CONSTANTS' ###
var SOURCES = ["./lib/**/*.js", "!(./lib/old/**/*.js)"],
    TESTS = "./test/**/*-test.js";

// ### HELPERS ###
var MOCHA_CONFIG = {
  timeout: 600000
};

// ### LINT TASKS ###
function doEslint() {
  var eslint = require("gulp-eslint");

  return gulp.src([
    "lib/**/*.js",
    "test/**/*.js",
    "gulpfile.js"
  ])
    .pipe(eslint())
    .pipe(eslint.format());
}

gulp.task("eslint", function() {
  return doEslint();
});

gulp.task("test:lint", function() {
  var eslint = require("gulp-eslint");
  return doEslint()
    .pipe(eslint.failOnError());
});

// ### CLEAN TASKS ###
gulp.task("clean:coverage:nodejs", function() {
  del("coverage/nodejs");
});
gulp.task("clean:coverage:browser", function() {
  del("coverage/browser");
});
gulp.task("clean:coverage", function() {
  del("coverage");
});

gulp.task("clean:dist", function() {
  del("dist");
});

// ### DOCUMENTATION TASKS ###
gulp.task("doc:readme", function() {
  gulp.src("./README.md").
       pipe(doctoc({
         title: ""
       })).
       pipe(gulp.dest("./"));
});

// ### NODEJS TASKS ###
function doTestsNodejs() {
  return gulp.src(TESTS).
              pipe(mocha(MOCHA_CONFIG));
}

gulp.task("test:nodejs:single", function() {
  return doTestsNodejs();
});

gulp.task("cover:nodejs", function() {
  return gulp.src(SOURCES).
              pipe(istanbul()).
              pipe(istanbul.hookRequire()).
              on("finish", function() {
                doTestsNodejs().
                pipe(istanbul.writeReports({
                  dir: "./coverage/nodejs",
                  reporters: ["html", "text-summary"]
                }));
              });
});

gulp.task("test:nodejs", function(cb) {
  runSequence("test:lint",
              "test:nodejs:single",
              cb);
});

// ### BROWSER TASKS ###
function doBrowserify(suffix, steps) {
  var source = require("vinyl-source-stream"),
      buffer = require("vinyl-buffer"),
      sourcemaps = require("gulp-sourcemaps");

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

  suffix = suffix || ".js";
  steps = steps || [];

  var stream = browserify({
    entries: require("path").resolve(pkg.main),
    standalone: "kms"
  }).bundle().
  pipe(source(pkg.name + suffix)).
  pipe(buffer());

  steps.forEach(function(s) {
    stream = stream.pipe(s);
  });

  return stream.pipe(sourcemaps.init({ loadMaps: true })).
                pipe(sourcemaps.write("./")).
                pipe(gulp.dest("./dist"));
}

gulp.task("bundle", function() {
  return doBrowserify();
});

gulp.task("minify", function() {
  var uglify = require("gulp-uglify");

  return doBrowserify(".min.js", [
    uglify()
  ]);
});

var KARMA_CONFIG = {
  frameworks: ["mocha", "browserify"],
  basePath: ".",
  browserNoActivityTimeout: 600000,
  client: {
    mocha: MOCHA_CONFIG
  },
  preprocessors: {
    "test/**/*-test.js": ["browserify"]
  },
  reporters: ["mocha"],
  browserify: {
    debug: true
  },
  customLaunchers: {
    "SL_Chrome": {
      base: "SauceLabs",
      browserName: "chrome"
    },
    "SL_Firefox": {
      base: "SauceLabs",
      browserName: "firefox"
    },
    "SL_Safari": {
      base: "SauceLabs",
      platform: "OS X 10.9",
      browserName: "safari",
      version: "7"
    },
    "SL_IE": {
      base: "SauceLabs",
      browserName: "internet explorer",
      version: "10"
    }
  },
  captureTimeout: 600000,
  sauceLabs: {
    testName: "node-scr"
  },
  files: [TESTS]
};
var KARMA_BROWSERS = {
  local: ["Chrome", "Firefox", "Safari"],
  saucelabs: ["SL_Chrome", "SL_Firefox", "SL_IE", "SL_Safari"]
};
// allow for IE on windows
if (/^win/.test(process.platform)) {
  KARMA_BROWSERS.local.push("IE");
}

gulp.task("test:browser:single", function(done) {
  var browsers = ARGV.browsers.split(/\s*,\s*/g).
                 filter(function (v) { return v; });

  var config = merge({}, KARMA_CONFIG, {
    singleRun: true
  });
  if (ARGV.sauce) {
    config = merge(config, {
      reporters: ["mocha", "saucelabs"],
      browsers: KARMA_BROWSERS.saucelabs
    });
  } else {
    config.browsers = KARMA_BROWSERS.local;
  }
  if (browsers.length) {
    config.browsers = config.browsers.filter(function(b) {
      b = b.replace("SL_", "");
      return -1 !== browsers.indexOf(b);
    });
  }

  karma.server.start(config, done);
});

gulp.task("test:browser:watch", function(done) {
  var config = clone(KARMA_CONFIG);

  karma.server.start(config, done);
});

gulp.task("test:browser", function(cb) {
  runSequence("test:lint",
              "test:browser:single",
              cb);
});

// ### MAIN TASKS ###
gulp.task("test", function(cb) {
  runSequence("test:lint",
              "test:browser:single",
              "test:nodejs:single",
              cb);
});
gulp.task("coverage", function(cb) {
  runSequence("test:lint",
              "cover:nodejs",
              cb);
});
gulp.task("clean", ["clean:coverage", "clean:dist"]);
gulp.task("dist", function(cb) {
  runSequence("clean:dist",
              "test:lint",
              "test:browser",
              ["bundle", "minify"],
              cb);
});

// ### MAIN WATCHERS ###
gulp.task("watch:test", ["test"], function() {
  return gulp.watch([SOURCES, TESTS], ["test:nodejs", "test:browser"]);
});

// ### DEFAULT ###
gulp.task("default", ["test"]);
<commit_msg>Build: Fix test naming<commit_after>/**
 * gulpfile.js - Gulp-based build
 *
 * Copyright (c) 2015 Cisco Systems, Inc. See LICENSE file.
 */
"use strict";

var ARGV = require("yargs").
    usage("$0 [options] task [task ...]").
    option("browsers", {
      type: "string",
      describe: "browsers to run tests in",
      default: ""
    }).
    option("sauce", {
      type: "boolean",
      describe: "use SauceLabs for tests/reporting",
      default: false
    }).
    help("help").
    argv;

var browserify = require("browserify"),
    clone = require("lodash.clone"),
    del = require("del"),
    doctoc = require("gulp-doctoc"),
    gulp = require("gulp"),
    istanbul = require("gulp-istanbul"),
    karma = require("karma"),
    merge = require("lodash.merge"),
    mocha = require("gulp-mocha"),
    runSequence = require("run-sequence");

// ### 'CONSTANTS' ###
var SOURCES = ["./lib/**/*.js", "!(./lib/old/**/*.js)"],
    TESTS = "./test/**/*-test.js";

// ### HELPERS ###
var MOCHA_CONFIG = {
  timeout: 600000
};

// ### LINT TASKS ###
function doEslint() {
  var eslint = require("gulp-eslint");

  return gulp.src([
    "lib/**/*.js",
    "test/**/*.js",
    "gulpfile.js"
  ])
    .pipe(eslint())
    .pipe(eslint.format());
}

gulp.task("eslint", function() {
  return doEslint();
});

gulp.task("test:lint", function() {
  var eslint = require("gulp-eslint");
  return doEslint()
    .pipe(eslint.failOnError());
});

// ### CLEAN TASKS ###
gulp.task("clean:coverage:nodejs", function() {
  del("coverage/nodejs");
});
gulp.task("clean:coverage:browser", function() {
  del("coverage/browser");
});
gulp.task("clean:coverage", function() {
  del("coverage");
});

gulp.task("clean:dist", function() {
  del("dist");
});

// ### DOCUMENTATION TASKS ###
gulp.task("doc:readme", function() {
  gulp.src("./README.md").
       pipe(doctoc({
         title: ""
       })).
       pipe(gulp.dest("./"));
});

// ### NODEJS TASKS ###
function doTestsNodejs() {
  return gulp.src(TESTS).
              pipe(mocha(MOCHA_CONFIG));
}

gulp.task("test:nodejs:single", function() {
  return doTestsNodejs();
});

gulp.task("cover:nodejs", function() {
  return gulp.src(SOURCES).
              pipe(istanbul()).
              pipe(istanbul.hookRequire()).
              on("finish", function() {
                doTestsNodejs().
                pipe(istanbul.writeReports({
                  dir: "./coverage/nodejs",
                  reporters: ["html", "text-summary"]
                }));
              });
});

gulp.task("test:nodejs", function(cb) {
  runSequence("test:lint",
              "test:nodejs:single",
              cb);
});

// ### BROWSER TASKS ###
function doBrowserify(suffix, steps) {
  var source = require("vinyl-source-stream"),
      buffer = require("vinyl-buffer"),
      sourcemaps = require("gulp-sourcemaps");

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

  suffix = suffix || ".js";
  steps = steps || [];

  var stream = browserify({
    entries: require("path").resolve(pkg.main),
    standalone: "kms"
  }).bundle().
  pipe(source(pkg.name + suffix)).
  pipe(buffer());

  steps.forEach(function(s) {
    stream = stream.pipe(s);
  });

  return stream.pipe(sourcemaps.init({ loadMaps: true })).
                pipe(sourcemaps.write("./")).
                pipe(gulp.dest("./dist"));
}

gulp.task("bundle", function() {
  return doBrowserify();
});

gulp.task("minify", function() {
  var uglify = require("gulp-uglify");

  return doBrowserify(".min.js", [
    uglify()
  ]);
});

var KARMA_CONFIG = {
  frameworks: ["mocha", "browserify"],
  basePath: ".",
  browserNoActivityTimeout: 600000,
  client: {
    mocha: MOCHA_CONFIG
  },
  preprocessors: {
    "test/**/*-test.js": ["browserify"]
  },
  reporters: ["mocha"],
  browserify: {
    debug: true
  },
  customLaunchers: {
    "SL_Chrome": {
      base: "SauceLabs",
      browserName: "chrome"
    },
    "SL_Firefox": {
      base: "SauceLabs",
      browserName: "firefox"
    },
    "SL_Safari": {
      base: "SauceLabs",
      platform: "OS X 10.9",
      browserName: "safari",
      version: "7"
    },
    "SL_IE": {
      base: "SauceLabs",
      browserName: "internet explorer",
      version: "10"
    }
  },
  captureTimeout: 600000,
  sauceLabs: {
    testName: "node-kms"
  },
  files: [TESTS]
};
var KARMA_BROWSERS = {
  local: ["Chrome", "Firefox", "Safari"],
  saucelabs: ["SL_Chrome", "SL_Firefox", "SL_IE", "SL_Safari"]
};
// allow for IE on windows
if (/^win/.test(process.platform)) {
  KARMA_BROWSERS.local.push("IE");
}

gulp.task("test:browser:single", function(done) {
  var browsers = ARGV.browsers.split(/\s*,\s*/g).
                 filter(function (v) { return v; });

  var config = merge({}, KARMA_CONFIG, {
    singleRun: true
  });
  if (ARGV.sauce) {
    config = merge(config, {
      reporters: ["mocha", "saucelabs"],
      browsers: KARMA_BROWSERS.saucelabs
    });
  } else {
    config.browsers = KARMA_BROWSERS.local;
  }
  if (browsers.length) {
    config.browsers = config.browsers.filter(function(b) {
      b = b.replace("SL_", "");
      return -1 !== browsers.indexOf(b);
    });
  }

  karma.server.start(config, done);
});

gulp.task("test:browser:watch", function(done) {
  var config = clone(KARMA_CONFIG);

  karma.server.start(config, done);
});

gulp.task("test:browser", function(cb) {
  runSequence("test:lint",
              "test:browser:single",
              cb);
});

// ### MAIN TASKS ###
gulp.task("test", function(cb) {
  runSequence("test:lint",
              "test:browser:single",
              "test:nodejs:single",
              cb);
});
gulp.task("coverage", function(cb) {
  runSequence("test:lint",
              "cover:nodejs",
              cb);
});
gulp.task("clean", ["clean:coverage", "clean:dist"]);
gulp.task("dist", function(cb) {
  runSequence("clean:dist",
              "test:lint",
              "test:browser",
              ["bundle", "minify"],
              cb);
});

// ### MAIN WATCHERS ###
gulp.task("watch:test", ["test"], function() {
  return gulp.watch([SOURCES, TESTS], ["test:nodejs", "test:browser"]);
});

// ### DEFAULT ###
gulp.task("default", ["test"]);
<|endoftext|>


<commit_before>// =============================================
// Project Settings
// edit these variables to suit your project
// **this is the only section you should need to edit
// =============================================

var project = {
    name: 'chopchop',
    source: './src',
    dist: './build',
    scss: 'scss',
    css: 'css',
    js: 'js',
    images: 'img',
    fonts: 'fonts',
    vendor: 'vendor',
    bower: './build/bower_components',
    autoprefixer: ['last 2 versions'],
    imageOptimisation: {
        optimizationLevel: 3,   // PNG (Between 0 - 7)
        progressive: true,      // JPG
        interlaced: true        // GIF
    }
};

// =============================================
// Dependencies
// =============================================

var gulp = require('gulp'),
    plugin = {
        util:               require('gulp-util'),
        browserSync:        require('browser-sync'),
        bower:              require('gulp-bower'),
        del:                require('del'),
        runSequence:        require('run-sequence'),
        imageMin:           require('gulp-imagemin'),
        sass:               require('gulp-sass'),
        autoPrefixer:       require('gulp-autoprefixer'),
        clipEmptyFiles:     require('gulp-clip-empty-files'),
        combineMq:          require('gulp-combine-mq'),
        jsHint:             require('gulp-jshint'),
        cssNano:            require('gulp-cssnano'),
        uglify:             require('gulp-uglify'),
        changed:            require('gulp-changed'),
        sourcemaps:         require('gulp-sourcemaps')
    };

// =============================================
// Enviroment Variables
// =============================================

var dev = plugin.util.env.dev,
    production = plugin.util.env.production;

// =============================================
// Paths
// =============================================

var scss = {
        source: project.source + '/' + project.scss + '/**/*.scss',
        build: project.dist + '/' + project.css
    },
    js = {
        source: [
            project.source + '/' + project.js + '/**/*.js',
            '!' + project.source + '/' + project.js + '/**/_*.js',
        ],
        build: project.dist + '/' + project.js
    },
    img = {
        source: project.source + '/' + project.images + '/**/*.*',
        build: project.dist + '/' + project.images
    },
    fonts = {
        source: project.source + '/' + project.fonts + '/**/*.*',
        build: project.dist + '/' + project.fonts
    },
    vendor = {
        source: project.source + '/' + project.vendor + '/**/*.*',
        build: project.dist + '/' + project.vendor
    },
    bower = './' + project.bower;

// =============================================
// BROWSER SYNC `gulp browser-sync`
// injects css changes and auto reloads on js changes
// ** gets developer name from enviroment name
// =============================================

gulp.task('browser-sync', function() {
    if(dev) {
        plugin.browserSync({
	    proxy: 'http://' + project.name + '.' + plugin.util.env.name + '.dyn.iweb.co.uk/'
        });
    }
});

// =============================================
// BOWER `gulp bower`
// installs dependencies from the bower.json file
// =============================================

gulp.task('bower', function() {
    return plugin.bower()
        .pipe(gulp.dest(bower));
});

// =============================================
// FONTS `gulp fonts`
// moves fonts to build directory
// =============================================

gulp.task('fonts', function() {
    return gulp.src(fonts.source)
        .pipe(plugin.changed(fonts.build))
        .pipe(gulp.dest(fonts.build));
});

// =============================================
// VENDOR `gulp vendor`
// moves vendor to build directory
// =============================================

gulp.task('vendor', function() {
    return gulp.src(vendor.source)
        .pipe(plugin.changed(vendor.build))
        .pipe(gulp.dest(vendor.build));
});

// =============================================
// IMG `gulp img`
// minifys images
// =============================================

gulp.task('img', function() {
    return gulp.src(img.source)
        .pipe(plugin.changed(img.build))
        .pipe(plugin.util.env.production ? plugin.imageMin(project.imageOptimisation) : plugin.util.noop())
        .pipe(gulp.dest(img.build));
});

// =============================================
// JS `gulp js`
// compiles js, Jshint, Minify if `--production`
// =============================================

gulp.task('js', function() {
    return gulp.src(js.source)
        .pipe(plugin.jsHint())
        .pipe(plugin.jsHint.reporter('default'))
        .pipe(plugin.util.env.production ? plugin.uglify() : plugin.util.noop())
        .pipe(gulp.dest(js.build))
        .pipe(plugin.util.env.dev ? plugin.browserSync.reload({stream: true}) : plugin.util.noop());
});

// =============================================
// CSS `gulp css`
// compiles scss to css, autoprefixer, combines media queries and minifies if `--production`
// =============================================

gulp.task('css', function() {
    return gulp.src(scss.source)
        .pipe(plugin.clipEmptyFiles())
        .pipe(plugin.util.env.dev ? plugin.sourcemaps.init() : plugin.util.noop())
        .pipe(plugin.sass.sync().on('error', plugin.sass.logError))
        .pipe(plugin.autoPrefixer(project.autoprefixer))
        .pipe(plugin.util.env.dev ? plugin.sourcemaps.write() : plugin.util.noop())
        .pipe(plugin.util.env.production ? plugin.combineMq() : plugin.util.noop())
        .pipe(plugin.util.env.production ? plugin.cssNano() : plugin.util.noop())
        .pipe(gulp.dest(scss.build))
        .pipe(plugin.util.env.dev ? plugin.browserSync.reload({stream: true}) : plugin.util.noop());
});

// =============================================
// Clean `gulp clean
// destroys the build directory
// =============================================

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

// =============================================
// Watch 'gulp watch'
// watches for changes and runs the associated task on change
// =============================================

gulp.task('watch', ['browser-sync'], function(cb) {
    gulp.watch(scss.source, ['css']);
    gulp.watch(js.source, ['js']);
    gulp.watch(img.source, ['img']);
    gulp.watch(fonts.source, ['fonts']);
    gulp.watch(vendor.source, ['vendor']);
});

// =============================================
// Build 'gulp build'
// builds all assets, also has `--production` option to build production ready assets
// =============================================

gulp.task('build', function(cb) {
    plugin.runSequence('clean', ['bower', 'css', 'js', 'img', 'fonts', 'vendor'], cb);
});

// =============================================
// Default 'gulp'
// runs build task, then runs watche task
// =============================================

gulp.task('default', function(cb) {
    plugin.runSequence('build', 'watch', cb);
});
<commit_msg>created option object<commit_after>// =============================================
// Project Settings
// edit these variables to suit your project
// =============================================

var project = {
    name: 'chopchop',
    source: './src',
    dist: './build',
    scss: 'scss',
    css: 'css',
    js: 'js',
    images: 'img',
    fonts: 'fonts',
    vendor: 'vendor',
    bower: './build/bower_components',
};

// =============================================
// Options
// edit these variables to suit your project
// =============================================

var option = {
    autoprefixer: ['last 2 versions'],
    imageOptimisation: {
        optimizationLevel: 3,   // PNG (Between 0 - 7)
        progressive: true,      // JPG
        interlaced: true        // GIF
    }
};

// =============================================
// Dependencies
// =============================================

var gulp = require('gulp'),
    plugin = {
        util:               require('gulp-util'),
        browserSync:        require('browser-sync'),
        bower:              require('gulp-bower'),
        del:                require('del'),
        runSequence:        require('run-sequence'),
        imageMin:           require('gulp-imagemin'),
        sass:               require('gulp-sass'),
        autoPrefixer:       require('gulp-autoprefixer'),
        clipEmptyFiles:     require('gulp-clip-empty-files'),
        combineMq:          require('gulp-combine-mq'),
        jsHint:             require('gulp-jshint'),
        cssNano:            require('gulp-cssnano'),
        uglify:             require('gulp-uglify'),
        changed:            require('gulp-changed'),
        sourcemaps:         require('gulp-sourcemaps')
    };

// =============================================
// Enviroment Variables
// =============================================

var dev = plugin.util.env.dev,
    production = plugin.util.env.production;

// =============================================
// Paths
// =============================================

var scss = {
        source: project.source + '/' + project.scss + '/**/*.scss',
        build: project.dist + '/' + project.css
    },
    js = {
        source: [
            project.source + '/' + project.js + '/**/*.js',
            '!' + project.source + '/' + project.js + '/**/_*.js',
        ],
        build: project.dist + '/' + project.js
    },
    img = {
        source: project.source + '/' + project.images + '/**/*.*',
        build: project.dist + '/' + project.images
    },
    fonts = {
        source: project.source + '/' + project.fonts + '/**/*.*',
        build: project.dist + '/' + project.fonts
    },
    vendor = {
        source: project.source + '/' + project.vendor + '/**/*.*',
        build: project.dist + '/' + project.vendor
    },
    bower = './' + project.bower;

// =============================================
// BROWSER SYNC `gulp browser-sync`
// injects css changes and auto reloads on js changes
// ** gets developer name from enviroment name
// =============================================

gulp.task('browser-sync', function() {
    if(dev) {
        plugin.browserSync({
	    proxy: 'http://' + project.name + '.' + plugin.util.env.name + '.dyn.iweb.co.uk/'
        });
    }
});

// =============================================
// BOWER `gulp bower`
// installs dependencies from the bower.json file
// =============================================

gulp.task('bower', function() {
    return plugin.bower()
        .pipe(gulp.dest(bower));
});

// =============================================
// FONTS `gulp fonts`
// moves fonts to build directory
// =============================================

gulp.task('fonts', function() {
    return gulp.src(fonts.source)
        .pipe(plugin.changed(fonts.build))
        .pipe(gulp.dest(fonts.build));
});

// =============================================
// VENDOR `gulp vendor`
// moves vendor to build directory
// =============================================

gulp.task('vendor', function() {
    return gulp.src(vendor.source)
        .pipe(plugin.changed(vendor.build))
        .pipe(gulp.dest(vendor.build));
});

// =============================================
// IMG `gulp img`
// minifys images
// =============================================

gulp.task('img', function() {
    return gulp.src(img.source)
        .pipe(plugin.changed(img.build))
        .pipe(plugin.util.env.production ? plugin.imageMin(option.imageOptimisation) : plugin.util.noop())
        .pipe(gulp.dest(img.build));
});

// =============================================
// JS `gulp js`
// compiles js, Jshint, Minify if `--production`
// =============================================

gulp.task('js', function() {
    return gulp.src(js.source)
        .pipe(plugin.jsHint())
        .pipe(plugin.jsHint.reporter('default'))
        .pipe(plugin.util.env.production ? plugin.uglify() : plugin.util.noop())
        .pipe(gulp.dest(js.build))
        .pipe(plugin.util.env.dev ? plugin.browserSync.reload({stream: true}) : plugin.util.noop());
});

// =============================================
// CSS `gulp css`
// compiles scss to css, autoprefixer, combines media queries and minifies if `--production`
// =============================================

gulp.task('css', function() {
    return gulp.src(scss.source)
        .pipe(plugin.clipEmptyFiles())
        .pipe(plugin.util.env.dev ? plugin.sourcemaps.init() : plugin.util.noop())
        .pipe(plugin.sass.sync().on('error', plugin.sass.logError))
        .pipe(plugin.autoPrefixer(option.autoprefixer))
        .pipe(plugin.util.env.dev ? plugin.sourcemaps.write() : plugin.util.noop())
        .pipe(plugin.util.env.production ? plugin.combineMq() : plugin.util.noop())
        .pipe(plugin.util.env.production ? plugin.cssNano() : plugin.util.noop())
        .pipe(gulp.dest(scss.build))
        .pipe(plugin.util.env.dev ? plugin.browserSync.reload({stream: true}) : plugin.util.noop());
});

// =============================================
// Clean `gulp clean
// destroys the build directory
// =============================================

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

// =============================================
// Watch 'gulp watch'
// watches for changes and runs the associated task on change
// =============================================

gulp.task('watch', ['browser-sync'], function(cb) {
    gulp.watch(scss.source, ['css']);
    gulp.watch(js.source, ['js']);
    gulp.watch(img.source, ['img']);
    gulp.watch(fonts.source, ['fonts']);
    gulp.watch(vendor.source, ['vendor']);
});

// =============================================
// Build 'gulp build'
// builds all assets, also has `--production` option to build production ready assets
// =============================================

gulp.task('build', function(cb) {
    plugin.runSequence('clean', ['bower', 'css', 'js', 'img', 'fonts', 'vendor'], cb);
});

// =============================================
// Default 'gulp'
// runs build task, then runs watche task
// =============================================

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


<commit_before>'use strict';

var gulp = require('gulp');
var inject = require('gulp-inject');
var less = require('gulp-less');
var del = require('del');
var runSequence = require('run-sequence');
var browserify = require('browserify');
var reactify = require('reactify'); // for browserify
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var stylish = require('gulp-jscs-stylish');
var react = require('gulp-react'); // for jshint
var concat = require('gulp-concat');
var cssmin = require('gulp-minify-css');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var lr = require('tiny-lr')();

var config = require('./config/config.js');

// from http://rhumaric.com/2014/01/livereload-magic-gulp-style/
function startExpress() {
  var app = require('./app.js');
  app.use(require('connect-livereload')());
  app.listen(config.port);
}

function startLivereload() {
  lr.listen(35729);
}

function notifyLivereload(event) {
  // this should, but does not work, so using the solution below
  //gulp.src(event.path, {read: false}).pipe(require('gulp-livereload')(lr));

  var fileName = require('path').relative(__dirname, event.path);
  lr.changed({
    body: {
      files: [fileName]
    }
  });
}

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

gulp.task('img', function() {
  return gulp.src('./frontend/src/img/**/*.{jpg,gif,png}')
  .pipe(gulp.dest('./frontend/build/public/img/'));
});

gulp.task('fonts', function() {
  return gulp.src('./frontend/src/bootstrap/fonts/*')
  .pipe(gulp.dest('./frontend/build/public/fonts/'));
});

gulp.task('css:store', function() {
  return gulp.src(['./frontend/src/css/*.less', '!./frontend/src/css/admin*.less'])
      .pipe(less())
      .pipe(concat('style.css'))
      .pipe(gulp.dest('./frontend/build/public/css/'));
});

gulp.task('css:admin', function() {
  return gulp.src('./frontend/src/css/admin*.less')
      .pipe(less())
      .pipe(concat('admin.css'))
      .pipe(gulp.dest('./frontend/build/public/css/'));
});

gulp.task('css:min', function() {
  gulp.src(['./frontend/src/css/*.less', '!./frontend/src/css/admin*.less'])
      .pipe(less())
      .pipe(concat('style.css'))
      .pipe(cssmin())
      .pipe(gulp.dest('./frontend/build/public/css/'));
});

gulp.task('css', ['css:store', 'css:admin']);

gulp.task('lint', function() {
  return gulp.src(['frontend/src/**/*.{js,jsx}', '!./frontend/src/bootstrap/**/*.js']) // lint reactified JS
  .pipe(plumber())
  .pipe(jscs())
  .pipe(react())
  .pipe(jshint())
  .pipe(stylish.combineWithHintResults())
  .pipe(jshint.reporter('jshint-stylish'));
});

gulp.task('js:store', ['lint'], function() {
  return browserify('./frontend/src/js/App.jsx')
  .transform(reactify)
  .bundle()
  .on('error', function(err) {
    notify.onError({
      message: '<%= error.message %>'
    }).apply(this, arguments);
    this.emit('end');
  })
  .pipe(source('App.js'))
  .pipe(gulp.dest('./frontend/build/public/js/'));
});

gulp.task('js:admin', function() {
  return browserify('./frontend/src/js-admin/AdminApp.jsx')
  .transform(reactify)
  .bundle()
  .on('error', function(err) {
    notify.onError({
      message: '<%= error.message %>'
    }).apply(this, arguments);
    this.emit('end');
  })
  .pipe(source('adminApp.js'))
  .pipe(gulp.dest('./frontend/build/public/js/'));
});

gulp.task('js', ['js:store', 'js:admin']);

gulp.task('js:store:min', function() {
  return browserify('./frontend/src/js/App.jsx')
  .transform(reactify)
  .bundle()
  .pipe(source('App.js'))
  .pipe(buffer())
  .pipe(uglify())
  .pipe(gulp.dest('./frontend/build/public/js/'));
});

gulp.task('js:admin:min', function() {
  return browserify('./frontend/src/js-admin/AdminApp.jsx')
  .transform(reactify)
  .bundle()
  .pipe(source('adminApp.js'))
  .pipe(buffer())
  .pipe(uglify())
  .pipe(gulp.dest('./frontend/build/public/js/'));
});

gulp.task('js:min', ['js:store:min', 'js:admin:min']);

gulp.task('index', function() {
  return gulp.src('./frontend/src/index.html')
      .pipe(inject(gulp.src(['./public/**/*.{css,js}', '!./public/**/admin*'], {read: false, cwd: './frontend/build/'}), {addRootSlash: false}))
      .pipe(inject(gulp.src('./config/google-analytics.js'), {name: 'analytics', transform: function(path, file) { return file.contents.toString('utf8'); }}))
      .pipe(gulp.dest('./frontend/build/'));
});

gulp.task('admin', function() {
  return gulp.src('./frontend/src/admin.html')
      .pipe(inject(gulp.src('./public/**/admin*.{css,js}', {read: false, cwd: './frontend/build/'}), {addRootSlash: false}))
      .pipe(gulp.dest('./frontend/build/'));
});

gulp.task('lint-backend', function() {
  return gulp.src('backend/**/*.js') // lint reactified JS
  .pipe(plumber())
  .pipe(jscs())
  .pipe(jshint())
  .pipe(stylish.combineWithHintResults())
  .pipe(jshint.reporter('jshint-stylish'));
});

gulp.task('build-dev', function(cb) {
  runSequence(
    ['clean'],
    ['lint-backend', 'css', 'js', 'img', 'fonts'],
    ['index', 'admin'],
    cb);
});

gulp.task('build', function(cb) {
  runSequence(
    ['clean'],
    ['lint-backend', 'css:min', 'js:min', 'img', 'fonts'],
    ['index', 'admin'],
    cb);
});

gulp.task('start-dev', function() {
  startExpress();
  startLivereload();
  gulp.watch('frontend/src/css/**/*.{css,less}', ['css', 'index', 'admin']);
  gulp.watch('frontend/src/js*/**/*.{js,jsx}', ['js', 'index', 'admin']);
  gulp.watch('frontend/src/img/**/*.{jpg,gif,png}', ['img']);
  gulp.watch('frontend/src/index.html', ['index']);
  gulp.watch('frontend/src/admin.html', ['admin']);
  gulp.watch('frontend/build/**/*.{html,css,js,jpg,gif,png}', notifyLivereload);
});

gulp.task('start', function() {
  startExpress();
});

gulp.task('default', function(cb) {
  runSequence(
    ['build-dev'],
    ['start-dev'],
    cb);
});
<commit_msg>reuse at least some of the code<commit_after>'use strict';

var gulp = require('gulp');
var inject = require('gulp-inject');
var less = require('gulp-less');
var del = require('del');
var runSequence = require('run-sequence');
var browserify = require('browserify');
var reactify = require('reactify'); // for browserify
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var stylish = require('gulp-jscs-stylish');
var react = require('gulp-react'); // for jshint
var concat = require('gulp-concat');
var cssmin = require('gulp-minify-css');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var lr = require('tiny-lr')();

var config = require('./config/config.js');

// from http://rhumaric.com/2014/01/livereload-magic-gulp-style/
function startExpress() {
  var app = require('./app.js');
  app.use(require('connect-livereload')());
  app.listen(config.port);
}

function startLivereload() {
  lr.listen(35729);
}

function notifyLivereload(event) {
  // this should, but does not work, so using the solution below
  //gulp.src(event.path, {read: false}).pipe(require('gulp-livereload')(lr));

  var fileName = require('path').relative(__dirname, event.path);
  lr.changed({
    body: {
      files: [fileName]
    }
  });
}

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

gulp.task('img', function() {
  return gulp.src('./frontend/src/img/**/*.{jpg,gif,png}')
  .pipe(gulp.dest('./frontend/build/public/img/'));
});

gulp.task('fonts', function() {
  return gulp.src('./frontend/src/bootstrap/fonts/*')
  .pipe(gulp.dest('./frontend/build/public/fonts/'));
});

gulp.task('css:store', function() {
  return gulp.src(['./frontend/src/css/*.less', '!./frontend/src/css/admin*.less'])
      .pipe(less())
      .pipe(concat('style.css'))
      .pipe(gulp.dest('./frontend/build/public/css/'));
});

gulp.task('css:admin', function() {
  return gulp.src('./frontend/src/css/admin*.less')
      .pipe(less())
      .pipe(concat('admin.css'))
      .pipe(gulp.dest('./frontend/build/public/css/'));
});

gulp.task('css:min', function() {
  gulp.src(['./frontend/src/css/*.less', '!./frontend/src/css/admin*.less'])
      .pipe(less())
      .pipe(concat('style.css'))
      .pipe(cssmin())
      .pipe(gulp.dest('./frontend/build/public/css/'));
});

gulp.task('css', ['css:store', 'css:admin']);

gulp.task('lint', function() {
  return gulp.src(['frontend/src/**/*.{js,jsx}', '!./frontend/src/bootstrap/**/*.js']) // lint reactified JS
  .pipe(plumber())
  .pipe(jscs())
  .pipe(react())
  .pipe(jshint())
  .pipe(stylish.combineWithHintResults())
  .pipe(jshint.reporter('jshint-stylish'));
});

function js(startPath, targetFile) {
  return function() {
    return browserify(startPath)
    .transform(reactify)
    .bundle()
    .on('error', function(err) {
      notify.onError({
        message: '<%= error.message %>'
      }).apply(this, arguments);
      this.emit('end');
    })
    .pipe(source(targetFile))
    .pipe(gulp.dest('./frontend/build/public/js/'));
  }
}

function jsMin(startPath, targetFile) {
  return function() {
    return browserify(startPath)
    .transform(reactify)
    .bundle()
    .pipe(source(targetFile))
    .pipe(buffer())
    .pipe(uglify())
    .pipe(gulp.dest('./frontend/build/public/js/'));
  }
}

gulp.task('js:store', ['lint'], js('./frontend/src/js/App.jsx', 'App.js'));
gulp.task('js:admin', js('./frontend/src/js-admin/AdminApp.jsx', 'adminApp.js'));

gulp.task('js', ['js:store', 'js:admin']);

gulp.task('js:store:min', jsMin('./frontend/src/js/App.jsx', 'App.js'));
gulp.task('js:admin:min', jsMin('./frontend/src/js-admin/AdminApp.jsx', 'adminApp.js'));

gulp.task('js:min', ['js:store:min', 'js:admin:min']);

gulp.task('index', function() {
  return gulp.src('./frontend/src/index.html')
      .pipe(inject(gulp.src(['./public/**/*.{css,js}', '!./public/**/admin*'], {read: false, cwd: './frontend/build/'}), {addRootSlash: false}))
      .pipe(inject(gulp.src('./config/google-analytics.js'), {name: 'analytics', transform: function(path, file) { return file.contents.toString('utf8'); }}))
      .pipe(gulp.dest('./frontend/build/'));
});

gulp.task('admin', function() {
  return gulp.src('./frontend/src/admin.html')
      .pipe(inject(gulp.src('./public/**/admin*.{css,js}', {read: false, cwd: './frontend/build/'}), {addRootSlash: false}))
      .pipe(gulp.dest('./frontend/build/'));
});

gulp.task('lint-backend', function() {
  return gulp.src('backend/**/*.js') // lint reactified JS
  .pipe(plumber())
  .pipe(jscs())
  .pipe(jshint())
  .pipe(stylish.combineWithHintResults())
  .pipe(jshint.reporter('jshint-stylish'));
});

gulp.task('build-dev', function(cb) {
  runSequence(
    ['clean'],
    ['lint-backend', 'css', 'js', 'img', 'fonts'],
    ['index', 'admin'],
    cb);
});

gulp.task('build', function(cb) {
  runSequence(
    ['clean'],
    ['lint-backend', 'css:min', 'js:min', 'img', 'fonts'],
    ['index', 'admin'],
    cb);
});

gulp.task('start-dev', function() {
  startExpress();
  startLivereload();
  gulp.watch('frontend/src/css/**/*.{css,less}', ['css', 'index', 'admin']);
  gulp.watch('frontend/src/js*/**/*.{js,jsx}', ['js', 'index', 'admin']);
  gulp.watch('frontend/src/img/**/*.{jpg,gif,png}', ['img']);
  gulp.watch('frontend/src/index.html', ['index']);
  gulp.watch('frontend/src/admin.html', ['admin']);
  gulp.watch('frontend/build/**/*.{html,css,js,jpg,gif,png}', notifyLivereload);
});

gulp.task('start', function() {
  startExpress();
});

gulp.task('default', function(cb) {
  runSequence(
    ['build-dev'],
    ['start-dev'],
    cb);
});
<|endoftext|>


<commit_before>'use strict';

var PORT = process.env.PORT || 3000;

var _ = require('lodash');
var babelify = require('babelify');
var brfs = require('brfs');
var browserify = require('browserify');
var browserifyShim = require('browserify-shim');
var browserSync = require('browser-sync');
var del = require('del');
var mainBowerFiles = require('main-bower-files');
var runSequence = require('run-sequence');
var source = require('vinyl-source-stream');
var watchify = require('watchify');

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

function onError(error) {
  util.log('Error: ' + error.message);
  /*jshint validthis:true*/
  this.emit('end');
}

gulp.task('browser-sync', function() {
  return browserSync({
    browser: [],
    port: PORT,
    server: {
      baseDir: './dist'
    }
  });
});

gulp.task('js', function() {
  var bundler = watchify(browserify('./app/js/main.js',
    _.assign({
      debug: true,
    }, watchify.args)));

  bundler
    .transform(babelify)
    .transform(brfs)
    .transform(browserifyShim);

  function rebundle() {
    return bundler.bundle()
      .on('error', onError)
      .pipe(source('bundle.js'))
      .pipe(gulp.dest('dist'))
      .pipe(browserSync.reload({stream: true, once: true}));
  }

  bundler
    .on('log', util.log)
    .on('update', rebundle);

  return rebundle();
});

gulp.task('html', function() {
  return gulp.src('./app/index.html')
    .pipe(gulp.dest('dist'));
});

gulp.task('bower', function() {
  return gulp.src(mainBowerFiles())
    .pipe(gulp.dest('dist'));
});

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

gulp.task('default', ['clean'], function(cb) {
  return runSequence(
    ['html', 'bower', 'js'],
    'browser-sync',
    cb
  );
});
<commit_msg>Simplify gulpfile configuration.<commit_after>'use strict';

var PORT = process.env.PORT || 3000;

var SOURCE_DIR = './app';
var BUILD_DIR = 'dist';

var _ = require('lodash');
var babelify = require('babelify');
var brfs = require('brfs');
var browserify = require('browserify');
var browserifyShim = require('browserify-shim');
var browserSync = require('browser-sync');
var del = require('del');
var mainBowerFiles = require('main-bower-files');
var runSequence = require('run-sequence');
var source = require('vinyl-source-stream');
var watchify = require('watchify');

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

function onError(error) {
  util.log(error.message);
  /*jshint validthis:true*/
  this.emit('end');
}

gulp.task('browser-sync', function() {
  return browserSync({
    browser: [],
    port: PORT,
    server: {
      baseDir: './' + BUILD_DIR
    }
  });
});

gulp.task('js', function() {
  var bundler = watchify(browserify(SOURCE_DIR + '/js/main.js',
    _.assign({
      debug: true,
    }, watchify.args)));

  bundler
    .transform(babelify)
    .transform(brfs)
    .transform(browserifyShim);

  function rebundle() {
    return bundler.bundle()
      .on('error', onError)
      .pipe(source('bundle.js'))
      .pipe(gulp.dest(BUILD_DIR))
      .pipe(browserSync.reload({stream: true, once: true}));
  }

  bundler
    .on('log', util.log)
    .on('update', rebundle);

  return rebundle();
});

gulp.task('html', function() {
  return gulp.src(SOURCE_DIR + '/index.html')
    .pipe(gulp.dest(BUILD_DIR));
});

gulp.task('bower', function() {
  return gulp.src(mainBowerFiles())
    .pipe(gulp.dest(BUILD_DIR));
});

gulp.task('clean', del.bind(null, [BUILD_DIR]));

gulp.task('default', ['clean'], function(cb) {
  return runSequence(
    ['html', 'bower', 'js'],
    'browser-sync',
    cb
  );
});
<|endoftext|>


<commit_before>var gulp = require("gulp");
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace'); //Rewrite occurences of filenames which have been renamed by gulp-rev
var replace = require('gulp-replace') //string replace

var md5Value = function () {
            return Array.apply(0, Array(15)).map(function() {
                return (function(charset){
                    return charset.charAt(Math.floor(Math.random() * charset.length));
                }('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'));
            }).join('');
        }

var config = {
    source_path: "./manage_90/",
    source_advertiser_path: "./manage_90/Advertiser/",
    cdn_server: "http://cdn.yeahmobi.com/",
    dest_path: "./dist/",
    temp_path: "./temp/",
    fils_ext: "{js,css,html,png,jpg,gif,ico}",
    hash_value: md5Value()
}

gulp.task("copy_upload", function() {
    return gulp.src([config.source_path + "upload/**"])
        .pipe(gulp.dest(config.dest_path + "/upload"))
})

gulp.task("copy_htaccess", function() {
    return gulp.src([config.source_path + ".htaccess"])
        .pipe(gulp.dest(config.dest_path))
})

gulp.task("copy_other_files", function() {
    return gulp.src([config.source_path + "**/*.*",
            '!' + config.source_path + "**/*." + config.fils_ext
        ])
        .pipe(gulp.dest(config.dest_path))
})

gulp.task("mainjs", function() {
    gulp.src(config.source_path + "/static/script/main.js")
        .pipe(replace(/{assert_hash}/i, config.hash_value))
        .pipe(replace(/{cdn_server}/i, config.cdn_server))
        .pipe(gulp.dest(config.temp_path + "/static/script/"))
})

gulp.task("loginHtml", function() {
    gulp.src(config.source_path + "/login.html")
        .pipe(replace(/{assert_hash}/i, config.hash_value))
        .pipe(replace(/{cdn_server}/i, config.cdn_server))
        .pipe(gulp.dest(config.dest_path))
})

gulp.task("adv", function() {
    gulp.src([
            config.source_advertiser_path + "**/*." + config.fils_ext,
            '!' + config.source_advertiser_path + "*.html",
            //'!'+ config.source_path + "/Advertiser/sign-up.html"
        ])
        .pipe(rev({hash:config.hash_value}))
        .pipe(gulp.dest(config.dest_path + "/Advertiser"))
        .pipe(rev.manifest())
        .pipe(gulp.dest(config.dest_path + "/Advertiser"))
        .on("end", function() {

            var manifest = gulp.src(config.dest_path + "/Advertiser/rev-manifest.json")
            gulp.src([config.source_advertiser_path + "*.html"])
                .pipe(revReplace({
                    manifest: manifest,
                    prefix: config.cdn_server
                }))
                .pipe(gulp.dest(config.dest_path + "/Advertiser"))
        })
})

gulp.task('default', ["copy_other_files", "loginHtml", "mainjs", "copy_upload", "copy_htaccess", "adv"], function() {
    return gulp.src([
            config.source_path + "**/*." + config.fils_ext,
            '!' + config.source_path + "*.html",
            '!' + config.source_advertiser_path + "*.html",
            //'!'+ config.source_path + "/Advertiser/sign-up.html"
        ])
        .pipe(rev({hash:config.hash_value}))
        .pipe(gulp.dest(config.dest_path))
        .pipe(rev.manifest())
        .pipe(gulp.dest(config.dest_path))
        .on("end", function() {

            gulp.src([config.temp_path + "/static/script/*.*"])
                .pipe(rev({hash:config.hash_value}))
                .pipe(gulp.dest(config.dest_path + "/static/script/"))

            gulp.src(config.dest_path + "**/*.css")
                .pipe(replace(/.(png|jpg|gif)/g, "-" + config.hash_value + ".$1"))
                .pipe(gulp.dest(config.dest_path))

            gulp.src(config.dest_path + "**/*.html")
                .pipe(replace(/static\/(.+).(png|jpg|gif)/g, config.cdn_server + "static/$1"+"-" + config.hash_value + ".$2"))
                .pipe(gulp.dest(config.dest_path))

            var manifest = gulp.src(config.dest_path + "/rev-manifest.json")
            gulp.src([config.source_path + "/*.html",
                    '!' + config.source_path + "/login.html",
                    config.dest_path + "/login.html"
                ])
                .pipe(revReplace({
                    manifest: manifest,
                    prefix: config.cdn_server
                }))
                .pipe(gulp.dest(config.dest_path))
                .on("end", function() {
                    gulp.src([config.dest_path + "/static/**/*.html"])
                        .pipe(revReplace({
                            manifest: manifest,
                            prefix: config.cdn_server
                        }))
                        .pipe(gulp.dest(config.dest_path + "/static"))

                })

        })
})
<commit_msg>fix advertiser<commit_after>var gulp = require("gulp");
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace'); //Rewrite occurences of filenames which have been renamed by gulp-rev
var replace = require('gulp-replace') //string replace

var md5Value = function() {
    return Array.apply(0, Array(15)).map(function() {
        return (function(charset) {
            return charset.charAt(Math.floor(Math.random() * charset.length));
        }('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'));
    }).join('');
}

var config = {
    source_path: "./manage_90/",
    source_advertiser_path: "./manage_90/Advertiser/",
    cdn_server: "http://cdn.yeahmobi.com/",
    dest_path: "./dist/",
    temp_path: "./temp/",
    fils_ext: "{js,css,html,png,jpg,gif,ico}",
    hash_value: md5Value()
}

gulp.task("copy_upload", function() {
    return gulp.src([config.source_path + "upload/**"])
        .pipe(gulp.dest(config.dest_path + "/upload"))
})

gulp.task("copy_htaccess", function() {
    return gulp.src([config.source_path + ".htaccess"])
        .pipe(gulp.dest(config.dest_path))
})

gulp.task("copy_other_files", function() {
    return gulp.src([config.source_path + "**/*.*",
            '!' + config.source_path + "**/*." + config.fils_ext
        ])
        .pipe(gulp.dest(config.dest_path))
})

gulp.task("mainjs", function() {
    gulp.src(config.source_path + "/static/script/main.js")
        .pipe(replace(/{assert_hash}/i, config.hash_value))
        .pipe(replace(/{cdn_server}/i, config.cdn_server))
        .pipe(gulp.dest(config.temp_path + "/static/script/"))
})

gulp.task("loginHtml", function() {
    gulp.src(config.source_path + "/login.html")
        .pipe(replace(/{assert_hash}/i, config.hash_value))
        .pipe(replace(/{cdn_server}/i, config.cdn_server))
        .pipe(gulp.dest(config.dest_path))
})

gulp.task("adv", function() {
    gulp.src([
            config.source_advertiser_path + "**/*." + config.fils_ext,
            '!' + config.source_advertiser_path + "*.html",
            //'!'+ config.source_path + "/Advertiser/sign-up.html"
        ])
        .pipe(rev({
            hash: config.hash_value
        }))
        .pipe(gulp.dest(config.dest_path + "/Advertiser"))
        .pipe(rev.manifest())
        .pipe(gulp.dest(config.dest_path + "/Advertiser"))
        .on("end", function() {

            var manifest = gulp.src(config.dest_path + "/Advertiser/rev-manifest.json")
            gulp.src([config.source_advertiser_path + "*.html"])
                .pipe(revReplace({
                    manifest: manifest,
                    prefix: config.cdn_server + 'Advertiser/'
                }))
                .pipe(replace(/href=('|")\.\.\/(.+).(css)/g, 'href="' + config.cdn_server + "$2" + "-" + config.hash_value + ".css"))
                .pipe(replace(/src=('|")\.\.\/(.+).(js|png|jpg|gif)/g, 'src="' + config.cdn_server + "$2" + "-" + config.hash_value + ".$3"))
                .pipe(gulp.dest(config.dest_path + "/Advertiser"))
        })
})

gulp.task('default', ["copy_other_files", "loginHtml", "mainjs", "copy_upload", "copy_htaccess", "adv"], function() {
    return gulp.src([
            config.source_path + "**/*." + config.fils_ext,
            '!' + config.source_path + "*.html",
            '!' + config.source_advertiser_path + "*.html",
            //'!'+ config.source_path + "/Advertiser/sign-up.html"
        ])
        .pipe(rev({
            hash: config.hash_value
        }))
        .pipe(gulp.dest(config.dest_path))
        .pipe(rev.manifest())
        .pipe(gulp.dest(config.dest_path))
        .on("end", function() {

            gulp.src([config.temp_path + "/static/script/*.*"])
                .pipe(rev({
                    hash: config.hash_value
                }))
                .pipe(gulp.dest(config.dest_path + "/static/script/"))

            gulp.src(config.dest_path + "**/*.css")
                .pipe(replace(/.(png|jpg|gif)/g, "-" + config.hash_value + ".$1"))
                .pipe(gulp.dest(config.dest_path))

            gulp.src([config.dest_path + "**/*.html",
                    '!' + config.dest_path + "Advertiser/*.html"
                ])
                .pipe(replace(/static\/(.+).(png|jpg|gif)/g, config.cdn_server + "static/$1" + "-" + config.hash_value + ".$2"))
                .pipe(gulp.dest(config.dest_path))

            var manifest = gulp.src(config.dest_path + "/rev-manifest.json")
            gulp.src([config.source_path + "/*.html",
                    '!' + config.source_path + "/login.html",
                    config.dest_path + "/login.html"
                ])
                .pipe(revReplace({
                    manifest: manifest,
                    prefix: config.cdn_server
                }))
                .pipe(replace(/widget-script=('|")(.+).(js)/g, 'widget-script="$2-' + config.hash_value + '.$3'))
                .pipe(gulp.dest(config.dest_path))
                .on("end", function() {
                    gulp.src([config.dest_path + "/static/**/*.html"])
                        .pipe(revReplace({
                            manifest: manifest,
                            prefix: config.cdn_server
                        }))
                        .pipe(gulp.dest(config.dest_path + "/static"))

                })

        })
})
<|endoftext|>


<commit_before>var gulp = require('gulp');
var babel = require('gulp-babel');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var watch = require('gulp-watch');

gulp.task('default', function () {
    return gulp.src('src/jquery.porthole.es6')
        .pipe(babel({
            modules : 'umd'
        }))
        .pipe(gulp.dest('dist'));
});

gulp.task('watch', function () {
    watch('src/jquery.porthole.es6', function() {
        return gulp.src('src/jquery.porthole.es6')
            .pipe(babel({
                modules : 'umd'
            }))
            .pipe(gulp.dest('dist'));
    });
});

gulp.task('compress', function () {
    return gulp.src('src/jquery.porthole.es6')
        .pipe(babel({
            modules : 'umd'
        }))
        .pipe(uglify())
        .pipe(rename('jquery.porthole.min.js'))
        .pipe(gulp.dest('dist'));
});
<commit_msg>gulp config fix<commit_after>var gulp = require('gulp');
var babel = require('gulp-babel');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');

var babelConf = {
    modules : 'umd',
    optional : 'es7.comprehensions'
}

var srcDir = 'src'
var distDir = 'dist'

var baseFile = 'jquery.porthole'
var srcFile = baseFile+'.es6'
var distFile = baseFile+'.js'
var minFile = baseFile+'.min.js'

gulp.task('compile', function () {
    gulp.src(srcDir+'/'+srcFile)
        .pipe(babel(babelConf))
        .pipe(gulp.dest(distDir));
});

gulp.task('compress', function () {
    gulp.src(distDir+'/'+distFile)
        .pipe(uglify())
        .pipe(rename(minFile))
        .pipe(gulp.dest(distDir));
});

gulp.task('default', ['compile', 'compress']);

gulp.task('watch', function() {
    gulp.watch(srcDir+'/**', ['compile']);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var eslint = require('gulp-eslint');
var runSequence = require('run-sequence');
var concat = require('gulp-concat');
var benchmark = require('gulp-bench');
var gulpShell = require('gulp-shell');

// Registers build tasks
require('./build/gulp-clean');
require('./build/gulp-build');
require('./build/gulp-test');
require('./build/gulp-perf');

var srcDir = 'lib';

gulp.task('lint', function() {
    return gulp.src(srcDir + '/**/*.js').
        pipe(eslint({
            globals: {
                'require': false,
                'module': false
            },
            reset: true, // dz: remove me after linting is finished, else i can't do one at the time
            useEslintrc: true,
        })).
        pipe(eslint.format()).
        pipe(eslint.failOnError()); // dz: change back after finishing to failAfterError
});

gulp.task('doc', ['clean.doc', 'doc-d']);

gulp.task('doc-d', gulpShell.task([
    './node_modules/.bin/jsdoc lib -r -d doc -c ./build/jsdoc.json --verbose'
]));

// Run in serial to fail build if lint fails.
gulp.task('default', ['build-with-lint', 'lint']);
<commit_msg>Remove trailing comma<commit_after>var gulp = require('gulp');
var eslint = require('gulp-eslint');
var runSequence = require('run-sequence');
var concat = require('gulp-concat');
var benchmark = require('gulp-bench');
var gulpShell = require('gulp-shell');

// Registers build tasks
require('./build/gulp-clean');
require('./build/gulp-build');
require('./build/gulp-test');
require('./build/gulp-perf');

var srcDir = 'lib';

gulp.task('lint', function() {
    return gulp.src(srcDir + '/**/*.js').
        pipe(eslint({
            globals: {
                'require': false,
                'module': false
            },
            reset: true, // dz: remove me after linting is finished, else i can't do one at the time
            useEslintrc: true
        })).
        pipe(eslint.format()).
        pipe(eslint.failOnError()); // dz: change back after finishing to failAfterError
});

gulp.task('doc', ['clean.doc', 'doc-d']);

gulp.task('doc-d', gulpShell.task([
    './node_modules/.bin/jsdoc lib -r -d doc -c ./build/jsdoc.json --verbose'
]));

// Run in serial to fail build if lint fails.
gulp.task('default', ['build-with-lint', 'lint']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var browserSync = require('browser-sync');
var runSequence = require('run-sequence');
var ts = require('gulp-typescript');
var merge = require('merge2');
var dtsGenerator = require('dts-generator')

gulp.task('dts-gen', function() {
    dtsGenerator.generate({
        name: 'logging',
        baseDir: '/c/a/aurelia-ts-port/aurelia-ts/logging',
        files: [ 'index.d.ts' ],
          out: 'logging.d.ts'
    });
});

gulp.task('build-ts', function () {
    var tsResult = gulp.src([
        './views/*.ts',
        './typings/**/*.d.ts',
        './*.ts'
        ],
        {base: "."})
    .pipe(ts({
         typescript: require('typescript'),
         declarationFiles: false,
         noExternalResolve: true,
         target: "es5",
         module: "amd",
         emitDecoratorMetadata: true
    }));

    return merge([
        tsResult.dts.pipe(gulp.dest('.')),
        tsResult.js.pipe(gulp.dest('.'))
    ]);
});

var path = {
  sourceTS: "views/**/*.ts",
  html: "views/**/*.html",
  style: "styles/**/*.css"
}

gulp.task('serve', ['build-ts'], function(done) {
  browserSync({
    open: false,
    port: 9000,
    server: {
      baseDir: ['.'],
      middleware: function (req, res, next) {
        res.setHeader('Access-Control-Allow-Origin', '*');
        next();
      }
    }
  }, done);
});

function reportChange(event){
  console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
}

gulp.task('watch', ['serve'], function() {
  gulp.watch(path.sourceTS, ['build-ts', browserSync.reload]).on('change', reportChange);
  gulp.watch(path.html, [browserSync.reload]).on('change', reportChange);
  gulp.watch(path.style, [browserSync.reload]).on('change', reportChange);
});
<commit_msg>added build data structure to gulpfile.js<commit_after>var gulp = require('gulp');
var browserSync = require('browser-sync');
var runSequence = require('run-sequence');
var ts = require('gulp-typescript');
var merge = require('merge2');
var dtsGenerator = require('dts-generator')

var buildTargets = {
  rings: [
    { name: 'ring-0', repos: [
      { name: 'event-aggregator' },
      { name: 'history' },
      { name: 'html-template-element' },
      { name: 'logging' },
      { name: 'logging-console' },
      { name: 'path' },
      { name: 'metadata' },
      { name: 'skeleton-plugin' },
      { name: 'task-queue' },
      { name: 'route-recognizer'}
      ]},
    { name: 'ring-1', repos: [
      { name: 'dependency-injection' },
      { name: 'history-browser' },
      { name: 'loader' },
      { name: 'http-client' }
    ]},
    { name: 'ring-2', repos: [
      { name: 'binding' },
      { name: 'router' },
      { name: 'loader-default' }
    ]},
    { name: 'ring-3', repos: [
      { name: 'templating' }
    ]},
    { name: 'ring-4', repos: [
      { name: 'framework' },
      { name: 'animator-css' },
      { name: 'templating-binding' },
      { name: 'templating-resources' },
      { name: 'templating-router' }
    ]},
    { name: 'ring-5', repos: [
      { name: 'app-contacts' },
      { name: 'bootstrapper' },
      { name: 'skeleton-navigation' }
    ]}
  ]
}

gulp.task('dts-gen', function() {
  debugger;
    dtsGenerator.generate({
        name: 'logging',
        baseDir: '/c/a/aurelia-ts-port/aurelia-ts/logging',
        files: [ 'index.d.ts' ],
          out: 'logging.d.ts'
    });
});

gulp.task('build-ts', function () {
    var tsResult = gulp.src([
        './views/*.ts',
        './typings/**/*.d.ts',
        './*.ts'
        ],
        {base: "."})
    .pipe(ts({
         typescript: require('typescript'),
         declarationFiles: false,
         noExternalResolve: true,
         target: "es5",
         module: "amd",
         emitDecoratorMetadata: true
    }));

    return merge([
        tsResult.dts.pipe(gulp.dest('.')),
        tsResult.js.pipe(gulp.dest('.'))
    ]);
});

var path = {
  sourceTS: "views/**/*.ts",
  html: "views/**/*.html",
  style: "styles/**/*.css"
}

gulp.task('serve', ['build-ts'], function(done) {
  browserSync({
    open: false,
    port: 9000,
    server: {
      baseDir: ['.'],
      middleware: function (req, res, next) {
        res.setHeader('Access-Control-Allow-Origin', '*');
        next();
      }
    }
  }, done);
});

function reportChange(event){
  console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
}

gulp.task('watch', ['serve'], function() {
  gulp.watch(path.sourceTS, ['build-ts', browserSync.reload]).on('change', reportChange);
  gulp.watch(path.html, [browserSync.reload]).on('change', reportChange);
  gulp.watch(path.style, [browserSync.reload]).on('change', reportChange);
});
<|endoftext|>


<commit_before>'use strict';
require('./src/common/mochaHelper');
var gulp = require('gulp'),
		ghPages = require('gulp-gh-pages'),
		jshint = require('gulp-jshint'),
		webpack = require('gulp-webpack'),
		gp_rename = require('gulp-rename'),
		gp_uglify = require('gulp-uglify'),
		cleanCSS = require('gulp-clean-css'),
		gp_watch = require('gulp-watch'),
		concat = require('gulp-concat-util'),
		concatCss = require('gulp-concat-css'),
		del = require('del'),
		vinyl_paths = require('vinyl-paths'),
		scanner = require('i18next-scanner'),
		hash = require('sha1'),
		mustache = require('gulp-mustache-plus'),
		rev = require('gulp-rev'),
		fs = require('fs'),
		connect = require('gulp-connect'),
		open = require('gulp-open'),
		through = require('through2'),
		path = require('path'),
		mock = require('binary-mock-websocket'),
		insert = require('gulp-insert'),
		mocha = require('gulp-mocha');

var options = {
	lngs: ['zh_tw', 'de', 'id', 'zh_cn', 'it', 'vi', 'ar', 'pl', 'ru', 'pt', 'es', 'fr', 'en'], // supported languages
	resource: {
		loadPath: 'src/common/translations/{{lng}}.js',
		savePath: 'src/common/translations/{{lng}}.js',
		jsonIndent: 2
	}
};

var customTransform = function _transform(file, enc, done) {
	var parser = this.parser;
	var content = fs.readFileSync(file.path, enc);

	parser.parseFuncFromString(content, {
		list: ['translator.translateText'],
	}, function (key) {
		var value = key;
		var defaultKey = hash(value);
		parser.set(defaultKey, value);
	});

	parser.parseAttrFromString(content, {
		list: ['data-i18n-text', 'i18n-text'],
	}, function (key) {
		var value = key;
		var defaultKey = hash(value);
		parser.set(defaultKey, value);
	});

	done();
};

var manifest = {};

var parseFilenameWithoutVersion = function parseFilenameWithoutVersion(chunk) {
	var oldFile = path.parse(chunk.revOrigPath);
	var filename = oldFile.base.slice(0, oldFile.base.indexOf('.'));
	var ext = oldFile.base.slice(oldFile.base.indexOf('.'));
	var newFileName = filename + '-' + chunk.revHash + ext;
	return {
		old: oldFile.base,
		new: newFileName
	};
};

var parseFilenameWithVersion = function parseFilenameWithVersion(file) {
	var newFile = path.parse(file.path);
	var ext = newFile.ext;
	var filename = newFile.base.slice(0, newFile.base.indexOf('-'));
	return {
		old: filename + ext,
		new: newFile.base
	};
};

var addToManifest = function addToManifest(chunk, enc, cb) {
	var map;
	if ( !chunk.hasOwnProperty('revHash') ) {
		map = parseFilenameWithVersion(chunk);
	} else {
		map = parseFilenameWithoutVersion(chunk);
	}
	manifest[map.old] = map.new;
	return cb(null, chunk);
};

gulp.task('clean-css', function() {
	return gulp.src('./www/css/*-*.css')
		.pipe(vinyl_paths(del));
});

gulp.task('static-css', ['clean-css'], function() {
	return gulp.src('static/css/*')
		.pipe(rev())
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('./www/css'));
});

gulp.task('static', ['static-css'], function() {
	return gulp.src(['static/**', '!static/css/*'])
		.pipe(gulp.dest('./www'));
});

gulp.task('mocha', ['i18n'], function() {
    return gulp.src(['./src/**/__tests__/*.js'])
			.pipe(mocha({
				reporter: 'nyan'
			}));
});

gulp.task('lint', function() {
	return gulp.src(['./src/**/*.js', '!./src/**/*.min.js', '!./src/common/translations/*.js'])
		.pipe(jshint())
		.pipe(jshint.reporter('default'))
		.pipe(jshint.reporter('fail'));
});

gulp.task('test', ['mocha', 'lint'], function() {
	return gulp.src(['./src/**/*.js', '!./src/**/*.min.js', '!./src/common/translations/*.js'])
		.pipe(jshint())
		.pipe(jshint.reporter('default'))
		.pipe(jshint.reporter('fail'));
});

gulp.task('i18n-xml', ['static'], function () {
	return gulp.src('www/xml/*.xml')
		.pipe(scanner(options, customTransform))
		.pipe(gulp.dest('./'));
});

gulp.task('i18n-html', ['i18n-xml'], function () {
	return gulp.src('templates/*.mustache')
		.pipe(scanner(options, customTransform))
		.pipe(gulp.dest('./'));
});

gulp.task('i18n-js', ['i18n-html'], function () {
	return gulp.src(['src/**/*.js', '!src/common/translations/*.js'])
		.pipe(scanner(options, customTransform))
		.pipe(gulp.dest('./'));
});

gulp.task('i18n', ['i18n-js'], function () {
	return gulp.src('./src/common/translations/*.js')
		.pipe(insert.wrap('module.exports = ', ';'))
		.pipe(gulp.dest('./src/common/translations'));
});

gulp.task('blockly-msg', ['static'], function(){
	return gulp.src('node_modules/blockly/msg/**')
		.pipe(gulp.dest('www/js/blockly/msg'));
});

gulp.task('blockly-media', ['static'], function(){
	return gulp.src('node_modules/blockly/media/**')
		.pipe(gulp.dest('www/js/blockly/media'));
});

gulp.task('blockly-js', ['static'], function(){
	return gulp.src([
		'node_modules/blockly/blockly_compressed.js',
		'node_modules/blockly/blocks_compressed.js',
		'node_modules/blockly/javascript_compressed.js'
		])
		.pipe(concat('blockly.js'))
		.pipe(gulp.dest('www/js/blockly'));
});

gulp.task('blockly', ['blockly-msg', 'blockly-media', 'blockly-js'], function () {
});

gulp.task('bundle', ['blockly'], function () {
	return gulp.src([
		'./node_modules/jquery/dist/jquery.min.js',
		'./node_modules/underscore/underscore-min.js',
		'./node_modules/backbone/backbone-min.js',
		'./node_modules/tourist/tourist.min.js',
		'./node_modules/notifyjs-browser/dist/notify.js'
		])
		.pipe(concat('bundle.js'))
		.pipe(gulp.dest('www/js/'));
});

gulp.task('clean-webpack', function() {
	return gulp.src(['./www/js/*-*.{js,map}'])
		.pipe(vinyl_paths(del));
});

gulp.task('webpack', ['i18n', 'clean-webpack', 'test', 'bundle'], function(){
	return webpack(require('./webpack.config.js'))
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('www/js'));
});

gulp.task('build-bot-min', ['build'], function(){
	return gulp.src(['www/js/bot-*.js'])
		.pipe(gp_rename('bot.min.js'))
		.pipe(gp_uglify())
		.pipe(rev())
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('www/js'));
});

gulp.task('build-index-min', ['build'], function(){
	return gulp.src(['www/js/index-*.js'])
		.pipe(gp_rename('index.min.js'))
		.pipe(gp_uglify())
		.pipe(rev())
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('www/js'));
});

gulp.task('pack-css', ['static'], function(){
	return gulp.src(['node_modules/{bootstrap/dist/css/bootstrap.min,tourist/tourist}.css'])
		.pipe(concatCss('bundle.css'))
		.pipe(rev())
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('www/css'));
});

gulp.task('pack-css-min', ['build'], function(){
	return gulp.src('www/css/bundle-*.css')
		.pipe(gp_rename('bundle.min.css'))
		.pipe(cleanCSS())
		.pipe(rev())
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('www/css'));
});

gulp.task('mustache-dev', ['static', 'webpack', 'pack-css'], function(){
	return gulp.src('templates/*.mustache')
		.pipe(mustache({},{},{
			index: '<script src="js/' + manifest['index.js'] + '"></script>',
			bot: '<script src="js/' + manifest['bot.js'] + '"></script>',
			bundle_css: '<link href="css/' + manifest['bundle.css'] + '" rel="stylesheet" />',
			main_css: '<link href="css/' + manifest['main.css'] + '" rel="stylesheet" />',
			bot_css: '<link href="css/' + manifest['bot.css'] + '" rel="stylesheet" />',
            fontello_css: '<link href="css/' + manifest['fontello.css'] + '" rel="stylesheet" />',
			head: 'templates/partials/head.mustache',
			security: 'templates/partials/security.mustache',
			language: 'templates/partials/language.mustache',
		}))
		.pipe(gulp.dest('www'));
});

gulp.task('mustache-min', ['static', 'pack-css-min', 'build-bot-min', 'build-index-min'], function(){
	return gulp.src('templates/*.mustache')
		.pipe(mustache({},{},{
			index: '<script src="js/' + manifest['index.min.js'] + '"></script>',
			bot: '<script src="js/' + manifest['bot.min.js'] + '"></script>',
			bundle_css: '<link href="css/' + manifest['bundle.min.css'] + '" rel="stylesheet" />',
			main_css: '<link href="css/' + manifest['main.css'] + '" rel="stylesheet" />',
			bot_css: '<link href="css/' + manifest['bot.css'] + '" rel="stylesheet" />',
			fontello_css: '<link href="css/' + manifest['fontello.css'] + '" rel="stylesheet" />',
			head: 'templates/partials/head.mustache',
			security: 'templates/partials/security.mustache',
			language: 'templates/partials/language.mustache',
		}))
		.pipe(gulp.dest('www'));
});

gulp.task('connect', function () {
	connect.server({
		root: 'www',
		port: 8080,
		livereload: true
	});
});

gulp.task('open', function(){
	gulp.src('www/index.html')
		.pipe(open({uri: 'http://localhost:8080/'}));
});

gulp.task('build', ['pack-css', 'webpack', 'mustache-dev'], function () {
	gulp.src('www/**')
		.pipe(connect.reload());
});

gulp.task('build-min', ['build-bot-min', 'build-index-min', 'pack-css-min', 'mustache-min'], function () {
	gulp.src('www/**')
		.pipe(connect.reload());
});

gulp.task('deploy', ['build-min'], function () {
	return gulp.src(['404.md', 'LICENSE', 'README.md', 'CNAME', './www/**'])
		.pipe(ghPages());
});

gulp.task('serve', ['open', 'connect'], function () {
	gp_watch(['www/*.html'], {debounceDelay: 1000})
		.pipe(connect.reload());
});

gulp.task('test-deploy', ['build-min', 'serve'], function () {
});

gulp.task('watch', ['build', 'serve'], function () {
	gp_watch(['static/**', 'src/**/*.js', 'templates/**/*.mustache', '!./src/common/translations/*.js'], {debounceDelay: 15000}, function(){
		gulp.run(['build']);
	});
});

gulp.task('build-mock', function() {
	return gulp.src('./src/common/calls.js', {read: false})
		.pipe(mock())
		.pipe(gulp.dest('./src/common/mock'));
});

gulp.task('default', ['watch']);
<commit_msg>Slight change in gulpfile, puting the deploy tasks near<commit_after>'use strict';
require('./src/common/mochaHelper');
var gulp = require('gulp'),
		ghPages = require('gulp-gh-pages'),
		jshint = require('gulp-jshint'),
		webpack = require('gulp-webpack'),
		gp_rename = require('gulp-rename'),
		gp_uglify = require('gulp-uglify'),
		cleanCSS = require('gulp-clean-css'),
		gp_watch = require('gulp-watch'),
		concat = require('gulp-concat-util'),
		concatCss = require('gulp-concat-css'),
		del = require('del'),
		vinyl_paths = require('vinyl-paths'),
		scanner = require('i18next-scanner'),
		hash = require('sha1'),
		mustache = require('gulp-mustache-plus'),
		rev = require('gulp-rev'),
		fs = require('fs'),
		connect = require('gulp-connect'),
		open = require('gulp-open'),
		through = require('through2'),
		path = require('path'),
		mock = require('binary-mock-websocket'),
		insert = require('gulp-insert'),
		mocha = require('gulp-mocha');

var options = {
	lngs: ['zh_tw', 'de', 'id', 'zh_cn', 'it', 'vi', 'ar', 'pl', 'ru', 'pt', 'es', 'fr', 'en'], // supported languages
	resource: {
		loadPath: 'src/common/translations/{{lng}}.js',
		savePath: 'src/common/translations/{{lng}}.js',
		jsonIndent: 2
	}
};

var customTransform = function _transform(file, enc, done) {
	var parser = this.parser;
	var content = fs.readFileSync(file.path, enc);

	parser.parseFuncFromString(content, {
		list: ['translator.translateText'],
	}, function (key) {
		var value = key;
		var defaultKey = hash(value);
		parser.set(defaultKey, value);
	});

	parser.parseAttrFromString(content, {
		list: ['data-i18n-text', 'i18n-text'],
	}, function (key) {
		var value = key;
		var defaultKey = hash(value);
		parser.set(defaultKey, value);
	});

	done();
};

var manifest = {};

var parseFilenameWithoutVersion = function parseFilenameWithoutVersion(chunk) {
	var oldFile = path.parse(chunk.revOrigPath);
	var filename = oldFile.base.slice(0, oldFile.base.indexOf('.'));
	var ext = oldFile.base.slice(oldFile.base.indexOf('.'));
	var newFileName = filename + '-' + chunk.revHash + ext;
	return {
		old: oldFile.base,
		new: newFileName
	};
};

var parseFilenameWithVersion = function parseFilenameWithVersion(file) {
	var newFile = path.parse(file.path);
	var ext = newFile.ext;
	var filename = newFile.base.slice(0, newFile.base.indexOf('-'));
	return {
		old: filename + ext,
		new: newFile.base
	};
};

var addToManifest = function addToManifest(chunk, enc, cb) {
	var map;
	if ( !chunk.hasOwnProperty('revHash') ) {
		map = parseFilenameWithVersion(chunk);
	} else {
		map = parseFilenameWithoutVersion(chunk);
	}
	manifest[map.old] = map.new;
	return cb(null, chunk);
};

gulp.task('clean-css', function() {
	return gulp.src('./www/css/*-*.css')
		.pipe(vinyl_paths(del));
});

gulp.task('static-css', ['clean-css'], function() {
	return gulp.src('static/css/*')
		.pipe(rev())
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('./www/css'));
});

gulp.task('static', ['static-css'], function() {
	return gulp.src(['static/**', '!static/css/*'])
		.pipe(gulp.dest('./www'));
});

gulp.task('mocha', ['i18n'], function() {
    return gulp.src(['./src/**/__tests__/*.js'])
			.pipe(mocha({
				reporter: 'nyan'
			}));
});

gulp.task('lint', function() {
	return gulp.src(['./src/**/*.js', '!./src/**/*.min.js', '!./src/common/translations/*.js'])
		.pipe(jshint())
		.pipe(jshint.reporter('default'))
		.pipe(jshint.reporter('fail'));
});

gulp.task('test', ['mocha', 'lint'], function() {
	return gulp.src(['./src/**/*.js', '!./src/**/*.min.js', '!./src/common/translations/*.js'])
		.pipe(jshint())
		.pipe(jshint.reporter('default'))
		.pipe(jshint.reporter('fail'));
});

gulp.task('i18n-xml', ['static'], function () {
	return gulp.src('www/xml/*.xml')
		.pipe(scanner(options, customTransform))
		.pipe(gulp.dest('./'));
});

gulp.task('i18n-html', ['i18n-xml'], function () {
	return gulp.src('templates/*.mustache')
		.pipe(scanner(options, customTransform))
		.pipe(gulp.dest('./'));
});

gulp.task('i18n-js', ['i18n-html'], function () {
	return gulp.src(['src/**/*.js', '!src/common/translations/*.js'])
		.pipe(scanner(options, customTransform))
		.pipe(gulp.dest('./'));
});

gulp.task('i18n', ['i18n-js'], function () {
	return gulp.src('./src/common/translations/*.js')
		.pipe(insert.wrap('module.exports = ', ';'))
		.pipe(gulp.dest('./src/common/translations'));
});

gulp.task('blockly-msg', ['static'], function(){
	return gulp.src('node_modules/blockly/msg/**')
		.pipe(gulp.dest('www/js/blockly/msg'));
});

gulp.task('blockly-media', ['static'], function(){
	return gulp.src('node_modules/blockly/media/**')
		.pipe(gulp.dest('www/js/blockly/media'));
});

gulp.task('blockly-js', ['static'], function(){
	return gulp.src([
		'node_modules/blockly/blockly_compressed.js',
		'node_modules/blockly/blocks_compressed.js',
		'node_modules/blockly/javascript_compressed.js'
		])
		.pipe(concat('blockly.js'))
		.pipe(gulp.dest('www/js/blockly'));
});

gulp.task('blockly', ['blockly-msg', 'blockly-media', 'blockly-js'], function () {
});

gulp.task('bundle', ['blockly'], function () {
	return gulp.src([
		'./node_modules/jquery/dist/jquery.min.js',
		'./node_modules/underscore/underscore-min.js',
		'./node_modules/backbone/backbone-min.js',
		'./node_modules/tourist/tourist.min.js',
		'./node_modules/notifyjs-browser/dist/notify.js'
		])
		.pipe(concat('bundle.js'))
		.pipe(gulp.dest('www/js/'));
});

gulp.task('clean-webpack', function() {
	return gulp.src(['./www/js/*-*.{js,map}'])
		.pipe(vinyl_paths(del));
});

gulp.task('webpack', ['i18n', 'clean-webpack', 'test', 'bundle'], function(){
	return webpack(require('./webpack.config.js'))
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('www/js'));
});

gulp.task('build-bot-min', ['build'], function(){
	return gulp.src(['www/js/bot-*.js'])
		.pipe(gp_rename('bot.min.js'))
		.pipe(gp_uglify())
		.pipe(rev())
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('www/js'));
});

gulp.task('build-index-min', ['build'], function(){
	return gulp.src(['www/js/index-*.js'])
		.pipe(gp_rename('index.min.js'))
		.pipe(gp_uglify())
		.pipe(rev())
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('www/js'));
});

gulp.task('pack-css', ['static'], function(){
	return gulp.src(['node_modules/{bootstrap/dist/css/bootstrap.min,tourist/tourist}.css'])
		.pipe(concatCss('bundle.css'))
		.pipe(rev())
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('www/css'));
});

gulp.task('pack-css-min', ['build'], function(){
	return gulp.src('www/css/bundle-*.css')
		.pipe(gp_rename('bundle.min.css'))
		.pipe(cleanCSS())
		.pipe(rev())
		.pipe(through.obj(addToManifest))
		.pipe(gulp.dest('www/css'));
});

gulp.task('mustache-dev', ['static', 'webpack', 'pack-css'], function(){
	return gulp.src('templates/*.mustache')
		.pipe(mustache({},{},{
			index: '<script src="js/' + manifest['index.js'] + '"></script>',
			bot: '<script src="js/' + manifest['bot.js'] + '"></script>',
			bundle_css: '<link href="css/' + manifest['bundle.css'] + '" rel="stylesheet" />',
			main_css: '<link href="css/' + manifest['main.css'] + '" rel="stylesheet" />',
			bot_css: '<link href="css/' + manifest['bot.css'] + '" rel="stylesheet" />',
            fontello_css: '<link href="css/' + manifest['fontello.css'] + '" rel="stylesheet" />',
			head: 'templates/partials/head.mustache',
			security: 'templates/partials/security.mustache',
			language: 'templates/partials/language.mustache',
		}))
		.pipe(gulp.dest('www'));
});

gulp.task('mustache-min', ['static', 'pack-css-min', 'build-bot-min', 'build-index-min'], function(){
	return gulp.src('templates/*.mustache')
		.pipe(mustache({},{},{
			index: '<script src="js/' + manifest['index.min.js'] + '"></script>',
			bot: '<script src="js/' + manifest['bot.min.js'] + '"></script>',
			bundle_css: '<link href="css/' + manifest['bundle.min.css'] + '" rel="stylesheet" />',
			main_css: '<link href="css/' + manifest['main.css'] + '" rel="stylesheet" />',
			bot_css: '<link href="css/' + manifest['bot.css'] + '" rel="stylesheet" />',
			fontello_css: '<link href="css/' + manifest['fontello.css'] + '" rel="stylesheet" />',
			head: 'templates/partials/head.mustache',
			security: 'templates/partials/security.mustache',
			language: 'templates/partials/language.mustache',
		}))
		.pipe(gulp.dest('www'));
});

gulp.task('connect', function () {
	connect.server({
		root: 'www',
		port: 8080,
		livereload: true
	});
});

gulp.task('open', function(){
	gulp.src('www/index.html')
		.pipe(open({uri: 'http://localhost:8080/'}));
});

gulp.task('build', ['pack-css', 'webpack', 'mustache-dev'], function () {
	gulp.src('www/**')
		.pipe(connect.reload());
});

gulp.task('build-min', ['build-bot-min', 'build-index-min', 'pack-css-min', 'mustache-min'], function () {
	gulp.src('www/**')
		.pipe(connect.reload());
});

gulp.task('serve', ['open', 'connect'], function () {
	gp_watch(['www/*.html'], {debounceDelay: 1000})
		.pipe(connect.reload());
});

gulp.task('deploy', ['build-min'], function () {
	return gulp.src(['404.md', 'LICENSE', 'README.md', 'CNAME', './www/**'])
		.pipe(ghPages());
});

gulp.task('test-deploy', ['build-min', 'serve'], function () {
});

gulp.task('watch', ['build', 'serve'], function () {
	gp_watch(['static/**', 'src/**/*.js', 'templates/**/*.mustache', '!./src/common/translations/*.js'], {debounceDelay: 15000}, function(){
		gulp.run(['build']);
	});
});

gulp.task('build-mock', function() {
	return gulp.src('./src/common/calls.js', {read: false})
		.pipe(mock())
		.pipe(gulp.dest('./src/common/mock'));
});

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


<commit_before>'use strict';

var fs = require('fs');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var request = require('request');
var parseString = require('xml2js').parseString;

var isOnTravis = process.env.CIRCLECI === 'true';
var isOnTravisAndMaster = isOnTravis && process.env.CI_PULL_REQUEST === '' && process.env.CIRCLE_BRANCH === 'master';
var version;

parseString(fs.readFileSync('CellStore.dll.nuspec', 'utf-8'), { async: false }, function (err, result) {
    version = result.package.metadata[0].version[0];
});

gulp.task('swagger:clean', $.shell.task([
   'rm -rf build',
   'mkdir build'
]));

gulp.task('swagger:resolve', ['swagger:clean'], function(done){
    request({ url: 'http://28msec.github.io/cellstore-pro/swagger-aggregated.json' }, function(err, resp){
        fs.writeFileSync('build/swagger-aggregated.json', resp.body);
        done();
    });
});

gulp.task('swagger:install-codegen', ['swagger:resolve'], $.shell.task('cd build && curl -L -o swagger-codegen.zip https://github.com/28msec/swagger-codegen/archive/2149dc04d52811cbf89ac72ab17a57be6a6150ac.zip && unzip -q swagger-codegen.zip && cd swagger-codegen-2149dc04d52811cbf89ac72ab17a57be6a6150ac && mvn package && cp modules/swagger-codegen-cli/target/swagger-codegen-cli.jar ..'));

gulp.task('swagger:generate-csharp', ['swagger:install-codegen'], $.shell.task([
    'cp codegen-options.json build',
    'cd build && java -jar swagger-codegen-cli.jar generate -i swagger-aggregated.json -l csharp -c codegen-options.json  -o .'
]));

gulp.task('swagger:csharp', ['swagger:generate-csharp'], $.shell.task([
    'cd build && mcs -sdk:4.5 -r:bin/Newtonsoft.Json.dll,bin/RestSharp.dll,System.Runtime.Serialization.dll -target:library -out:bin/CellStore.dll -recurse:src/*.cs -doc:bin/CellStore.xml -platform:anycpu'
]));

gulp.task('swagger:test', $.shell.task([
    'mcs -sdk:4.5 -r:build/bin/Newtonsoft.Json.dll,build/bin/RestSharp.dll,build/bin/CellStore.dll,System.Runtime.Serialization.dll samples/GetFacts/GetFacts/Program.cs',
    'cp build/bin/*.dll samples/GetFacts/GetFacts',
    'mono samples/GetFacts/GetFacts/Program.exe'
]));

gulp.task('swagger:pack', $.shell.task([
    'cp CellStore.dll.nuspec build',
    'cd build && wget https://nuget.org/nuget.exe',
    'cd build && mono nuget.exe pack CellStore.dll.nuspec'
]));

gulp.task('swagger:push', $.shell.task([
    'cd build && mono nuget.exe setApiKey ' + process.env.NUGET_API_KEY + ' | cat &> /dev/null',
    'cd build && mono nuget.exe push CellStore.NET.' + version + '.nupkg'
]));

gulp.task('swagger', function(done){
    if(isOnTravisAndMaster) {
        $.runSequence('swagger:csharp', 'swagger:test', 'swagger:pack', 'swagger:push', done);
    } else {
        $.runSequence('swagger:csharp', 'swagger:test', done);
    }
});

gulp.task('default', ['swagger']);
<commit_msg>:lipstick: copy generated files to artifacts<commit_after>'use strict';

var fs = require('fs');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var request = require('request');
var parseString = require('xml2js').parseString;

var isOnTravis = process.env.CIRCLECI === 'true';
var artifactsDir = process.env.CIRCLE_ARTIFACTS;
var isOnTravisAndMaster = isOnTravis && process.env.CI_PULL_REQUEST === '' && process.env.CIRCLE_BRANCH === 'master';
var version;

parseString(fs.readFileSync('CellStore.dll.nuspec', 'utf-8'), { async: false }, function (err, result) {
    version = result.package.metadata[0].version[0];
});

gulp.task('swagger:clean', $.shell.task([
   'rm -rf build',
   'mkdir build'
]));

gulp.task('swagger:resolve', ['swagger:clean'], function(done){
    request({ url: 'http://28msec.github.io/cellstore-pro/swagger-aggregated.json' }, function(err, resp){
        fs.writeFileSync('build/swagger-aggregated.json', resp.body);
        done();
    });
});

gulp.task('swagger:install-codegen', ['swagger:resolve'], $.shell.task('cd build && curl -L -o swagger-codegen.zip https://github.com/28msec/swagger-codegen/archive/2149dc04d52811cbf89ac72ab17a57be6a6150ac.zip && unzip -q swagger-codegen.zip && cd swagger-codegen-2149dc04d52811cbf89ac72ab17a57be6a6150ac && mvn package && cp modules/swagger-codegen-cli/target/swagger-codegen-cli.jar ..'));

gulp.task('swagger:generate-csharp', ['swagger:install-codegen'], $.shell.task([
    'cp codegen-options.json build',
    'cd build && java -jar swagger-codegen-cli.jar generate -i swagger-aggregated.json -l csharp -c codegen-options.json  -o .'
]));

gulp.task('swagger:csharp', ['swagger:generate-csharp'], $.shell.task([
    'cd build && mcs -sdk:4.5 -r:bin/Newtonsoft.Json.dll,bin/RestSharp.dll,System.Runtime.Serialization.dll -target:library -out:bin/CellStore.dll -recurse:src/*.cs -doc:bin/CellStore.xml -platform:anycpu',
    'cd build && if [ "' + artifactsDir + '" != "" ] ; then cp -R * ' + artifactsDir + ' ; fi'
]));

gulp.task('swagger:test', $.shell.task([
    'mcs -sdk:4.5 -r:build/bin/Newtonsoft.Json.dll,build/bin/RestSharp.dll,build/bin/CellStore.dll,System.Runtime.Serialization.dll samples/GetFacts/GetFacts/Program.cs',
    'cp build/bin/*.dll samples/GetFacts/GetFacts',
    'mono samples/GetFacts/GetFacts/Program.exe'
]));

gulp.task('swagger:pack', $.shell.task([
    'cp CellStore.dll.nuspec build',
    'cd build && wget https://nuget.org/nuget.exe',
    'cd build && mono nuget.exe pack CellStore.dll.nuspec'
]));

gulp.task('swagger:push', $.shell.task([
    'cd build && mono nuget.exe setApiKey ' + process.env.NUGET_API_KEY + ' | cat &> /dev/null',
    'cd build && mono nuget.exe push CellStore.NET.' + version + '.nupkg'
]));

gulp.task('swagger', function(done){
    if(isOnTravisAndMaster) {
        $.runSequence('swagger:csharp', 'swagger:test', 'swagger:pack', 'swagger:push', done);
    } else {
        $.runSequence('swagger:csharp', 'swagger:test', done);
    }
});

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