<commit_before>'use strict';
var util = require('util');
var gulp = require('gulp');
var concat = require('gulp-concat');
var del = require('del');
var inject = require('gulp-inject');
var cssnano = require('gulp-cssnano');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var templateCache = require('gulp-angular-templatecache');
var eventStream = require('event-stream');
var argv = require('yargs').argv;
var gulpNgConfig = require('gulp-ng-config');
var less = require('gulp-less');
var mainBowerFiles = require('main-bower-files');
var gulpSync = require('gulp-sync')(gulp);
var wait = require('gulp-wait');
var autoprefixer = require('gulp-autoprefixer');
var jsHint = require('gulp-jshint');
var gulpIf = require('gulp-if');
var connect = require('gulp-connect');
var angularFilesort = require('gulp-angular-filesort');
var babel = require('gulp-babel');
var htmlmin = require('gulp-htmlmin');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var rev = require('gulp-rev');
var config = require('./build.config.js');

var environment = 'development';
if (typeof argv.env === 'string' && config.environments.indexOf(argv.env.toLowerCase()) > -1) {
    environment = argv.env.toLowerCase();
}

gulp.task('lint', function () {
    return gulp.src(config.taskFiles.jshint)
        .pipe(jsHint())
        .pipe(jsHint.reporter('default'));
});

gulp.task('clean', function (callback) {
    var options = {
        force: true
    };
    del(config.buildFiles, options).then(function (paths) {
        console.log('Deleted files/folders:\n', paths.join('\n'));
        callback();
    });
});

gulp.task('constants', function () {
    var options = {
        environment: environment,
        createModule: true,
        wrap: '(function () {\n <%= module %> \n})();'
    };
    return gulp.src(config.appFiles.constants)
        .pipe(gulpNgConfig(config.names.constantsModule, options))
        .pipe(gulp.dest(config.outputPaths.constants));
});

gulp.task('less', function () {
    return gulp.src(config.appFiles.less)
        .pipe(less())
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false,
            remove: false
        }))
        .pipe(concat(config.names.output.appCss))
        .pipe(gulpIf(shouldMinify(), cssnano()))
        .pipe(gulpIf(shouldRevision(), rev()))
        .pipe(gulp.dest(config.outputPaths.css))
        .pipe(connect.reload());
});

gulp.task('html', function () {
    var htmlminOptions = {
        collapseWhitespace: true,
        removeComments: true
    };
    var options = {
        standalone: true,
        module: config.names.templatesModule,
        moduleSystem: 'IIFE'
    };
    return gulp.src(config.appFiles.html)
        .pipe(htmlmin(htmlminOptions))
        .pipe(templateCache(config.names.output.templatesJs, options))
        .pipe(gulpIf(shouldMinify(), uglify()))
        .pipe(gulpIf(shouldRevision(), rev()))
        .pipe(gulp.dest(config.outputPaths.templates))
        .pipe(connect.reload());
});

gulp.task('vendor-css', function () {
    var options = {
        filter: '**/*.css',
        debugging: false
    };
    return gulp.src(mainBowerFiles(options), {base: 'bower_components'})
        .pipe(concat(config.names.output.vendorCss))
        .pipe(gulpIf(shouldMinify(), cssnano()))
        .pipe(gulpIf(shouldRevision(), rev()))
        .pipe(gulp.dest(config.outputPaths.css));
});

gulp.task('app-js', ['constants'], function () {
    return gulp.src(config.appFiles.js)
        .pipe(ngAnnotate())
        .pipe(angularFilesort())
        .pipe(babel({presets: ['es2015']}))
        .pipe(concat(config.names.output.appJs))
        .pipe(gulpIf(shouldMinify(), uglify()))
        .pipe(gulpIf(shouldRevision(), rev()))
        .pipe(gulp.dest(config.outputPaths.js))
        .pipe(connect.reload());
});

gulp.task('vendor-js', function () {
    var options = {
        filter: '**/*.js',
        debugging: false
    };
    var mainBowerSourceFiles = gulp.src(mainBowerFiles(options), {
        base: 'bower_components'
    });
    var vendorJsSourceFiles = gulp.src(config.vendorFiles.js);
    return eventStream.merge(mainBowerSourceFiles, vendorJsSourceFiles)
        .pipe(ngAnnotate())
        .pipe(concat(config.names.output.vendorJs))
        .pipe(gulpIf(shouldMinify(), uglify()))
        .pipe(gulpIf(shouldRevision(), rev()))
        .pipe(gulp.dest(config.outputPaths.js));
});

gulp.task('font', function () {
    return gulp.src(mainBowerFiles({
            filter: '**/*.{eot,svg,ttf,woff,woff2}'
        }))
        .pipe(gulp.dest(config.outputPaths.fonts));
});

gulp.task('static-font', function () {
    return gulp.src(config.appFiles.fonts)
        .pipe(gulp.dest(config.outputPaths.fonts));
});

gulp.task('static-files', function () {
    return gulp.src(config.appFiles.staticFiles)
        .pipe(gulp.dest(config.outputPaths.root));
});

gulp.task('favicon', function () {
    return gulp.src(config.appFiles.favicon)
        .pipe(gulp.dest(config.outputPaths.root));
});

gulp.task('images', function () {
    var options = {
        optimizationLevel: 3,
        progressive: true,
        interlaced: true,
        multipass: true,
        svgoPlugins: [{removeViewBox: false}],
        use: [pngquant()]
    };
    return gulp.src(config.appFiles.images)
        .pipe(gulpIf(shouldMinify(), imagemin(options)))
        .pipe(gulp.dest(config.outputPaths.images))
        .pipe(connect.reload());
});

gulp.task('build-index', gulpSync.sync(['clean', 'work']), function () {
    var jsFiles = gulp.src([
        config.outputPaths.js + '/vendor*.js',
        config.outputPaths.js + '/templates*.js',
        config.outputPaths.js + '/build*.js'
    ], {
        read: false
    });

    var cssFiles = gulp.src([
        config.outputPaths.css + '/vendor*.css',
        config.outputPaths.css + '/build*.css'
    ], {
        read: false
    });
    var options = {
        ignorePath: config.outputPaths.injectIgnoreString,
        addRootSlash: false,
        read: false
    };
    console.log('Environment: %s', environment);
    return gulp.src(config.appFiles.index)
        .pipe(wait(1000))
        .pipe(inject(cssFiles, options))
        .pipe(inject(jsFiles, options))
        .pipe(gulp.dest(config.outputPaths.root))
        .pipe(connect.reload());
});

gulp.task('default', ['build-index']);

gulp.task('work', ['html', 'vendor-css', 'less', 'vendor-js', 'app-js', 'static-font', 'font', 'favicon', 'images']);

gulp.task('watch', ['build-index', 'connect'], function () {
    gulp.watch(config.watch.less, ['less']);
    gulp.watch(config.watch.js, ['app-js']);
    gulp.watch(config.watch.html, ['html']);
    gulp.watch(config.watch.images, ['images']);
    gulp.watch(config.watch.constants, ['app-js']);
});

gulp.task('connect', ['build-index'], function () {
    connect.server({
        root: config.outputPaths.root,
        port: 9000,
        livereload: true,
        fallback: config.outputPaths.root + '/index.html'
    });
});

gulp.task('start', function () {
    connect.server({
        root: config.outputPaths.root,
        port: 9000,
        livereload: false,
        fallback: config.outputPaths.root + '/index.html'
    });
});

function shouldRevision() {
    if (environment === 'development' || environment === 'localqa') {
        return false;
    }
    return true;
}

function shouldMinify() {
    if (environment === 'development' || environment === 'localqa') {
        return false;
    }
    return true;
}

gulp.task('test:build', ['test:clean', 'test:constants', 'test:html']);

gulp.task('test:clean', function (callback) {
    var options = {
        force: true
    };
    del(config.tempFiles, options).then(function (paths) {
        console.log('Deleted generated test files/folders:\n', paths.join('\n'));
        callback();
    });
});

gulp.task('test:constants', ['test:clean'], function () {
    var options = {
        environment: 'test',
        createModule: true,
        wrap: '(function () {\n <%= module %> \n})();'
    };
    return gulp.src(config.appFiles.constants)
        .pipe(gulpNgConfig(config.names.constantsModule, options))
        .pipe(uglify())
        .pipe(rev())
        .pipe(gulp.dest(config.outputPaths.testDependencies));
});

gulp.task('test:html', ['test:clean'], function () {
    var htmlminOptions = {
        collapseWhitespace: true,
        removeComments: true
    };
    var options = {
        standalone: true,
        module: config.names.templatesModule,
        moduleSystem: 'IIFE'
    };
    return gulp.src(config.appFiles.html)
        .pipe(htmlmin(htmlminOptions))
        .pipe(templateCache(config.names.output.templatesJs, options))
        .pipe(uglify())
        .pipe(rev())
        .pipe(gulp.dest(config.outputPaths.testDependencies))
});<commit_msg>Rearranged the javascript build step<commit_after>'use strict';
var util = require('util');
var gulp = require('gulp');
var concat = require('gulp-concat');
var del = require('del');
var inject = require('gulp-inject');
var cssnano = require('gulp-cssnano');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var templateCache = require('gulp-angular-templatecache');
var eventStream = require('event-stream');
var argv = require('yargs').argv;
var gulpNgConfig = require('gulp-ng-config');
var less = require('gulp-less');
var mainBowerFiles = require('main-bower-files');
var gulpSync = require('gulp-sync')(gulp);
var wait = require('gulp-wait');
var autoprefixer = require('gulp-autoprefixer');
var jsHint = require('gulp-jshint');
var gulpIf = require('gulp-if');
var connect = require('gulp-connect');
var angularFilesort = require('gulp-angular-filesort');
var babel = require('gulp-babel');
var htmlmin = require('gulp-htmlmin');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var rev = require('gulp-rev');
var config = require('./build.config.js');

var environment = 'development';
if (typeof argv.env === 'string' && config.environments.indexOf(argv.env.toLowerCase()) > -1) {
    environment = argv.env.toLowerCase();
}

gulp.task('lint', function () {
    return gulp.src(config.taskFiles.jshint)
        .pipe(jsHint())
        .pipe(jsHint.reporter('default'));
});

gulp.task('clean', function (callback) {
    var options = {
        force: true
    };
    del(config.buildFiles, options).then(function (paths) {
        console.log('Deleted files/folders:\n', paths.join('\n'));
        callback();
    });
});

gulp.task('constants', function () {
    var options = {
        environment: environment,
        createModule: true,
        wrap: '(function () {\n <%= module %> \n})();'
    };
    return gulp.src(config.appFiles.constants)
        .pipe(gulpNgConfig(config.names.constantsModule, options))
        .pipe(gulp.dest(config.outputPaths.constants));
});

gulp.task('less', function () {
    return gulp.src(config.appFiles.less)
        .pipe(less())
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false,
            remove: false
        }))
        .pipe(concat(config.names.output.appCss))
        .pipe(gulpIf(shouldMinify(), cssnano()))
        .pipe(gulpIf(shouldRevision(), rev()))
        .pipe(gulp.dest(config.outputPaths.css))
        .pipe(connect.reload());
});

gulp.task('html', function () {
    var htmlminOptions = {
        collapseWhitespace: true,
        removeComments: true
    };
    var options = {
        standalone: true,
        module: config.names.templatesModule,
        moduleSystem: 'IIFE'
    };
    return gulp.src(config.appFiles.html)
        .pipe(htmlmin(htmlminOptions))
        .pipe(templateCache(config.names.output.templatesJs, options))
        .pipe(gulpIf(shouldMinify(), uglify()))
        .pipe(gulpIf(shouldRevision(), rev()))
        .pipe(gulp.dest(config.outputPaths.templates))
        .pipe(connect.reload());
});

gulp.task('vendor-css', function () {
    var options = {
        filter: '**/*.css',
        debugging: false
    };
    return gulp.src(mainBowerFiles(options), {base: 'bower_components'})
        .pipe(concat(config.names.output.vendorCss))
        .pipe(gulpIf(shouldMinify(), cssnano()))
        .pipe(gulpIf(shouldRevision(), rev()))
        .pipe(gulp.dest(config.outputPaths.css));
});

gulp.task('app-js', ['constants'], function () {
    return gulp.src(config.appFiles.js)
        .pipe(angularFilesort())
        .pipe(ngAnnotate())
        .pipe(babel({presets: ['es2015']}))
        .pipe(concat(config.names.output.appJs))
        .pipe(gulpIf(shouldMinify(), uglify()))
        .pipe(gulpIf(shouldRevision(), rev()))
        .pipe(gulp.dest(config.outputPaths.js))
        .pipe(connect.reload());
});

gulp.task('vendor-js', function () {
    var options = {
        filter: '**/*.js',
        debugging: false
    };
    var mainBowerSourceFiles = gulp.src(mainBowerFiles(options), {
        base: 'bower_components'
    });
    var vendorJsSourceFiles = gulp.src(config.vendorFiles.js);
    return eventStream.merge(mainBowerSourceFiles, vendorJsSourceFiles)
        .pipe(ngAnnotate())
        .pipe(concat(config.names.output.vendorJs))
        .pipe(gulpIf(shouldMinify(), uglify()))
        .pipe(gulpIf(shouldRevision(), rev()))
        .pipe(gulp.dest(config.outputPaths.js));
});

gulp.task('font', function () {
    return gulp.src(mainBowerFiles({
            filter: '**/*.{eot,svg,ttf,woff,woff2}'
        }))
        .pipe(gulp.dest(config.outputPaths.fonts));
});

gulp.task('static-font', function () {
    return gulp.src(config.appFiles.fonts)
        .pipe(gulp.dest(config.outputPaths.fonts));
});

gulp.task('static-files', function () {
    return gulp.src(config.appFiles.staticFiles)
        .pipe(gulp.dest(config.outputPaths.root));
});

gulp.task('favicon', function () {
    return gulp.src(config.appFiles.favicon)
        .pipe(gulp.dest(config.outputPaths.root));
});

gulp.task('images', function () {
    var options = {
        optimizationLevel: 3,
        progressive: true,
        interlaced: true,
        multipass: true,
        svgoPlugins: [{removeViewBox: false}],
        use: [pngquant()]
    };
    return gulp.src(config.appFiles.images)
        .pipe(gulpIf(shouldMinify(), imagemin(options)))
        .pipe(gulp.dest(config.outputPaths.images))
        .pipe(connect.reload());
});

gulp.task('build-index', gulpSync.sync(['clean', 'work']), function () {
    var jsFiles = gulp.src([
        config.outputPaths.js + '/vendor*.js',
        config.outputPaths.js + '/templates*.js',
        config.outputPaths.js + '/build*.js'
    ], {
        read: false
    });

    var cssFiles = gulp.src([
        config.outputPaths.css + '/vendor*.css',
        config.outputPaths.css + '/build*.css'
    ], {
        read: false
    });
    var options = {
        ignorePath: config.outputPaths.injectIgnoreString,
        addRootSlash: false,
        read: false
    };
    console.log('Environment: %s', environment);
    return gulp.src(config.appFiles.index)
        .pipe(wait(1000))
        .pipe(inject(cssFiles, options))
        .pipe(inject(jsFiles, options))
        .pipe(gulp.dest(config.outputPaths.root))
        .pipe(connect.reload());
});

gulp.task('default', ['build-index']);

gulp.task('work', ['html', 'vendor-css', 'less', 'vendor-js', 'app-js', 'static-font', 'font', 'favicon', 'images']);

gulp.task('watch', ['build-index', 'connect'], function () {
    gulp.watch(config.watch.less, ['less']);
    gulp.watch(config.watch.js, ['app-js']);
    gulp.watch(config.watch.html, ['html']);
    gulp.watch(config.watch.images, ['images']);
    gulp.watch(config.watch.constants, ['app-js']);
});

gulp.task('connect', ['build-index'], function () {
    connect.server({
        root: config.outputPaths.root,
        port: 9000,
        livereload: true,
        fallback: config.outputPaths.root + '/index.html'
    });
});

gulp.task('start', function () {
    connect.server({
        root: config.outputPaths.root,
        port: 9000,
        livereload: false,
        fallback: config.outputPaths.root + '/index.html'
    });
});

function shouldRevision() {
    if (environment === 'development' || environment === 'localqa') {
        return false;
    }
    return true;
}

function shouldMinify() {
    if (environment === 'development' || environment === 'localqa') {
        return false;
    }
    return true;
}

gulp.task('test:build', ['test:clean', 'test:constants', 'test:html']);

gulp.task('test:clean', function (callback) {
    var options = {
        force: true
    };
    del(config.tempFiles, options).then(function (paths) {
        console.log('Deleted generated test files/folders:\n', paths.join('\n'));
        callback();
    });
});

gulp.task('test:constants', ['test:clean'], function () {
    var options = {
        environment: 'test',
        createModule: true,
        wrap: '(function () {\n <%= module %> \n})();'
    };
    return gulp.src(config.appFiles.constants)
        .pipe(gulpNgConfig(config.names.constantsModule, options))
        .pipe(uglify())
        .pipe(rev())
        .pipe(gulp.dest(config.outputPaths.testDependencies));
});

gulp.task('test:html', ['test:clean'], function () {
    var htmlminOptions = {
        collapseWhitespace: true,
        removeComments: true
    };
    var options = {
        standalone: true,
        module: config.names.templatesModule,
        moduleSystem: 'IIFE'
    };
    return gulp.src(config.appFiles.html)
        .pipe(htmlmin(htmlminOptions))
        .pipe(templateCache(config.names.output.templatesJs, options))
        .pipe(uglify())
        .pipe(rev())
        .pipe(gulp.dest(config.outputPaths.testDependencies))
});<|endoftext|>


<commit_before>// Include gulp
var gulp = require('gulp');

// Include Our Plugins
var jshint = require('gulp-jshint');
var Server = require('karma').Server;
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var ngAnnotate = require('gulp-ng-annotate');

// Lint Task
gulp.task('lint', function() {
    return gulp.src('src/*/*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
    return gulp.src([
<<<<<<< HEAD
            'src/directives/cytoscape-directive.js',
            'src/directives/graph-elements.js',
            'src/directives/graph-layout.js',
            'src/directives/graph-style.js',
            'src/services/cytoCreateGraph.js',
            'src/services/cytoElementsHelpers.js',
            'src/services/cytoData.js',
            'src/services/cytoEvents.js',
            'src/services/cytoGraphDefaults.js',
            'src/services/cytoHelpers.js',
            'src/services/cytoLayoutDefaults.js'
=======
        'src/directives/cytoscape-directive.js',
        'src/directives/graph-elements.js',
        'src/directives/graph-layout.js',
        'src/directives/graph-style.js',
        'src/services/cytoCreateGraph.js',
        'src/services/cytoElementsHelpers.js',
        'src/services/cytoData.js',
        'src/services/cytoEvents.js',
        'src/services/cytoGraphDefaults.js',
        'src/services/cytoHelpers.js',
        'src/services/cytoLayoutDefaults.js'
>>>>>>> development
        ])
        .pipe(concat('ngCytoscape.js'))
        .pipe(gulp.dest('dst'))
        .pipe(rename('ngCytoscape.min.js'))
        .pipe(uglify())

        .pipe(gulp.dest('dst'));
});
gulp.task('test', function (done) {
    new Server({
        configFile: __dirname + '/karma.conf.js',
        singleRun: true
    }, done).start();
});
// Watch Files For Changes
gulp.task('watch', function() {
    gulp.watch(['src/services/*.js', 'src/directives/*.js'], ['lint', 'scripts']);
});
gulp.task('build', ['lint','test','scripts']);
// Default Task
gulp.task('dev', ['lint', 'scripts', 'watch']);<commit_msg>fixe gulp file<commit_after>// Include gulp
var gulp = require('gulp');

// Include Our Plugins
var jshint = require('gulp-jshint');
var Server = require('karma').Server;
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var ngAnnotate = require('gulp-ng-annotate');

// Lint Task
gulp.task('lint', function() {
    return gulp.src('src/*/*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
    return gulp.src([
        'src/directives/cytoscape-directive.js',
        'src/directives/graph-elements.js',
        'src/directives/graph-layout.js',
        'src/directives/graph-style.js',
        'src/services/cytoCreateGraph.js',
        'src/services/cytoElementsHelpers.js',
        'src/services/cytoData.js',
        'src/services/cytoEvents.js',
        'src/services/cytoGraphDefaults.js',
        'src/services/cytoHelpers.js',
        'src/services/cytoLayoutDefaults.js'
        ])
        .pipe(concat('ngCytoscape.js'))
        .pipe(gulp.dest('dst'))
        .pipe(rename('ngCytoscape.min.js'))
        .pipe(uglify())

        .pipe(gulp.dest('dst'));
});
gulp.task('test', function (done) {
    new Server({
        configFile: __dirname + '/karma.conf.js',
        singleRun: true
    }, done).start();
});
// Watch Files For Changes
gulp.task('watch', function() {
    gulp.watch(['src/services/*.js', 'src/directives/*.js'], ['lint', 'scripts']);
});
gulp.task('build', ['lint','test','scripts']);
// Default Task
gulp.task('dev', ['lint', 'scripts', 'watch']);<|endoftext|>


<commit_before>var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
const fs = require('fs');
const del = require('del');
const glob = require('glob');
const path = require('path');
const mkdirp = require('mkdirp');
const babelify = require('babelify');
const isparta = require('isparta');
const esperanto = require('esperanto');
const browserify = require('browserify');
const runSequence = require('run-sequence');
const source = require('vinyl-source-stream');
const manifest = require('./package.json');
const config = manifest.seniOptions;
const mainFile = manifest.main;
const destinationFolder = path.dirname(mainFile);
const exportFileName = path.basename(mainFile, path.extname(mainFile));

// Remove the built files
gulp.task('clean', function(cb) {
  del([destinationFolder], cb);
});

// Remove our temporary files
gulp.task('clean-tmp', function(cb) {
  del(['tmp'], cb);
});

// Send a notification when JSHint fails,
// so that you know your changes didn't build
function jshintNotify(file) {
  if (!file.jshint) { return; }
  return file.jshint.success ? false : 'JSHint failed';
}

function jscsNotify(file) {
  if (!file.jscs) { return; }
  return file.jscs.success ? false : 'JSRC failed';
}

// Lint our source code
gulp.task('lint-src', function() {
  return gulp.src(['src/**/*.js'])
    .pipe($.plumber())
    .pipe($.jshint())
    .pipe($.jshint.reporter('jshint-stylish'))
    .pipe($.notify(jshintNotify))
    .pipe($.jscs())
    .pipe($.notify(jscsNotify))
    .pipe($.jshint.reporter('fail'));
});

// Lint our test code
gulp.task('lint-test', function() {
  return gulp.src(['test/**/*.js'])
    .pipe($.plumber())
    .pipe($.jshint())
    .pipe($.jshint.reporter('jshint-stylish'))
    .pipe($.notify(jshintNotify))
    .pipe($.jscs())
    .pipe($.notify(jscsNotify))
    .pipe($.jshint.reporter('fail'));
});

// Build two versions of the library
gulp.task('build', ['lint-src', 'clean'], function(done) {
  esperanto.bundle({
    base: 'src',
    entry: config.entryFileName
  }).then(function(bundle) {
    var res = bundle.toUmd({
      sourceMap: true,
      sourceMapSource: config.entryFileName + '.js',
      sourceMapFile: exportFileName + '.js',
      name: config.exportVarName
    });
    // Write the generated sourcemap
    mkdirp.sync(destinationFolder);
    fs.writeFileSync(path.join(destinationFolder, exportFileName + '.js'), res.map.toString());

    $.file(exportFileName + '.js', res.code, { src: true })
      .pipe($.plumber())
      .pipe($.sourcemaps.init({ loadMaps: true }))
      .pipe($.babel({ blacklist: ['useStrict'] }))
      .pipe($.sourcemaps.write('./', {addComment: false}))
      .pipe(gulp.dest(destinationFolder))
      .pipe($.filter(['*', '!**/*.js.map']))
      .pipe($.rename(exportFileName + '.min.js'))
      .pipe($.uglifyjs({
        outSourceMap: true,
        inSourceMap: destinationFolder + '/' + exportFileName + '.js.map'
      }))
      .pipe(gulp.dest(destinationFolder))
      .on('end', done);
  });
});

// Bundle our app for our unit tests
gulp.task('browserify', function() {
  var testFiles = glob.sync('./test/unit/**/*');
  var allFiles = ['./test/setup/browserify.js'].concat(testFiles);
  var bundler = browserify(allFiles);
  bundler.transform(babelify.configure({
    sourceMapRelative: __dirname + '/src',
    blacklist: ['useStrict']
  }));
  var bundleStream = bundler.bundle();
  return bundleStream
    .on('error', function(err){
      console.log(err.message);
      this.emit('end');
    })
    .pipe($.plumber())
    .pipe(source('./tmp/__spec-build.js'))
    .pipe(gulp.dest(''))
    .pipe($.livereload());
});

gulp.task('coverage', function(done) {
  require('babel/register')({ modules: 'common' });
  gulp.src(['src/**/*.js'])
    .pipe($.plumber())
    .pipe($.istanbul({ instrumenter: isparta.Instrumenter }))
    .pipe($.istanbul.hookRequire())
    .on('finish', function() {
      return test()
      .pipe($.istanbul.writeReports())
      .on('end', done);
    });
});

function test() {

  return gulp.src(['test/setup/node.js', 'test/unit/**/*.js'], {read: false})
    .pipe($.plumber())
    .pipe($.mocha({reporter: 'dot', globals: config.mochaGlobals}));
};

// Lint and run our tests
gulp.task('test', ['lint-src', 'lint-test'], function() {
  require('babel/register')({ modules: 'common' });
  return test();
});

// Ensure that linting occurs before browserify runs. This prevents
// the build from breaking due to poorly formatted code.
gulp.task('build-in-sequence', function(callback) {
  runSequence(['lint-src', 'lint-test'], 'browserify', callback);
});

// Run the headless unit tests as you make changes.
gulp.task('watch', function() {
  gulp.watch(['src/**/*', 'test/**/*', '.jshintrc', 'test/.jshintrc'], ['test']);
});

// Build as you make changes.
gulp.task('build-watch', function() {
  gulp.watch(['src/**/*'], ['build']);
});

// Set up a livereload environment for our spec runner
gulp.task('test-browser', ['build-in-sequence'], function() {
  $.livereload.listen({port: 35729, host: 'localhost', start: true});
  return gulp.watch(['src/**/*.js', 'test/**/*', '.jshintrc', 'test/.jshintrc'], ['build-in-sequence']);
});

// An alias of test
gulp.task('default', ['test']);
<commit_msg>js2 mode warning removal<commit_after>var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
const fs = require('fs');
const del = require('del');
const glob = require('glob');
const path = require('path');
const mkdirp = require('mkdirp');
const babelify = require('babelify');
const isparta = require('isparta');
const esperanto = require('esperanto');
const browserify = require('browserify');
const runSequence = require('run-sequence');
const source = require('vinyl-source-stream');
const manifest = require('./package.json');
const config = manifest.seniOptions;
const mainFile = manifest.main;
const destinationFolder = path.dirname(mainFile);
const exportFileName = path.basename(mainFile, path.extname(mainFile));

// Remove the built files
gulp.task('clean', function(cb) {
  del([destinationFolder], cb);
});

// Remove our temporary files
gulp.task('clean-tmp', function(cb) {
  del(['tmp'], cb);
});

// Send a notification when JSHint fails,
// so that you know your changes didn't build
function jshintNotify(file) {
  if (!file.jshint) { return false; }
  return file.jshint.success ? false : 'JSHint failed';
}

function jscsNotify(file) {
  if (!file.jscs) { return false; }
  return file.jscs.success ? false : 'JSRC failed';
}

// Lint our source code
gulp.task('lint-src', function() {
  return gulp.src(['src/**/*.js'])
    .pipe($.plumber())
    .pipe($.jshint())
    .pipe($.jshint.reporter('jshint-stylish'))
    .pipe($.notify(jshintNotify))
    .pipe($.jscs())
    .pipe($.notify(jscsNotify))
    .pipe($.jshint.reporter('fail'));
});

// Lint our test code
gulp.task('lint-test', function() {
  return gulp.src(['test/**/*.js'])
    .pipe($.plumber())
    .pipe($.jshint())
    .pipe($.jshint.reporter('jshint-stylish'))
    .pipe($.notify(jshintNotify))
    .pipe($.jscs())
    .pipe($.notify(jscsNotify))
    .pipe($.jshint.reporter('fail'));
});

// Build two versions of the library
gulp.task('build', ['lint-src', 'clean'], function(done) {
  esperanto.bundle({
    base: 'src',
    entry: config.entryFileName
  }).then(function(bundle) {
    var res = bundle.toUmd({
      sourceMap: true,
      sourceMapSource: config.entryFileName + '.js',
      sourceMapFile: exportFileName + '.js',
      name: config.exportVarName
    });
    // Write the generated sourcemap
    mkdirp.sync(destinationFolder);
    fs.writeFileSync(path.join(destinationFolder, exportFileName + '.js'), res.map.toString());

    $.file(exportFileName + '.js', res.code, { src: true })
      .pipe($.plumber())
      .pipe($.sourcemaps.init({ loadMaps: true }))
      .pipe($.babel({ blacklist: ['useStrict'] }))
      .pipe($.sourcemaps.write('./', {addComment: false}))
      .pipe(gulp.dest(destinationFolder))
      .pipe($.filter(['*', '!**/*.js.map']))
      .pipe($.rename(exportFileName + '.min.js'))
      .pipe($.uglifyjs({
        outSourceMap: true,
        inSourceMap: destinationFolder + '/' + exportFileName + '.js.map'
      }))
      .pipe(gulp.dest(destinationFolder))
      .on('end', done);
  });
});

// Bundle our app for our unit tests
gulp.task('browserify', function() {
  var testFiles = glob.sync('./test/unit/**/*');
  var allFiles = ['./test/setup/browserify.js'].concat(testFiles);
  var bundler = browserify(allFiles);
  bundler.transform(babelify.configure({
    sourceMapRelative: __dirname + '/src',
    blacklist: ['useStrict']
  }));
  var bundleStream = bundler.bundle();
  return bundleStream
    .on('error', function(err){
      console.log(err.message);
      this.emit('end');
    })
    .pipe($.plumber())
    .pipe(source('./tmp/__spec-build.js'))
    .pipe(gulp.dest(''))
    .pipe($.livereload());
});

gulp.task('coverage', function(done) {
  require('babel/register')({ modules: 'common' });
  gulp.src(['src/**/*.js'])
    .pipe($.plumber())
    .pipe($.istanbul({ instrumenter: isparta.Instrumenter }))
    .pipe($.istanbul.hookRequire())
    .on('finish', function() {
      return test()
      .pipe($.istanbul.writeReports())
      .on('end', done);
    });
});

function test() {

  return gulp.src(['test/setup/node.js', 'test/unit/**/*.js'], {read: false})
    .pipe($.plumber())
    .pipe($.mocha({reporter: 'dot', globals: config.mochaGlobals}));
};

// Lint and run our tests
gulp.task('test', ['lint-src', 'lint-test'], function() {
  require('babel/register')({ modules: 'common' });
  return test();
});

// Ensure that linting occurs before browserify runs. This prevents
// the build from breaking due to poorly formatted code.
gulp.task('build-in-sequence', function(callback) {
  runSequence(['lint-src', 'lint-test'], 'browserify', callback);
});

// Run the headless unit tests as you make changes.
gulp.task('watch', function() {
  gulp.watch(['src/**/*', 'test/**/*', '.jshintrc', 'test/.jshintrc'], ['test']);
});

// Build as you make changes.
gulp.task('build-watch', function() {
  gulp.watch(['src/**/*'], ['build']);
});

// Set up a livereload environment for our spec runner
gulp.task('test-browser', ['build-in-sequence'], function() {
  $.livereload.listen({port: 35729, host: 'localhost', start: true});
  return gulp.watch(['src/**/*.js', 'test/**/*', '.jshintrc', 'test/.jshintrc'], ['build-in-sequence']);
});

// An alias of test
gulp.task('default', ['test']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var initGulpTasks = require('react-component-gulp-tasks');

/**
 * Tasks are added by the react-component-gulp-tasks package
 *
 * See https://github.com/JedWatson/react-component-gulp-tasks
 * for documentation.
 *
 * You can also add your own additional gulp tasks if you like.
 */

// Read the package.json to detect the package name
var pkg = JSON.parse(require('fs').readFileSync('./package.json'));

var taskConfig = {

  component: {
    name: 'BurgerMenu',
    dependencies: [
      'classnames',
      'react',
      'snapsvg'
    ],
    lib: 'lib',
    file: 'BurgerMenu.js',
    src: 'src',
    dist: 'dist',
    pkgName: pkg.name
  },

  example: {
    src: 'example/src',
    dist: 'example/dist',
    files: [
      'index.html',
      '.gitignore',
      'normalize.css',
      'fonts/**/*'
    ],
    scripts: [
      'example.js'
    ],
    less: [
      'example.less'
    ]
  }

};

initGulpTasks(gulp, taskConfig);
<commit_msg>Update deps<commit_after>var gulp = require('gulp');
var initGulpTasks = require('react-component-gulp-tasks');

/**
 * Tasks are added by the react-component-gulp-tasks package
 *
 * See https://github.com/JedWatson/react-component-gulp-tasks
 * for documentation.
 *
 * You can also add your own additional gulp tasks if you like.
 */

// Read the package.json to detect the package name
var pkg = JSON.parse(require('fs').readFileSync('./package.json'));

var taskConfig = {

  component: {
    name: 'BurgerMenu',
    dependencies: [
      'browserify-optional',
      'classnames',
      'react',
      'snapsvg'
    ],
    lib: 'lib',
    file: 'BurgerMenu.js',
    src: 'src',
    dist: 'dist',
    pkgName: pkg.name
  },

  example: {
    src: 'example/src',
    dist: 'example/dist',
    files: [
      'index.html',
      '.gitignore',
      'normalize.css',
      'fonts/**/*'
    ],
    scripts: [
      'example.js'
    ],
    less: [
      'example.less'
    ]
  }

};

initGulpTasks(gulp, taskConfig);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');
var logger = require('mino-logger');

var less = require('gulp-less');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var watch = require('gulp-watch');
var gulpImports = require('gulp-imports');
var nodemon = require('gulp-nodemon');
var path = require('path');

var docs_to_json = require('sa-docs-to-json');

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

require('./default_plugins/admin_server/gulpfile')(gulp);
require('./default_plugins/browser_server/gulpfile')(gulp);
require('./default_plugins/auth/gulpfile')(gulp);
require('./default_plugins/permissions/gulpfile')(gulp);
require('./MinoDB/ui_server/gulpfile')(gulp);

var throw_errors = true;
var debug = gulp.env.debug;
if (debug) {
    logger.set_level("debug");
}

var onError = function (err) {
  gutil.beep();
  console.log(err);
  if (throw_errors) {
    throw err;
  }
};

gulp.task('test', function(cb){

    var run_tests = function() {
        var task = gulp.src( [ 'test/test.js' ] )
        .pipe( mocha( {
            reporter: 'spec',
            grep: gulp.env.grep
        }))

        if (!debug) {
            task.pipe(istanbul.writeReports())
        }

        task.on('end', cb)
        task.pipe(plumber(onError));
    }

    var setup_coverage = function(callback) {
        gulp.src([
            'MinoDB/**/*.js',
            '!MinoDB/ui_server/**/*',
            'common_classes/**/*.js',
            'default_plugins/auth/Auth.js',
            'default_plugins/permissions/MinoDbPermissions.js',
        ])
        .pipe(istanbul())
        .pipe(istanbul.hookRequire())
        .on( 'finish', function () {
            callback();
        })
        .on('error', gutil.log);
    }

    if (debug) {
        run_tests();
    } else {
        setup_coverage(function() {
            run_tests();
        })
    }

});

gulp.task('docs', function() {
    return gulp.src('./docs_src/*.json')
    .pipe(docs_to_json())
    .pipe(gulp.dest('./docs/'))
});

gulp.task('watch', function(){
    gulp.watch('docs_src/**/**.*', ['docs']);
    gulp.watch(['fieldval_themes/**/**.*','common_elements/**/**.*','common_classes/**/**.*'], ['default']);
    gulp.start('browser_watch');
    gulp.start('auth_watch');
    gulp.start('admin_watch');
    gulp.start('ui_watch');
    gulp.start('permissions_watch');
});

gulp.task('default', function(){
    gulp.start('browser_default');
    gulp.start('auth_default');
    gulp.start('admin_default');
    gulp.start('ui_default');
    gulp.start('permissions_default');
})

gulp.task('dev', function(){
    gulp.start('default');
    gulp.start('watch');
})<commit_msg>Improved style of gulpfile.js<commit_after>var gulp = require('gulp');
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');
var logger = require('mino-logger');

var less = require('gulp-less');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var watch = require('gulp-watch');
var gulpImports = require('gulp-imports');
var nodemon = require('gulp-nodemon');
var path = require('path');

var docs_to_json = require('sa-docs-to-json');

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

require('./default_plugins/admin_server/gulpfile')(gulp);
require('./default_plugins/browser_server/gulpfile')(gulp);
require('./default_plugins/auth/gulpfile')(gulp);
require('./default_plugins/permissions/gulpfile')(gulp);
require('./MinoDB/ui_server/gulpfile')(gulp);

var throw_errors = true;
var debug = gulp.env.debug;
if (debug) {
    logger.set_level("debug");
}

var onError = function (err) {
  gutil.beep();
  console.log(err);
  if (throw_errors) {
    throw err;
  }
};

gulp.task('test', function(cb){

    var run_tests = function() {
        var task = gulp.src( [ 'test/test.js' ] )
        .pipe( mocha( {
            reporter: 'spec',
            grep: gulp.env.grep
        }));

        if (!debug) {
            task.pipe(istanbul.writeReports());
        }

        task.on('end', cb);
        task.pipe(plumber(onError));
    };

    var setup_coverage = function(callback) {
        gulp.src([
            'MinoDB/**/*.js',
            '!MinoDB/ui_server/**/*',
            'common_classes/**/*.js',
            'default_plugins/auth/Auth.js',
            'default_plugins/permissions/MinoDbPermissions.js',
        ])
        .pipe(istanbul())
        .pipe(istanbul.hookRequire())
        .on( 'finish', function () {
            callback();
        })
        .on('error', gutil.log);
    };

    if (debug) {
        run_tests();
    } else {
        setup_coverage(function() {
            run_tests();
        });
    }

});

gulp.task('docs', function() {
    return gulp.src('./docs_src/*.json')
    .pipe(docs_to_json())
    .pipe(gulp.dest('./docs/'));
});

gulp.task('watch', function(){
    gulp.watch('docs_src/**/**.*', ['docs']);
    gulp.watch(['fieldval_themes/**/**.*','common_elements/**/**.*','common_classes/**/**.*'], ['default']);
    gulp.start('browser_watch');
    gulp.start('auth_watch');
    gulp.start('admin_watch');
    gulp.start('ui_watch');
    gulp.start('permissions_watch');
});

gulp.task('default', function(){
    gulp.start('browser_default');
    gulp.start('auth_default');
    gulp.start('admin_default');
    gulp.start('ui_default');
    gulp.start('permissions_default');
});

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


<commit_before>'use strict';

// Include gulp
var gulp = require('gulp');
var pkg  = require('./package.json');
var beep = require('beepbeep');
var onError = function() {
  beep();
};

// Include Our Plugins
var eslint     = require('gulp-eslint');
var nodeunit   = require('gulp-nodeunit');
var livereload = require('gulp-livereload');
var plumber    = require('gulp-plumber');
var shell      = require('gulp-shell');
var sass       = require('gulp-sass');
var rename     = require("gulp-rename");
var uglify     = require('gulp-uglify');
var postcss    = require('gulp-postcss');
var autoprefixer = require('autoprefixer');

// Lint Task
gulp.task('eslint', function() {
  return gulp.src(
    [
      '*.js',
      pkg.directories.src+'/**/*.js',
      pkg.directories.test+'/**/*.js'
    ])
    .pipe(plumber({errorHandler: onError}))
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError())
  ;
});

// Node Unit
gulp.task('nodeunit', function() {
  return gulp.src(pkg.directories.test + '/**/*.js')
    .pipe(plumber({errorHandler: onError}))
    .pipe(nodeunit({
      reporter: 'minimal'
    }))
  ;
});

// Lint Task
gulp.task('build-js', function() {
  return gulp.src(
    [
      pkg.directories.theme + '/**/js-src/*.js'
    ])
    .pipe(plumber({errorHandler: onError}))
    .pipe(eslint({
      "env": {
        "browser": true,
        "jquery": true
      },
      "globals": {},
      "rules": {
        "strict": [
          2,
          "safe"
        ],
        "curly": 2,
        "no-undef": 2
      }
    }))
    .pipe(eslint.format())
    .pipe(eslint.failAfterError())
    .pipe(eslint.reporter('default'))
    .pipe(eslint.reporter('fail'))
    .pipe(uglify({output: {
      max_line_len: 9000
    }}))
    .pipe(rename(function(path){
      path.dirname = path.dirname.replace(/js\-src/, 'js');
      return path;
    }))
    .pipe(gulp.dest(pkg.directories.theme))
  ;
});

// Sass
gulp.task('build-sass', function() {
  return gulp.src(pkg.directories.theme + '/**/*.scss')
    .pipe(plumber({errorHandler: onError}))
    .pipe(sass({outputStyle: 'compact'}).on('error', sass.logError))
    .pipe(postcss([
      autoprefixer({
        browsers: ['last 2 versions', '> 0.5%', 'ie 8-11']
      })
    ]))
    .pipe(rename(function(path){
      path.dirname = path.dirname.replace(/sass/, 'css');
      return path;
    }))
    .pipe(gulp.dest(pkg.directories.theme))
  ;
});

// Watch Files For Changes
gulp.task('watch', function() {
  livereload.listen();
  gulp.watch(['gulpfile.js', 'package.json'], process.exit);
  gulp.watch(['*.js', pkg.directories.src+'/**/*.js', pkg.directories.test+'/**/*.js'], ['test']);
  gulp.watch([pkg.directories.data+'/**/*'],       ['generate']);
  gulp.watch(pkg.directories.theme + '/**/*.js',   ['build-js']);
  gulp.watch(pkg.directories.theme + '/**/*.scss', ['build-sass']);
});

// Default Task
gulp.task('default',     ['eslint', 'nodeunit', 'build-js', 'build-sass']);
gulp.task('test',        ['eslint', 'nodeunit']);
gulp.task('generate',    shell.task(['npm run generate']));
<commit_msg>Fixed ESLint for browser part<commit_after>'use strict';

// Include gulp
var gulp = require('gulp');
var pkg  = require('./package.json');
var beep = require('beepbeep');
var onError = function() {
  beep();
};

// Include Our Plugins
var eslint     = require('gulp-eslint');
var nodeunit   = require('gulp-nodeunit');
var livereload = require('gulp-livereload');
var plumber    = require('gulp-plumber');
var shell      = require('gulp-shell');
var sass       = require('gulp-sass');
var rename     = require("gulp-rename");
var uglify     = require('gulp-uglify');
var postcss    = require('gulp-postcss');
var autoprefixer = require('autoprefixer');

// Lint Task
gulp.task('eslint', function() {
  return gulp.src(
    [
      '*.js',
      pkg.directories.src+'/**/*.js',
      pkg.directories.test+'/**/*.js'
    ])
    .pipe(plumber({errorHandler: onError}))
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError())
  ;
});

// Node Unit
gulp.task('nodeunit', function() {
  return gulp.src(pkg.directories.test + '/**/*.js')
    .pipe(plumber({errorHandler: onError}))
    .pipe(nodeunit({
      reporter: 'minimal'
    }))
  ;
});

// Lint Task
gulp.task('build-js', function() {
  return gulp.src(
    [
      pkg.directories.theme + '/**/js-src/*.js'
    ])
    .pipe(plumber({errorHandler: onError}))
    .pipe(eslint({
      'env': [
        'browser',
        'jquery'
      ],
      'rules': {
        'strict': [
          2,
          'safe'
        ],
        'curly': 2,
        'no-undef': 2
      }
    }))
    .pipe(eslint.format())
    .pipe(eslint.failAfterError())
    .pipe(uglify({output: {
      max_line_len: 9000
    }}))
    .pipe(rename(function(path){
      path.dirname = path.dirname.replace(/js\-src/, 'js');
      return path;
    }))
    .pipe(gulp.dest(pkg.directories.theme))
  ;
});

// Sass
gulp.task('build-sass', function() {
  return gulp.src(pkg.directories.theme + '/**/*.scss')
    .pipe(plumber({errorHandler: onError}))
    .pipe(sass({outputStyle: 'compact'}).on('error', sass.logError))
    .pipe(postcss([
      autoprefixer({
        browsers: ['last 2 versions', '> 0.5%', 'ie 8-11']
      })
    ]))
    .pipe(rename(function(path){
      path.dirname = path.dirname.replace(/sass/, 'css');
      return path;
    }))
    .pipe(gulp.dest(pkg.directories.theme))
  ;
});

// Watch Files For Changes
gulp.task('watch', function() {
  livereload.listen();
  gulp.watch(['gulpfile.js', 'package.json'], process.exit);
  gulp.watch(['*.js', pkg.directories.src+'/**/*.js', pkg.directories.test+'/**/*.js'], ['test']);
  gulp.watch([pkg.directories.data+'/**/*'],       ['generate']);
  gulp.watch(pkg.directories.theme + '/**/*.js',   ['build-js']);
  gulp.watch(pkg.directories.theme + '/**/*.scss', ['build-sass']);
});

// Default Task
gulp.task('default',     ['eslint', 'nodeunit', 'build-js', 'build-sass']);
gulp.task('test',        ['eslint', 'nodeunit']);
gulp.task('generate',    shell.task(['npm run generate']));
<|endoftext|>


<commit_before>/**
 * @license MIT License
 *
 * Copyright (c) 2015 Tetsuharu OHZEKI <saneyuki.snyk@gmail.com>
 * Copyright (c) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
'use strict';

let babel = require('gulp-babel');
let babelify = require('babelify');
let browserify = require('browserify');
let childProcess = require('child_process');
let concat = require('gulp-concat');
let del = require('del');
let eslint = require('gulp-eslint');
let gulp = require('gulp');
let path = require('path');
let source = require('vinyl-source-stream');
let uglify = require('gulp-uglifyjs');

const isRelease = process.env.NODE_ENV === 'production';

const SRC = [
    'client/js/libs/handlebars.js',
    'client/js/libs/handlebars/**/*.js',
    'client/js/libs/jquery.js',
    'client/js/libs/jquery/**/*.js',
    'client/js/libs/moment.js',
    'client/js/libs/stringcolor.js',
    'client/js/libs/uri.js',
];

const DIST_SERVER = './dist/';
const DIST_CLIENT = './client/dist/';
const DIST_CLIENT_JS = path.resolve(DIST_CLIENT, './js/');

/**
 *  # The rules of task name
 *
 *  ## public task
 *  - This is completed in itself.
 *  - This is callable as `gulp <taskname>`.
 *
 *  ## private task
 *  - This has some sideeffect in dependent task trees
 *    and it cannot recovery by self.
 *  - This is __callable only from public task__.
 *    DONT CALL as `gulp <taskname>`.
 *  - MUST name `__taskname`.
 */

gulp.task('__uglify', ['clean:client'], function () {
    return gulp.src(SRC)
        .pipe(uglify('libs.min.js', {
            compress: false,
        }))
        .pipe(gulp.dest(DIST_CLIENT_JS));
});

gulp.task('__handlebars', ['clean:client'], function () {
    let handlebars = path.relative(__dirname, './node_modules/handlebars/bin/handlebars');
    let args = [
        String(handlebars),
        'client/views/',
        '-e', 'tpl',
        '-f', path.resolve(DIST_CLIENT_JS, './karen.templates.js'),
    ];

    let option = {
        cwd: path.relative(__dirname, ''),
        stdio: 'inherit',
    };
    childProcess.spawn('node', args, option);
});

gulp.task('__browserify', ['clean:client'], function () {
    const SRC_JS = ['./client/js/karen.js'];

    const option = {
        insertGlobals: false,
        debug: isRelease ? false : true,
    };

    const babel = babelify.configure({
        optional: [],
    });

    browserify(SRC_JS, option)
        .transform(babel)
        .bundle()
        .pipe(source('karen.js'))
        .pipe(gulp.dest(DIST_CLIENT_JS));
});

gulp.task('jslint', function () {
    let option = {
        useEslintrc: true,
    };

    return gulp.src([
            './gulpfile.js',
            './client/js/karen.js',
            './client/script/**/*.js',
            './defaults/**/*.js',
            './src/**/*.js',
        ])
        .pipe(eslint(option))
        .pipe(eslint.format())
        .pipe(eslint.failAfterError());
});

gulp.task('__babel:server', ['clean:server'], function () {
    return gulp.src('./src/**/*.js')
        .pipe(babel({
            // For io.js, we need not some transforms:
            blacklist: [
                'es6.blockScoping',
                'es6.constants',
                'es6.forOf',
                'es6.templateLiterals',
            ],
            sourceMaps: false,
        }))
        .pipe(gulp.dest(DIST_SERVER));
});

gulp.task('clean:client', function (callback) {
    return del(path.join(DIST_CLIENT, '**', '*.*'), callback);
});

gulp.task('clean:server', function (callback) {
    return del(path.join(DIST_SERVER, '**', '*.*'), callback);
});

gulp.task('__build:server', ['__babel:server']);
gulp.task('__build:client', ['__handlebars', '__uglify', '__browserify']);

gulp.task('build:server', ['jslint', '__build:server']);
gulp.task('build:client', ['jslint', '__build:client']);
gulp.task('build', ['jslint', '__build:client', '__build:server']);
gulp.task('clean', ['clean:client', 'clean:server']);
gulp.task('default', ['build']);
<commit_msg>Disable 'es6.classes' transform for server.<commit_after>/**
 * @license MIT License
 *
 * Copyright (c) 2015 Tetsuharu OHZEKI <saneyuki.snyk@gmail.com>
 * Copyright (c) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
'use strict';

let babel = require('gulp-babel');
let babelify = require('babelify');
let browserify = require('browserify');
let childProcess = require('child_process');
let concat = require('gulp-concat');
let del = require('del');
let eslint = require('gulp-eslint');
let gulp = require('gulp');
let path = require('path');
let source = require('vinyl-source-stream');
let uglify = require('gulp-uglifyjs');

const isRelease = process.env.NODE_ENV === 'production';

const SRC = [
    'client/js/libs/handlebars.js',
    'client/js/libs/handlebars/**/*.js',
    'client/js/libs/jquery.js',
    'client/js/libs/jquery/**/*.js',
    'client/js/libs/moment.js',
    'client/js/libs/stringcolor.js',
    'client/js/libs/uri.js',
];

const DIST_SERVER = './dist/';
const DIST_CLIENT = './client/dist/';
const DIST_CLIENT_JS = path.resolve(DIST_CLIENT, './js/');

/**
 *  # The rules of task name
 *
 *  ## public task
 *  - This is completed in itself.
 *  - This is callable as `gulp <taskname>`.
 *
 *  ## private task
 *  - This has some sideeffect in dependent task trees
 *    and it cannot recovery by self.
 *  - This is __callable only from public task__.
 *    DONT CALL as `gulp <taskname>`.
 *  - MUST name `__taskname`.
 */

gulp.task('__uglify', ['clean:client'], function () {
    return gulp.src(SRC)
        .pipe(uglify('libs.min.js', {
            compress: false,
        }))
        .pipe(gulp.dest(DIST_CLIENT_JS));
});

gulp.task('__handlebars', ['clean:client'], function () {
    let handlebars = path.relative(__dirname, './node_modules/handlebars/bin/handlebars');
    let args = [
        String(handlebars),
        'client/views/',
        '-e', 'tpl',
        '-f', path.resolve(DIST_CLIENT_JS, './karen.templates.js'),
    ];

    let option = {
        cwd: path.relative(__dirname, ''),
        stdio: 'inherit',
    };
    childProcess.spawn('node', args, option);
});

gulp.task('__browserify', ['clean:client'], function () {
    const SRC_JS = ['./client/js/karen.js'];

    const option = {
        insertGlobals: false,
        debug: isRelease ? false : true,
    };

    const babel = babelify.configure({
        optional: [],
    });

    browserify(SRC_JS, option)
        .transform(babel)
        .bundle()
        .pipe(source('karen.js'))
        .pipe(gulp.dest(DIST_CLIENT_JS));
});

gulp.task('jslint', function () {
    let option = {
        useEslintrc: true,
    };

    return gulp.src([
            './gulpfile.js',
            './client/js/karen.js',
            './client/script/**/*.js',
            './defaults/**/*.js',
            './src/**/*.js',
        ])
        .pipe(eslint(option))
        .pipe(eslint.format())
        .pipe(eslint.failAfterError());
});

gulp.task('__babel:server', ['clean:server'], function () {
    return gulp.src('./src/**/*.js')
        .pipe(babel({
            // For io.js, we need not some transforms:
            blacklist: [
                'es6.blockScoping',
                'es6.classes',
                'es6.constants',
                'es6.forOf',
                'es6.templateLiterals',
            ],
            sourceMaps: false,
        }))
        .pipe(gulp.dest(DIST_SERVER));
});

gulp.task('clean:client', function (callback) {
    return del(path.join(DIST_CLIENT, '**', '*.*'), callback);
});

gulp.task('clean:server', function (callback) {
    return del(path.join(DIST_SERVER, '**', '*.*'), callback);
});

gulp.task('__build:server', ['__babel:server']);
gulp.task('__build:client', ['__handlebars', '__uglify', '__browserify']);

gulp.task('build:server', ['jslint', '__build:server']);
gulp.task('build:client', ['jslint', '__build:client']);
gulp.task('build', ['jslint', '__build:client', '__build:server']);
gulp.task('clean', ['clean:client', 'clean:server']);
gulp.task('default', ['build']);
<|endoftext|>


<commit_before>(function(){
	'use strict';

	var gulp = require('gulp'),
	Merge = require('streamqueue'),
	argv = require('yargs').argv,
	$ = require('gulp-load-plugins')({
		rename: {
			'gulp-sass': 'sass',
			'gulp-minify-css': 'minifycss'
		},
		lazy: false
	});

	/* Combine Sass / Libraries */
	gulp.task('styles', function() {
		var style = gulp.src('src/scss/*.scss');

		return style
			.pipe($.sass({ outputStyle: 'compressed', errLogToConsole: true }))
			.pipe($.autoprefixer({ browsers: ['last 2 version'] }))
			.pipe($.if(argv.prod, $.minifycss()))
			.pipe(gulp.dest('dist/css'))
			.pipe($.notify({ message: 'Styles Task Completed' }));
	});

	/* Main Script / Libraries */
	gulp.task('scripts-main', function() {
		var libs = libs = gulp.src(['src/js/play-midnight-*', '!src/js/play-midnight-utils.js', '!src/js/play-midnight.js']),
			utils = gulp.src('src/js/play-midnight-utils.js'),
			script = gulp.src('src/js/play-midnight.js'),
			merged;

		merged = new Merge({ objectMode: true });
		merged.queue(utils);
		merged.queue(libs);
		merged.queue(script);

		return merged.done()
			.pipe($.jshint())
			.pipe($.jshint.reporter('default'))
			.pipe($.concat('play-midnight.js'))
			.pipe($.if(argv.prod, $.uglify()))
			.pipe(gulp.dest('dist/js'))
			.pipe($.notify({ message: 'Main Scripts Task Completed' }));
	});

	/* Background Script */
	gulp.task('scripts-bg', function() {
		var script = gulp.src('src/js/background.js');

		return script
		.pipe($.jshint())
		.pipe($.jshint.reporter('default'))
		.pipe($.if(argv.prod, $.uglify()))
		.pipe(gulp.dest('dist/js'))
		.pipe($.notify({ message: 'Background Scripts Task Completed' }));
	});

	/* Images Script */
	gulp.task('images', function() {
		var images = gulp.src('src/images/**/*');

		return images
		.pipe(gulp.dest('dist/images'))
		.pipe($.notify({ message: 'Images Task Completed' }));
	});

	/* HTML Script */
	gulp.task('html', function() {
		var html = gulp.src('src/**/*.html');

		return html
		.pipe(gulp.dest('dist'))
		.pipe($.notify({ message: 'HTML Task Completed' }));
	});

	/* Watch File Changes */
	gulp.task('watch', function() {
		gulp.watch('src/scss/**/*.scss', ['styles']);
		gulp.watch('src/js/**/play-midnight*.js', ['scripts-main']);
		gulp.watch('src/js/**/background.js', ['scripts-bg']);
		gulp.watch('src/images/**/*', ['images']);
		gulp.watch('src/**/*.html', ['html']);
	});

	/* Default Task */
	gulp.task('default', function() {
		gulp.start('styles', 'scripts-main', 'scripts-bg', 'images', 'html');
	});
}());
<commit_msg>Fix lib issue<commit_after>(function(){
	'use strict';

	var gulp = require('gulp'),
	Merge = require('streamqueue'),
	argv = require('yargs').argv,
	$ = require('gulp-load-plugins')({
		rename: {
			'gulp-sass': 'sass',
			'gulp-minify-css': 'minifycss'
		},
		lazy: false
	});

	/* Combine Sass / Libraries */
	gulp.task('styles', function() {
		var style = gulp.src('src/scss/*.scss');

		return style
			.pipe($.sass({ outputStyle: 'compressed', errLogToConsole: true }))
			.pipe($.autoprefixer({ browsers: ['last 2 version'] }))
			.pipe($.if(argv.prod, $.minifycss()))
			.pipe(gulp.dest('dist/css'))
			.pipe($.notify({ message: 'Styles Task Completed' }));
	});

	/* Main Script / Libraries */
	gulp.task('scripts-main', function() {
		var libs = gulp.src(['src/js/play-midnight-*', '!src/js/play-midnight-utils.js', '!src/js/play-midnight.js']),
			utils = gulp.src('src/js/play-midnight-utils.js'),
			script = gulp.src('src/js/play-midnight.js'),
			merged;

		merged = new Merge({ objectMode: true });
		merged.queue(utils);
		merged.queue(libs);
		merged.queue(script);

		return merged.done()
			.pipe($.jshint())
			.pipe($.jshint.reporter('default'))
			.pipe($.concat('play-midnight.js'))
			.pipe($.if(argv.prod, $.uglify()))
			.pipe(gulp.dest('dist/js'))
			.pipe($.notify({ message: 'Main Scripts Task Completed' }));
	});

	/* Background Script */
	gulp.task('scripts-bg', function() {
		var script = gulp.src('src/js/background.js');

		return script
		.pipe($.jshint())
		.pipe($.jshint.reporter('default'))
		.pipe($.if(argv.prod, $.uglify()))
		.pipe(gulp.dest('dist/js'))
		.pipe($.notify({ message: 'Background Scripts Task Completed' }));
	});

	/* Images Script */
	gulp.task('images', function() {
		var images = gulp.src('src/images/**/*');

		return images
		.pipe(gulp.dest('dist/images'))
		.pipe($.notify({ message: 'Images Task Completed' }));
	});

	/* HTML Script */
	gulp.task('html', function() {
		var html = gulp.src('src/**/*.html');

		return html
		.pipe(gulp.dest('dist'))
		.pipe($.notify({ message: 'HTML Task Completed' }));
	});

	/* Watch File Changes */
	gulp.task('watch', function() {
		gulp.watch('src/scss/**/*.scss', ['styles']);
		gulp.watch('src/js/**/play-midnight*.js', ['scripts-main']);
		gulp.watch('src/js/**/background.js', ['scripts-bg']);
		gulp.watch('src/images/**/*', ['images']);
		gulp.watch('src/**/*.html', ['html']);
	});

	/* Default Task */
	gulp.task('default', function() {
		gulp.start('styles', 'scripts-main', 'scripts-bg', 'images', 'html');
	});
}());
<|endoftext|>


<commit_before>const gulp = require('gulp');
const fs = require('fs');
const util = require('gulp-util');
const merge = require('merge-stream');
const exec = require('child_process').exec;
const sass = require('gulp-sass');
const postcss = require('gulp-postcss');
const cssnano = require('cssnano');
const browserSync = require('browser-sync').create();
const concat = require('gulp-concat');
const imageResize = require('gulp-image-resize');

gulp.task('scripts:games', function (callback) {
  exec(`cd ./scripts/games/ && yarn install && node app.js`, function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    callback(err);
  });
});

gulp.task('scripts:twitter', function (callback) {
  exec(`cd ./scripts/twitter/ && yarn install && node app.js`, function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    callback(err);
  });
});

gulp.task('scripts:wiki', function (callback) {
  exec(`cd ./scripts/wiki/ && yarn install && node app.js`, function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    callback(err);
  });
});

gulp.task('assets:images', function() {
  var baseImages = gulp.src(`build/images/*`, {base: './'})
      .pipe(gulp.dest('./'));
  var jumbotronImages = gulp.src(`build/images/jumbotron/*`, {base: './'})
      .pipe(imageResize({ width: 786, height: 471, crop: true }))
      .pipe(gulp.dest('./'));
  var bannerImages = gulp.src(`build/images/banners/*`, {base: './'})
      .pipe(imageResize({ width: 824, height: 306, crop: false }))
      .pipe(gulp.dest('./'));
  var boxartImages = gulp.src(`build/images/game/boxart/*`, {base: './'})
      .pipe(imageResize({ width: 328, height: 300, crop: true }))
      .pipe(gulp.dest('./'));
  var iconImages = gulp.src(`build/images/game/icons/*`, {base: './'})
      .pipe(imageResize({ width: 48, height: 48, crop: true }))
      .pipe(gulp.dest('./'));
  var screenshotImages = gulp.src(`build/images/screenshots/*`)
      .pipe(imageResize({ width: 400, height: 240, crop: false }))
      .pipe(gulp.dest(`build/images/screenshots/thumbs`));
  return merge(baseImages, jumbotronImages, bannerImages, boxartImages, iconImages, screenshotImages);
});

gulp.task('assets:js', function() {
  return gulp.src(['src/js/**/*.js'])
    .pipe(concat('script.js'))
    .pipe(gulp.dest('build/js'));
});

gulp.task('assets:fonts', function(){
  return gulp.src('./node_modules/bootstrap-sass/assets/fonts/**/*')
    .pipe(gulp.dest('build/fonts/'))
});

gulp.task('assets:scss', function () {
  var postCssOptions = [ cssnano ];
  return gulp.src('src/scss/style.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(postcss(postCssOptions))
    .pipe(gulp.dest('build/css'))
    .pipe(browserSync.stream());
});

gulp.task('hugo', function (cb) {
  exec('hugo -s ./site/ -d ../build/ -v', function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    cb(err);
  });
});

gulp.task('final:serve', function() {
    browserSync.init({
        open: false,
        server: {
            baseDir: 'build'
        }
    });

    gulp.watch('src/js/**/*', gulp.series('assets:js'));
    gulp.watch('src/scss/**/*', gulp.series('assets:scss'));
    gulp.watch('site/**/*.html', gulp.series('hugo'));
    gulp.watch('site/**/*.md', gulp.series('hugo'));

    gulp.watch('build/**/*').on('change', function() {
      browserSync.reload(x);
    });
});

gulp.task('final:publish', function(){
  fs.writeFileSync(`build/CNAME`, `${cname}`);
  fs.writeFileSync(`build/robots.txt`, `Sitemap: https://${cname}/sitemap.xml\n\nUser-agent: *`);
});

const cname = 'citra-emu.org';
var finalCommand = null;

if (util.env.production) {
  process.env.HUGO_ENV = 'PRD';
  process.env.HUGO_BASEURL = `https://${cname}`
  finalCommand = 'final:publish';
} else {
  process.env.HUGO_ENV = 'DEV';
  process.env.HUGO_BASEURL = 'http://localhost:3000';
  finalCommand = 'final:serve';
}

util.log(`process.env.HUGO_ENV = '${process.env.HUGO_ENV}'`);
util.log(`process.env.HUGO_BASEURL = '${process.env.HUGO_BASEURL}'`);

gulp.task('default', gulp.series(gulp.parallel('assets:js', 'assets:fonts', 'assets:scss'), 'hugo', 'assets:images', finalCommand))
gulp.task('all', gulp.series(gulp.parallel('scripts:games', 'scripts:twitter', 'scripts:wiki'), gulp.parallel('assets:js', 'assets:fonts', 'assets:scss'), 'hugo', 'assets:images', finalCommand))
gulp.task('content', gulp.series('hugo', finalCommand));<commit_msg>Updated callbacks for gulp.<commit_after>const gulp = require('gulp');
const fs = require('fs');
const util = require('gulp-util');
const merge = require('merge-stream');
const exec = require('child_process').exec;
const sass = require('gulp-sass');
const postcss = require('gulp-postcss');
const cssnano = require('cssnano');
const browserSync = require('browser-sync').create();
const concat = require('gulp-concat');
const imageResize = require('gulp-image-resize');

gulp.task('scripts:games', function (callback) {
  exec(`cd ./scripts/games/ && yarn install && node app.js`, function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    callback(err);
  });
});

gulp.task('scripts:twitter', function (callback) {
  exec(`cd ./scripts/twitter/ && yarn install && node app.js`, function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    callback(err);
  });
});

gulp.task('scripts:wiki', function (callback) {
  exec(`cd ./scripts/wiki/ && yarn install && node app.js`, function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    callback(err);
  });
});

gulp.task('assets:images', function() {
  var baseImages = gulp.src(`build/images/*`, {base: './'})
      .pipe(gulp.dest('./'));
  var jumbotronImages = gulp.src(`build/images/jumbotron/*`, {base: './'})
      .pipe(imageResize({ width: 786, height: 471, crop: true }))
      .pipe(gulp.dest('./'));
  var bannerImages = gulp.src(`build/images/banners/*`, {base: './'})
      .pipe(imageResize({ width: 824, height: 306, crop: false }))
      .pipe(gulp.dest('./'));
  var boxartImages = gulp.src(`build/images/game/boxart/*`, {base: './'})
      .pipe(imageResize({ width: 328, height: 300, crop: true }))
      .pipe(gulp.dest('./'));
  var iconImages = gulp.src(`build/images/game/icons/*`, {base: './'})
      .pipe(imageResize({ width: 48, height: 48, crop: true }))
      .pipe(gulp.dest('./'));
  var screenshotImages = gulp.src(`build/images/screenshots/*`)
      .pipe(imageResize({ width: 400, height: 240, crop: false }))
      .pipe(gulp.dest(`build/images/screenshots/thumbs`));

  return merge(baseImages, jumbotronImages, bannerImages, boxartImages, iconImages, screenshotImages);
});

gulp.task('assets:js', function() {
  return gulp.src(['src/js/**/*.js'])
    .pipe(concat('script.js'))
    .pipe(gulp.dest('build/js'));
});

gulp.task('assets:fonts', function(){
  return gulp.src('./node_modules/bootstrap-sass/assets/fonts/**/*')
    .pipe(gulp.dest('build/fonts/'))
});

gulp.task('assets:scss', function () {
  var postCssOptions = [ cssnano ];
  return gulp.src('src/scss/style.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(postcss(postCssOptions))
    .pipe(gulp.dest('build/css'))
    .pipe(browserSync.stream());
});

gulp.task('hugo', function (cb) {
  exec('hugo -s ./site/ -d ../build/ -v', function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    cb(err);
  });
});

gulp.task('final:serve', function(done) {
    browserSync.init({
        open: false,
        server: {
            baseDir: 'build'
        }
    });

    gulp.watch('src/js/**/*', gulp.series('assets:js'));
    gulp.watch('src/scss/**/*', gulp.series('assets:scss'));
    gulp.watch('site/**/*.html', gulp.series('hugo'));
    gulp.watch('site/**/*.md', gulp.series('hugo'));

    gulp.watch('build/**/*').on('change', function() {
      browserSync.reload(x);
    });

    done()
});

gulp.task('final:publish', function(done) {
  fs.writeFileSync(`build/CNAME`, `${cname}`);
  fs.writeFileSync(`build/robots.txt`, `Sitemap: https://${cname}/sitemap.xml\n\nUser-agent: *`);
  done()
});

const cname = 'citra-emu.org';
var finalCommand = null;

if (util.env.production) {
  process.env.HUGO_ENV = 'PRD';
  process.env.HUGO_BASEURL = `https://${cname}`
  finalCommand = 'final:publish';
} else {
  process.env.HUGO_ENV = 'DEV';
  process.env.HUGO_BASEURL = 'http://localhost:3000';
  finalCommand = 'final:serve';
}

util.log(`process.env.HUGO_ENV = '${process.env.HUGO_ENV}'`);
util.log(`process.env.HUGO_BASEURL = '${process.env.HUGO_BASEURL}'`);

gulp.task('default', gulp.series(gulp.parallel('assets:js', 'assets:fonts', 'assets:scss'), 'hugo', 'assets:images', finalCommand))
gulp.task('all', gulp.series(gulp.parallel('scripts:games', 'scripts:twitter', 'scripts:wiki'), gulp.parallel('assets:js', 'assets:fonts', 'assets:scss'), 'hugo', 'assets:images', finalCommand))
gulp.task('content', gulp.series('hugo', finalCommand));<|endoftext|>


<commit_before>// @ts-nocheck
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var cleanCSS = require('gulp-clean-css');
var header = require('gulp-header');
var notify = require('gulp-notify');
var pkg = require('./package.json');
var realFavicon = require ('gulp-real-favicon');
var rename = require("gulp-rename");
// var responsive-images-generator = require('gulp-responsive-images-generator');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var fs = require('fs');

// Set the banner content
var banner = ['/*!\n',
' * https://www.adamjolicoeur.com\n',
' * <%= pkg.title %> v<%= pkg.version %>\n',
' * Copyright 2008-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
' * Licensed under <%= pkg.license %>\n',
' */\n',
''
].join('');

// File where the favicon markups are stored
var FAVICON_DATA_FILE = 'faviconData.json';

// Generate the icons. This task takes a few seconds to complete.
// You should run it at least once to create the icons. Then,
// you should run it whenever RealFaviconGenerator updates its
// package (see the check-for-favicon-update task below).
gulp.task('generate-favicon', function(done) {
  realFavicon.generateFavicon({
    masterPicture: 'img/master_picture.png',
    dest: 'img/',
    iconsPath: '/img',
    design: {
      ios: {
        pictureAspect: 'noChange',
        assets: {
          ios6AndPriorIcons: false,
          ios7AndLaterIcons: false,
          precomposedIcons: false,
          declareOnlyDefaultIcon: true
        }
      },
      desktopBrowser: {},
      windows: {
        pictureAspect: 'noChange',
        backgroundColor: '#2b5797',
        onConflict: 'override',
        assets: {
          windows80Ie10Tile: true,
          windows10Ie11EdgeTiles: {
            small: false,
            medium: true,
            big: false,
            rectangle: false
          }
        }
      },
      androidChrome: {
        pictureAspect: 'noChange',
        themeColor: '#ffffff',
        manifest: {
          display: 'standalone',
          orientation: 'notSet',
          onConflict: 'override',
          declared: true
        },
        assets: {
          legacyIcon: false,
          lowResolutionIcons: false
        }
      },
      safariPinnedTab: {
        pictureAspect: 'silhouette',
        themeColor: '#5bbad5'
      }
    },
    settings: {
      scalingAlgorithm: 'Mitchell',
      errorOnImageTooSmall: false,
      readmeFile: false,
      htmlCodeFile: false,
      usePathAsIs: false
    },
    versioning: {
      paramName: 'v',
      paramValue: 'YAoMBnzn4g'
    },
    markupFile: FAVICON_DATA_FILE
  }, function() {
    done();
  });
});

// Inject the favicon markups in your HTML pages. You should run
// this task whenever you modify a page. You can keep this task
// as is or refactor your existing HTML pipeline.
gulp.task('inject-favicon-markups', function() {
  return gulp.src([ '/index.html' ])
    .pipe(realFavicon.injectFaviconMarkups(JSON.parse(fs.readFileSync(FAVICON_DATA_FILE)).favicon.html_code))
    .pipe(gulp.dest('/'));
});

// Check for updates on RealFaviconGenerator (think: Apple has just
// released a new Touch icon along with the latest version of iOS).
// Run this task from time to time. Ideally, make it part of your
// continuous integration system.
gulp.task('check-for-favicon-update', function(done) {
  var currentVersion = JSON.parse(fs.readFileSync(FAVICON_DATA_FILE)).version;
  realFavicon.checkForUpdates(currentVersion, function(err) {
    if (err) {
      throw err;
    }
  });
});

gulp.task('sass', function() {
  return gulp.src("dev/sass/*.scss")
  .pipe(sass().on('error', sass.logError))
  .pipe(header(banner, { pkg: pkg }))
  .pipe(sourcemaps.init())
  .pipe(cleanCSS({
    level: {
      2: {
        removeDuplicateRules: true // turns on removing duplicate rules
      }
    },
    compatibility: "*"
  }))
  .pipe(sourcemaps.write())
  .pipe(rename({ suffix: '.min' }))
  .pipe(gulp.dest('css'))
  .pipe(browserSync.reload({
    stream: true
  }));
});

// Minify JS
gulp.task('javascript', function() {
  return gulp.src('dev/js/jolicoeur.js')
  .pipe(uglify())
  .pipe(header(banner, { pkg: pkg }))
  .pipe(rename({ suffix: '.min' }))
  .pipe(gulp.dest('js'))
  .pipe(browserSync.reload({
    stream: true
  }));
});

// Copy vendor libraries from /node_modules into /vendor
gulp.task('copy', function() {
  gulp.src(['node_modules/bootstrap/dist/**/*', '!**/npm.js', '!**/bootstrap-theme.*', '!**/*.map'])
  .pipe(gulp.dest('dev/vendor/bootstrap'));

  gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js'])
  .pipe(gulp.dest('dev/vendor/jquery'));
});

// Configure the browserSync task
gulp.task('browserSync', function() {
  browserSync.init({
    server: {
      baseDir: ''
    },
  });
});

// ensure js finishes, reload browser
gulp.task('js-watch', ['javascript'], function (done) {
  browserSync.reload();
  done();
});

// ensure sass finishes, reload browser
gulp.task('sass-watch', ['sass'], function (done) {
  browserSync.reload();
  done();
});

// Dev task with browserSync
gulp.task('serve', ['sass', 'javascript', 'inject-favicon-markups'], function () {
  browserSync.init({
    server: {
      baseDir: "./"
    }
  });
  gulp.watch('dev/js/*.js', ['js-watch']);
  gulp.watch('dev/sass/*.scss', ['sass-watch']);
  gulp.watch('*.html').on('change', browserSync.reload);
});

// Run everything
gulp.task('default', ['javascript', 'sass', 'copy']);
<commit_msg>update browserSync task<commit_after>// @ts-nocheck
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var cleanCSS = require('gulp-clean-css');
var header = require('gulp-header');
var notify = require('gulp-notify');
var pkg = require('./package.json');
var realFavicon = require ('gulp-real-favicon');
var rename = require("gulp-rename");
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var fs = require('fs');

// Set the banner content
var banner = ['/*!\n',
' * https://www.adamjolicoeur.com\n',
' * <%= pkg.title %> v<%= pkg.version %>\n',
' * Copyright 2008-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
' * Licensed under <%= pkg.license %>\n',
' */\n',
''
].join('');

// File where the favicon markups are stored
var FAVICON_DATA_FILE = 'faviconData.json';

// Generate the icons. This task takes a few seconds to complete.
// You should run it at least once to create the icons. Then,
// you should run it whenever RealFaviconGenerator updates its
// package (see the check-for-favicon-update task below).
gulp.task('generate-favicon', function(done) {
  realFavicon.generateFavicon({
    masterPicture: 'img/master_picture.png',
    dest: 'img/',
    iconsPath: '/img',
    design: {
      ios: {
        pictureAspect: 'noChange',
        assets: {
          ios6AndPriorIcons: false,
          ios7AndLaterIcons: false,
          precomposedIcons: false,
          declareOnlyDefaultIcon: true
        }
      },
      desktopBrowser: {},
      windows: {
        pictureAspect: 'noChange',
        backgroundColor: '#2b5797',
        onConflict: 'override',
        assets: {
          windows80Ie10Tile: true,
          windows10Ie11EdgeTiles: {
            small: false,
            medium: true,
            big: false,
            rectangle: false
          }
        }
      },
      androidChrome: {
        pictureAspect: 'noChange',
        themeColor: '#ffffff',
        manifest: {
          display: 'standalone',
          orientation: 'notSet',
          onConflict: 'override',
          declared: true
        },
        assets: {
          legacyIcon: false,
          lowResolutionIcons: false
        }
      },
      safariPinnedTab: {
        pictureAspect: 'silhouette',
        themeColor: '#5bbad5'
      }
    },
    settings: {
      scalingAlgorithm: 'Mitchell',
      errorOnImageTooSmall: false,
      readmeFile: false,
      htmlCodeFile: false,
      usePathAsIs: false
    },
    versioning: {
      paramName: 'v',
      paramValue: 'YAoMBnzn4g'
    },
    markupFile: FAVICON_DATA_FILE
  }, function() {
    done();
  });
});

// Inject the favicon markups in your HTML pages. You should run
// this task whenever you modify a page. You can keep this task
// as is or refactor your existing HTML pipeline.
gulp.task('inject-favicon-markups', function() {
  return gulp.src([ '/index.html' ])
    .pipe(realFavicon.injectFaviconMarkups(JSON.parse(fs.readFileSync(FAVICON_DATA_FILE)).favicon.html_code))
    .pipe(gulp.dest('/'));
});

// Check for updates on RealFaviconGenerator
// Run this task from time to time. Ideally, make it part of your
// continuous integration system.
gulp.task('check-for-favicon-update', function(done) {
  var currentVersion = JSON.parse(fs.readFileSync(FAVICON_DATA_FILE)).version;
  realFavicon.checkForUpdates(currentVersion, function(err) {
    if (err) {
      throw err;
    }
  });
});

gulp.task('sass', function() {
  return gulp.src("dev/sass/*.scss")
  .pipe(sass().on('error', sass.logError))
  .pipe(header(banner, { pkg: pkg }))
  .pipe(sourcemaps.init())
  .pipe(cleanCSS({
    level: {
      2: {
        removeDuplicateRules: true
      }
    },
    compatibility: "*"
  }))
  .pipe(sourcemaps.write())
  .pipe(rename({ suffix: '.min' }))
  .pipe(gulp.dest('css'))
  .pipe(browserSync.reload({
    stream: true
  }));
});

// Minify JS
gulp.task('javascript', function() {
  return gulp.src('dev/js/jolicoeur.js')
  .pipe(uglify())
  .pipe(header(banner, { pkg: pkg }))
  .pipe(rename({ suffix: '.min' }))
  .pipe(gulp.dest('js'))
  .pipe(browserSync.reload({
    stream: true
  }));
});

// Copy vendor libraries from /node_modules into /vendor
gulp.task('copy', function() {
  gulp.src(['node_modules/bootstrap/dist/**/*', '!**/npm.js', '!**/bootstrap-theme.*', '!**/*.map'])
    .pipe(gulp.dest('dev/vendor/bootstrap'));
  gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js'])
    .pipe(gulp.dest('dev/vendor/jquery'));
});

// Configure the browserSync task
gulp.task('browserSync', function() {
  browserSync.init({
    server: {
      baseDir: ''
    },
    ui: {
      port: 8001 // customize port for browserSync UI
    },
    port: 8080, // use 8080 to prevent conflicts with other localhosts
    reloadOnRestart: true,
    notify: false // prevent the browserSync notification from appearing
  });
});

// ensure js finishes, reload browser
gulp.task('js-watch', ['javascript'], function (done) {
  browserSync.reload();
  done();
});

// ensure sass finishes, reload browser
gulp.task('sass-watch', ['sass'], function (done) {
  browserSync.reload();
  done();
});

// Dev task with browserSync
gulp.task('serve', ['sass', 'javascript', 'inject-favicon-markups'], function () {
  browserSync.init({
    server: {
      baseDir: "./"
    },
    ui: {
      port: 8001 // customize port for browserSync UI
    },
    port: 8080, // use 8080 to prevent conflicts with other localhosts
    reloadOnRestart: true,
    notify: false // prevent the browserSync notification from appearing
  });
  gulp.watch('dev/js/*.js', ['js-watch']);
  gulp.watch('dev/sass/*.scss', ['sass-watch']);
  gulp.watch('*.html').on('change', browserSync.reload);
});

gulp.task('default', ['javascript', 'sass', 'copy']);
<|endoftext|>


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

 Build Configuration
 Contributors: Luan Gjokaj

 ------------------------------------------------------------------------------------------------ */
var gulp = require('gulp');
var gutil = require('gulp-util');
var connect = require('gulp-connect-php');
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var postcss = require('gulp-postcss');
var cssnext = require('postcss-cssnext');
var partialimport = require('postcss-easy-import');
var sourcemaps = require('gulp-sourcemaps');
var cssnano = require('cssnano');
var plumber = require('gulp-plumber');
var htmlmin = require('gulp-htmlmin');
var babel = require("gulp-babel");

gulp.task('build-dev', [
    'style-dev',
    'copy-images',
    'copy-fonts',
    'footer-scripts-dev',
    'process-php',
    'connect-sync',
    'watch'
]);

gulp.task('build-prod', [
    'style-prod',
    'copy-images',
    'copy-fonts',
    'footer-scripts-prod',
    'process-images',
    'process-php'
]);

gulp.task('default');

var footerJS = [
    'node_modules/jquery/dist/jquery.js',
    'src/assets/js/main.js'
];

var onError = function (err) {
    gutil.beep();
    console.log(err.toString());
    this.emit('end');
};

gulp.task('connect-sync', function () {
    connect.server({
        base: 'app',
        port: '8020'
    }, function () {
        browserSync({
            proxy: '127.0.0.1:8020'
        });
    });
});

gulp.task('copy-php', function () {
    return gulp
        .src(['src/*.php'])
        .pipe(gulp.dest('app'))
        .pipe(browserSync.stream());
});

gulp.task('process-php', function () {
    return gulp.src(['src/*.html', 'src/*.php'])
        .pipe(htmlmin({
            collapseWhitespace: true,
            ignoreCustomFragments: [/<%[\s\S]*?%>/, /<\?[=|php]?[\s\S]*?\?>/]
        }))
        .pipe(gulp.dest('app'));
});

gulp.task('footer-scripts-dev', function () {
    return gulp.src(footerJS)
        .pipe(sourcemaps.init())
        .pipe(plumber({ errorHandler: onError }))
        .pipe(babel({
            presets: ['env']
        }))
        .pipe(concat('bundle.js'))
        .pipe(sourcemaps.write("."))
        .pipe(gulp.dest('app/assets/js'))
        .pipe(browserSync.stream());
});

gulp.task('footer-scripts-prod', function () {
    return gulp.src(footerJS)
        .pipe(plumber({ errorHandler: onError }))
        .pipe(babel({
            presets: ['env']
        }))
        .pipe(concat('bundle.js'))
        .pipe(uglify())
        .pipe(sourcemaps.write("."))
        .pipe(gulp.dest('app/assets/js'))
});

gulp.task('copy-fonts', function () {
    return gulp
        .src('src/assets/fonts/**')
        .pipe(gulp.dest('app/assets/fonts'))
        .pipe(browserSync.stream());
});

gulp.task('copy-images', function () {
    return gulp
        .src('src/assets/img/**')
        .pipe(gulp.dest('app/assets/img'))
        .pipe(browserSync.stream());
});

gulp.task('process-images', function (cb) {
    return gulp
        .src('src/assets/img/**')
        .pipe(imagemin())
        .pipe(gulp.dest('app/assets/img'))
});

var plugins = [
    partialimport,
    cssnext({}),
    cssnano()
];

gulp.task('style-dev', function () {
    return gulp.src('src/assets/style/main.css')
        .pipe(sourcemaps.init())
        .pipe(postcss(plugins))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('app/assets/css'))
        .pipe(browserSync.stream());
});

gulp.task('style-prod', function () {
    return gulp.src('src/assets/style/main.css')
        .pipe(postcss(plugins))
        .pipe(gulp.dest('app/assets/css'));
});

gulp.task('watch', function () {
    gulp.watch(['src/assets/style/*.css'], ['style-dev']);
    gulp.watch(['src/assets/js/*'], ['footer-scripts-dev']);
    gulp.watch(['src/assets/img/*'], ['copy-images']);
    gulp.watch(['src/assets/fonts/*'], ['copy-fonts']);
    gulp.watch(['src/*.php'], ['copy-php']);
});
<commit_msg>Cleanup. Error handling for all tasks.<commit_after>/* -------------------------------------------------------------------------------------------------

 Build Configuration
 Contributors: Luan Gjokaj

 ------------------------------------------------------------------------------------------------ */
var gulp = require('gulp');
var gutil = require('gulp-util');
var connect = require('gulp-connect-php');
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var postcss = require('gulp-postcss');
var cssnext = require('postcss-cssnext');
var partialimport = require('postcss-easy-import');
var sourcemaps = require('gulp-sourcemaps');
var cssnano = require('cssnano');
var plumber = require('gulp-plumber');
var htmlmin = require('gulp-htmlmin');
var babel = require("gulp-babel");

gulp.task('build-dev', [
    'style-dev',
    'copy-images',
    'copy-fonts',
    'footer-scripts-dev',
    'process-php',
    'connect-sync',
    'watch'
]);

gulp.task('build-prod', [
    'style-prod',
    'copy-images',
    'copy-fonts',
    'footer-scripts-prod',
    'process-images',
    'process-php'
]);

gulp.task('default');

var footerJS = [
    'node_modules/jquery/dist/jquery.js',
    'src/assets/js/main.js'
];

var onError = function (err) {
    gutil.beep();
    console.log(err.toString());
    this.emit('end');
};

gulp.task('connect-sync', function () {
    connect.server({
        base: 'app',
        port: '8020'
    }, function () {
        browserSync({
            proxy: '127.0.0.1:8020'
        });
    });
});

gulp.task('copy-php', function () {
    return gulp.src(['src/*.php'])
        .pipe(plumber({ errorHandler: onError }))
        .pipe(gulp.dest('app'))
        .pipe(browserSync.stream());
});

gulp.task('process-php', function () {
    return gulp.src(['src/*.html', 'src/*.php'])
        .pipe(plumber({ errorHandler: onError }))
        .pipe(htmlmin({
            collapseWhitespace: true,
            ignoreCustomFragments: [/<%[\s\S]*?%>/, /<\?[=|php]?[\s\S]*?\?>/]
        }))
        .pipe(gulp.dest('app'));
});

gulp.task('footer-scripts-dev', function () {
    return gulp.src(footerJS)
        .pipe(plumber({ errorHandler: onError }))
        .pipe(sourcemaps.init())
        .pipe(babel({
            presets: ['env']
        }))
        .pipe(concat('bundle.js'))
        .pipe(sourcemaps.write("."))
        .pipe(gulp.dest('app/assets/js'))
        .pipe(browserSync.stream());
});

gulp.task('footer-scripts-prod', function () {
    return gulp.src(footerJS)
        .pipe(plumber({ errorHandler: onError }))
        .pipe(babel({
            presets: ['env']
        }))
        .pipe(concat('bundle.js'))
        .pipe(uglify())
        .pipe(sourcemaps.write("."))
        .pipe(gulp.dest('app/assets/js'))
});

gulp.task('copy-fonts', function () {
    return gulp.src('src/assets/fonts/**')
        .pipe(plumber({ errorHandler: onError }))
        .pipe(gulp.dest('app/assets/fonts'))
        .pipe(browserSync.stream());
});

gulp.task('copy-images', function () {
    return gulp.src('src/assets/img/**')
        .pipe(plumber({ errorHandler: onError }))
        .pipe(gulp.dest('app/assets/img'))
        .pipe(browserSync.stream());
});

gulp.task('process-images', function (cb) {
    return gulp.src('src/assets/img/**')
        .pipe(plumber({ errorHandler: onError }))
        .pipe(imagemin())
        .pipe(gulp.dest('app/assets/img'))
});

var plugins = [
    partialimport,
    cssnext({}),
    cssnano()
];

gulp.task('style-dev', function () {
    return gulp.src('src/assets/style/main.css')
        .pipe(plumber({ errorHandler: onError }))
        .pipe(sourcemaps.init())
        .pipe(postcss(plugins))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('app/assets/css'))
        .pipe(browserSync.stream());
});

gulp.task('style-prod', function () {
    return gulp.src('src/assets/style/main.css')
        .pipe(plumber({ errorHandler: onError }))
        .pipe(postcss(plugins))
        .pipe(gulp.dest('app/assets/css'));
});

gulp.task('watch', function () {
    gulp.watch(['src/assets/style/*.css'], ['style-dev']);
    gulp.watch(['src/assets/js/*'], ['footer-scripts-dev']);
    gulp.watch(['src/assets/img/*'], ['copy-images']);
    gulp.watch(['src/assets/fonts/*'], ['copy-fonts']);
    gulp.watch(['src/*.php'], ['copy-php']);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var mocha = require('gulp-spawn-mocha');
var coverage = require('gulp-coverage');
var minimist = require('minimist');

var options = minimist(process.argv.slice(2));

gulp.task('test', function () {
  options.reporter = 'min';
  options.debugBrk = options.debug ? 'debug' : undefined;

  var sources = ['spec/config.js', 'app/**/*.spec.js'];

  return gulp
    .src(sources)
    .pipe(mocha(options));
});<commit_msg>added istanbul for code coverage<commit_after>var gulp = require('gulp');
var mocha = require('gulp-spawn-mocha');
var coverage = require('gulp-coverage');
var minimist = require('minimist');

var options = minimist(process.argv.slice(2));

gulp.task('test', function () {
  options.reporter = 'min';
  options.istanbul = true;
  options.debugBrk = options.debug ? 'debug' : undefined;

  var sources = ['spec/config.js', 'app/**/*.spec.js'];

  return gulp
    .src(sources)
    .pipe(mocha(options));
});<|endoftext|>