<commit_before>'use strict';

var gulp = require('gulp');
var liferay = require('liferay-gulp-tasks');
var metal = require('gulp-metal');
var runSequence = require('run-sequence');
var utils = require('./utils');

liferay.registerTasks();

metal.registerTasks({
	buildSrc: utils.getComponentPaths('src'),
	bundleFileName: 'metal.js',
	cssSrc: 'node_modules/metal-*/src/**/*.css',
	scssSrc: 'node_modules/metal-*/src/**/*.scss'
});

gulp.task('soy:copy', function() {
	return gulp.src('node_modules/metal-*/src/**/*.soy')
		.pipe(gulp.dest('build/soy'));
});

gulp.task('default', function(done) {
	runSequence(
		'clean',
		['css', 'build:globals', 'build:amd', 'build:amd:jquery', 'soy:copy'],
		'uglify',
		done
	);
});
<commit_msg>Fixes karma tests<commit_after>'use strict';

var gulp = require('gulp');
var karma = require('karma');
var liferay = require('liferay-gulp-tasks');
var metal = require('gulp-metal');
var runSequence = require('run-sequence');
var utils = require('./utils');

liferay.registerTasks();

metal.registerTasks({
	buildSrc: utils.getComponentPaths('src'),
	bundleFileName: 'metal.js',
	cssSrc: 'node_modules/metal-*/src/**/*.css',
	karma: karma,
	scssSrc: 'node_modules/metal-*/src/**/*.scss'
});

gulp.task('soy:copy', function() {
	return gulp.src('node_modules/metal-*/src/**/*.soy')
		.pipe(gulp.dest('build/soy'));
});

gulp.task('default', function(done) {
	runSequence(
		'clean',
		['css', 'build:globals', 'build:amd', 'build:amd:jquery', 'soy:copy'],
		'uglify',
		done
	);
});
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    gutil = require('gulp-util'),
    bump = require('gulp-bump'),
    git = require('gulp-git'),
    mocha = require('gulp-spawn-mocha'),
    mochaPhantomJS = require('gulp-mocha-phantomjs'),
    connect = require('gulp-connect'),
    clean = require('gulp-clean'),
    espower = require('gulp-espower'),
    runSequence = require('run-sequence'),
    source = require('vinyl-source-stream'),
    browserify = require('browserify'),
    merge = require('lodash.merge'),
    config = {
        bump: {
            target: ['./bower.json', './package.json']
        },
        bundle: {
            standalone: 'assert',
            srcFile: './lib/power-assert.js',
            destDir: './build',
            destName: 'power-assert.js'
        },
        test: {
            base: './test/',
            pattern: '**/*_test.js',
            poweredDir: './espowered_tests/',
            toBeInstrumented: function () {
                return this.base + 'tobe_instrumented/' + this.pattern;
            },
            notToBeInstrumented: function () {
                return this.base + 'not_tobe_instrumented/' + this.pattern;
            },
            amd: 'test/test-amd.html',
            browser: 'test/test-browser.html'
        }
    };

function runMocha(pattern, extraOptions) {
    extraOptions = extraOptions || {};
    return gulp
        .src(pattern, {read: false})
        .pipe(mocha(merge({
            bin: './node_modules/.bin/mocha',
            R: 'dot',
            c: true
        }, extraOptions)))
        .on('error', gutil.log);
}

function runMochaWithEspowerLoader() {
    return runMocha(config.test.base + config.test.pattern, {r: './enable_power_assert'});
}

function bumpVersion(options) {
    return gulp
        .src(config.bump.target)
        .pipe(bump(options))
        .pipe(gulp.dest('./'));
}

gulp.task('git_add', function(){
    return gulp
        .src(config.bump.target)
        .pipe(git.add());
});

gulp.task('git_commit', function(){
    var pkg = require('./package.json');
    return gulp
        .src(config.bump.target)
        .pipe(git.commit(pkg.version));
});

gulp.task('git_tag', function(done) {
    var pkg = require('./package.json');
    git.tag('v' + pkg.version, pkg.version, null, done);
});

['patch', 'minor', 'major'].forEach(function (v) {
    gulp.task('bump_' + v, function(){
        return bumpVersion({type: v});
    });
    gulp.task('release_' + v, function(){
        runSequence(
            'bump_' + v,
            'git_add',
            'git_commit',
            'git_tag'
        );
    });
});

gulp.task('connect', function() {
    connect.server({
        root: [__dirname],
        port: 9001,
        keepalive: true
    });
});

gulp.task('watch', function () {
    gulp.watch('{lib,test}/**/*.js', runMochaWithEspowerLoader);
    runMochaWithEspowerLoader();
});

gulp.task('clean_bundle', function () {
    return gulp
        .src(config.bundle.destDir, {read: false})
        .pipe(clean());
});

gulp.task('bundle', function() {
    var bundleStream = browserify(config.bundle.srcFile).bundle({standalone: config.bundle.standalone});
    return bundleStream
        .pipe(source(config.bundle.destName))
        .pipe(gulp.dest(config.bundle.destDir));
})

gulp.task('clean_espower', function () {
    return gulp
        .src(config.test.poweredDir, {read: false})
        .pipe(clean());
});

gulp.task('copy_others', function(){
    return gulp
        .src(config.test.notToBeInstrumented(), {base: config.test.base})
        .pipe(gulp.dest(config.test.poweredDir));
});

gulp.task('espower', function() {
    return gulp
        .src(config.test.toBeInstrumented(), {base: config.test.base})
        .pipe(espower())
        .pipe(gulp.dest(config.test.poweredDir));
});

gulp.task('unit', function () {
    return runMochaWithEspowerLoader();
});

gulp.task('test_generated', function () {
    return runMocha(config.test.poweredDir + config.test.pattern);
});

gulp.task('test_amd', function () {
    return gulp
        .src(config.test.amd)
        .pipe(mochaPhantomJS({reporter: 'dot'}));
});

gulp.task('test_browser', function () {
    return gulp
        .src(config.test.browser)
        .pipe(mochaPhantomJS({reporter: 'dot'}));
});

gulp.task('test', function() {
    runSequence(
        ['clean_espower', 'clean_bundle'],
        ['espower', 'copy_others', 'bundle'],
        ['unit','test_generated','test_browser','test_amd']
    );
});

gulp.task('clean', ['clean_espower', 'clean_bundle']);
<commit_msg>Add just_test task<commit_after>var gulp = require('gulp'),
    gutil = require('gulp-util'),
    bump = require('gulp-bump'),
    git = require('gulp-git'),
    mocha = require('gulp-spawn-mocha'),
    mochaPhantomJS = require('gulp-mocha-phantomjs'),
    connect = require('gulp-connect'),
    clean = require('gulp-clean'),
    espower = require('gulp-espower'),
    runSequence = require('run-sequence'),
    source = require('vinyl-source-stream'),
    browserify = require('browserify'),
    merge = require('lodash.merge'),
    config = {
        bump: {
            target: ['./bower.json', './package.json']
        },
        bundle: {
            standalone: 'assert',
            srcFile: './lib/power-assert.js',
            destDir: './build',
            destName: 'power-assert.js'
        },
        test: {
            base: './test/',
            pattern: '**/*_test.js',
            poweredDir: './espowered_tests/',
            toBeInstrumented: function () {
                return this.base + 'tobe_instrumented/' + this.pattern;
            },
            notToBeInstrumented: function () {
                return this.base + 'not_tobe_instrumented/' + this.pattern;
            },
            amd: 'test/test-amd.html',
            browser: 'test/test-browser.html'
        }
    };

function runMocha(pattern, extraOptions) {
    extraOptions = extraOptions || {};
    return gulp
        .src(pattern, {read: false})
        .pipe(mocha(merge({
            bin: './node_modules/.bin/mocha',
            R: 'dot',
            c: true
        }, extraOptions)))
        .on('error', gutil.log);
}

function runMochaWithEspowerLoader() {
    return runMocha(config.test.base + config.test.pattern, {r: './enable_power_assert'});
}

function bumpVersion(options) {
    return gulp
        .src(config.bump.target)
        .pipe(bump(options))
        .pipe(gulp.dest('./'));
}

gulp.task('git_add', function(){
    return gulp
        .src(config.bump.target)
        .pipe(git.add());
});

gulp.task('git_commit', function(){
    var pkg = require('./package.json');
    return gulp
        .src(config.bump.target)
        .pipe(git.commit(pkg.version));
});

gulp.task('git_tag', function(done) {
    var pkg = require('./package.json');
    git.tag('v' + pkg.version, pkg.version, null, done);
});

['patch', 'minor', 'major'].forEach(function (v) {
    gulp.task('bump_' + v, function(){
        return bumpVersion({type: v});
    });
    gulp.task('release_' + v, function(){
        runSequence(
            'bump_' + v,
            'git_add',
            'git_commit',
            'git_tag'
        );
    });
});

gulp.task('connect', function() {
    connect.server({
        root: [__dirname],
        port: 9001,
        keepalive: true
    });
});

gulp.task('watch', function () {
    gulp.watch('{lib,test}/**/*.js', runMochaWithEspowerLoader);
    runMochaWithEspowerLoader();
});

gulp.task('clean_bundle', function () {
    return gulp
        .src(config.bundle.destDir, {read: false})
        .pipe(clean());
});

gulp.task('bundle', function() {
    var bundleStream = browserify(config.bundle.srcFile).bundle({standalone: config.bundle.standalone});
    return bundleStream
        .pipe(source(config.bundle.destName))
        .pipe(gulp.dest(config.bundle.destDir));
})

gulp.task('clean_espower', function () {
    return gulp
        .src(config.test.poweredDir, {read: false})
        .pipe(clean());
});

gulp.task('copy_others', function(){
    return gulp
        .src(config.test.notToBeInstrumented(), {base: config.test.base})
        .pipe(gulp.dest(config.test.poweredDir));
});

gulp.task('espower', function() {
    return gulp
        .src(config.test.toBeInstrumented(), {base: config.test.base})
        .pipe(espower())
        .pipe(gulp.dest(config.test.poweredDir));
});

gulp.task('unit', function () {
    return runMochaWithEspowerLoader();
});

gulp.task('test_generated', function () {
    return runMocha(config.test.poweredDir + config.test.pattern);
});

gulp.task('test_amd', function () {
    return gulp
        .src(config.test.amd)
        .pipe(mochaPhantomJS({reporter: 'dot'}));
});

gulp.task('test_browser', function () {
    return gulp
        .src(config.test.browser)
        .pipe(mochaPhantomJS({reporter: 'dot'}));
});

gulp.task('test', function() {
    runSequence(
        ['clean_espower', 'clean_bundle'],
        ['espower', 'copy_others', 'bundle'],
        ['unit','test_generated','test_browser','test_amd']
    );
});

gulp.task('just_test', ['unit','test_generated','test_browser','test_amd']);
gulp.task('clean', ['clean_espower', 'clean_bundle']);
<|endoftext|>


<commit_before>// gulp plugins
var
  gulp = require('gulp'),
  gutil = require('gulp-util'),
  rename = require('gulp-rename'),
  // sass
  sass = require('gulp-ruby-sass'),
  // scripts
  uglify = require('gulp-uglify'),
  concat = require('gulp-concat'),
  // live reloading
  livereload = require('gulp-livereload'),
  lr = require('tiny-lr'),
  server = lr();

// file names
var
  defaultFileName = 'main',
  defaultMinSuffix = 'min',
  fileName = defaultFileName + '.' + defaultMinSuffix;

// file paths
var
  baseUrl = './assets/',
  cssPath = baseUrl + 'css/',
  jsPath = baseUrl + 'js/',
  paths = {
    sass: [
      cssPath + '*.scss',
      cssPath + '**/*.scss'
    ],
    scripts: [
      // jquery must be the first file
      jsPath + 'libs/jquery/*.js',
      jsPath + 'libs/**/*.js',
      jsPath + '*.js',
      // ignore minified file
      '!' + jsPath + fileName + '.js'
    ]
  };

gulp.task('sass', function () {
  gulp.src(cssPath + defaultFileName + '.scss')
    // unminified version
    .pipe(sass())
    .pipe(gulp.dest(cssPath))
    // minified version
    .pipe(sass({ style: 'compressed' }))
    .pipe(rename(fileName + '.css'))
    .pipe(gulp.dest(cssPath))
    .pipe(livereload(server));
});

gulp.task('scripts', function() {
  gulp.src(paths.scripts)
    .pipe(uglify())
    .pipe(concat(fileName + '.js'))
    .pipe(gulp.dest(jsPath))
    .pipe(livereload(server));
});

gulp.task('watch', function () {
  server.listen(35729, function(err) {
    if (err) return console.error(err);
    gulp.watch(paths.sass, ['sass']);
    gulp.watch(paths.scripts, ['scripts']);
  });
});

gulp.task('default', ['sass', 'scripts', 'watch']);
<commit_msg>Rename minified file name.<commit_after>// gulp plugins
var
  gulp = require('gulp'),
  gutil = require('gulp-util'),
  rename = require('gulp-rename'),
  // sass
  sass = require('gulp-ruby-sass'),
  // scripts
  uglify = require('gulp-uglify'),
  concat = require('gulp-concat'),
  // live reloading
  livereload = require('gulp-livereload'),
  lr = require('tiny-lr'),
  server = lr();

// file names
var
  defaultFileName = 'main',
  defaultMinSuffix = 'min',
  minFileName = defaultFileName + '.' + defaultMinSuffix;

// file paths
var
  baseUrl = './assets/',
  cssPath = baseUrl + 'css/',
  jsPath = baseUrl + 'js/',
  paths = {
    sass: [
      cssPath + '*.scss',
      cssPath + '**/*.scss'
    ],
    scripts: [
      // jquery must be the first file
      jsPath + 'libs/jquery/*.js',
      jsPath + 'libs/**/*.js',
      jsPath + '*.js',
      // ignore minified file
      '!' + jsPath + minFileName + '.js'
    ]
  };

gulp.task('sass', function () {
  gulp.src(cssPath + defaultFileName + '.scss')
    // unminified version
    .pipe(sass())
    .pipe(gulp.dest(cssPath))
    // minified version
    .pipe(sass({ style: 'compressed' }))
    .pipe(rename(minFileName + '.css'))
    .pipe(gulp.dest(cssPath))
    .pipe(livereload(server));
});

gulp.task('scripts', function() {
  gulp.src(paths.scripts)
    .pipe(uglify())
    .pipe(concat(minFileName + '.js'))
    .pipe(gulp.dest(jsPath))
    .pipe(livereload(server));
});

gulp.task('watch', function () {
  server.listen(35729, function(err) {
    if (err) return console.error(err);
    gulp.watch(paths.sass, ['sass']);
    gulp.watch(paths.scripts, ['scripts']);
  });
});

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


<commit_before>var gulp = require('gulp');
var fs = require('fs');
var merge = require('merge2');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var less = require('gulp-less');
var sass = require('gulp-sass');
var cleancss = require('gulp-clean-css');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var svgstore = require('gulp-svgstore');
var svgmin = require('gulp-svgmin');
var cheerio = require('gulp-cheerio');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var livereload = require('gulp-livereload');
var config = require('js-yaml').safeLoad(fs.readFileSync('rockety.yml', 'utf8'));
var sources = [];

gulp.task('config', function () {
    console.log(JSON.stringify(config, null, 4));
});

function css(config) {
    var stream, vendors = [], vendor, css;

    (config.css.vendor || []).forEach(function (item) {
        vendors.push('./src/vendor/' + item);
    });
    vendor = gulp.src(vendors);

    if (config.css.styles) {
        css = merge(
            gulp.src(config.css.styles.less ? config.source + '/less/' + config.css.styles.less : []).pipe(less()),
            gulp.src(config.css.styles.sass ? config.source + '/sass/' + config.css.styles.sass : []).pipe(sass())
        ).pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }));
    }

    stream = merge(vendor, css || gulp.src([]));
    if (config.css.sourcemap) {
        stream = stream.pipe(sourcemaps.init());
    }
    if (config.css.minify) {
        stream = stream.pipe(cleancss());
    }
    stream = stream.pipe(concat('style.css'));
    if (config.css.sourcemap) {
        stream = stream.pipe(sourcemaps.write());
    }
    stream = stream.pipe(gulp.dest(config.dest + '/css'));
    stream.pipe(livereload());
}

function svg(config) {
    return gulp.src(config.source + '/svg/*.svg')
        .pipe(rename({prefix: 'shape-'}))
        .pipe(svgmin())
        .pipe(svgstore())
        .pipe(cheerio({
            run: function ($) {
                $('svg').attr('style', 'display:none');
            },
            parserOptions: {xmlMode: true}
        }))
        .pipe(rename('shapes.svg'))
        .pipe(gulp.dest(config.dest + '/svg'))
        .pipe(livereload());
}

function js(config) {
    var stream, vendors = [], vendor, scripts = [], script;

    (config.js.vendor || []).forEach(function (item) {
        vendors.push('./src/vendor/' + item);
    });
    vendor = gulp.src(vendors);

    (config.js.scripts || []).forEach(function (item) {
        scripts.push(config.source + '/js/' + item);
    });
    script = gulp.src(scripts);

    if (scripts.length) {
        script = script.pipe(jshint()).pipe(jshint.reporter('jshint-stylish', {beep: true}));
    }

    stream = merge(vendor, script);
    if (config.js.sourcemap) {
        stream = stream.pipe(sourcemaps.init());
    }
    if (config.js.minify) {
        stream = stream.pipe(uglify());
    }
    stream = stream.pipe(concat('scripts.js', {newLine: ';'}));
    if (config.js.sourcemap) {
        stream = stream.pipe(sourcemaps.write());
    }
    stream = stream.pipe(gulp.dest(config.dest + '/js'));
    stream.pipe(livereload());
}

config.forEach(function (source) {
    sources.push(source.source);
    gulp.task('css:' + source.source, function () {
        return css(source)
    });
    gulp.task('svg:' + source.source, function () {
        return svg(source)
    });
    gulp.task('js:' + source.source, function () {
        return js(source)
    });

    gulp.task('reload:' + source.source, function () {
        gulp.src(source.watch).pipe(livereload());
    });

    gulp.task('copy:' + source.source, function () {
        source.copy.forEach(function(files) {
            Object.keys(files).forEach(function(src) {
                gulp.src(src).pipe(gulp.dest(files[src])).pipe(livereload());
            });
        });
    });
});

gulp.task('css', (sources.map(function(source) {
    return 'css:' + source;
})), function () {});
gulp.task('svg', (sources.map(function(source) {
    return 'svg:' + source;
})), function () {});
gulp.task('js', (sources.map(function(source) {
    return 'js:' + source;
})), function () {});
gulp.task('reload', (sources.map(function(source) {
    return 'reload:' + source;
})), function () {});
gulp.task('copy', (sources.map(function(source) {
    return 'copy:' + source;
})), function () {});

gulp.task('build', ['css', 'svg', 'js'], function () {});

gulp.task('watch', function () {
    livereload.listen();
    config.forEach(function(source) {
        gulp.watch(source.source + '/less/*.less', ['css:' + source.source]);
        gulp.watch(source.source + '/sass/*.sass', ['css:' + source.source]);
        gulp.watch(source.source + '/sass/*.scss', ['css:' + source.source]);
        gulp.watch(source.source + '/svg/*.svg', ['svg:' + source.source]);
        gulp.watch(source.source + '/js/*.js', ['js:' + source.source]);
        gulp.watch(source.watch, ['reload:' + source.source]);
        var copySources = [];
        source.copy.forEach(function(files) {
            Object.keys(files).forEach(function(src) {
                copySources.push(src);
            });
        });
        gulp.watch(copySources, ['copy:' + source.source]);
    });
});<commit_msg>Fixed error for watch command when there isn't copy task<commit_after>var gulp = require('gulp');
var fs = require('fs');
var merge = require('merge2');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var less = require('gulp-less');
var sass = require('gulp-sass');
var cleancss = require('gulp-clean-css');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var svgstore = require('gulp-svgstore');
var svgmin = require('gulp-svgmin');
var cheerio = require('gulp-cheerio');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var livereload = require('gulp-livereload');
var config = require('js-yaml').safeLoad(fs.readFileSync('rockety.yml', 'utf8'));
var sources = [];

gulp.task('config', function () {
    console.log(JSON.stringify(config, null, 4));
});

function css(config) {
    var stream, vendors = [], vendor, css;

    (config.css.vendor || []).forEach(function (item) {
        vendors.push('./src/vendor/' + item);
    });
    vendor = gulp.src(vendors);

    if (config.css.styles) {
        css = merge(
            gulp.src(config.css.styles.less ? config.source + '/less/' + config.css.styles.less : []).pipe(less()),
            gulp.src(config.css.styles.sass ? config.source + '/sass/' + config.css.styles.sass : []).pipe(sass())
        ).pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }));
    }

    stream = merge(vendor, css || gulp.src([]));
    if (config.css.sourcemap) {
        stream = stream.pipe(sourcemaps.init());
    }
    if (config.css.minify) {
        stream = stream.pipe(cleancss());
    }
    stream = stream.pipe(concat('style.css'));
    if (config.css.sourcemap) {
        stream = stream.pipe(sourcemaps.write());
    }
    stream = stream.pipe(gulp.dest(config.dest + '/css'));
    stream.pipe(livereload());
}

function svg(config) {
    return gulp.src(config.source + '/svg/*.svg')
        .pipe(rename({prefix: 'shape-'}))
        .pipe(svgmin())
        .pipe(svgstore())
        .pipe(cheerio({
            run: function ($) {
                $('svg').attr('style', 'display:none');
            },
            parserOptions: {xmlMode: true}
        }))
        .pipe(rename('shapes.svg'))
        .pipe(gulp.dest(config.dest + '/svg'))
        .pipe(livereload());
}

function js(config) {
    var stream, vendors = [], vendor, scripts = [], script;

    (config.js.vendor || []).forEach(function (item) {
        vendors.push('./src/vendor/' + item);
    });
    vendor = gulp.src(vendors);

    (config.js.scripts || []).forEach(function (item) {
        scripts.push(config.source + '/js/' + item);
    });
    script = gulp.src(scripts);

    if (scripts.length) {
        script = script.pipe(jshint()).pipe(jshint.reporter('jshint-stylish', {beep: true}));
    }

    stream = merge(vendor, script);
    if (config.js.sourcemap) {
        stream = stream.pipe(sourcemaps.init());
    }
    if (config.js.minify) {
        stream = stream.pipe(uglify());
    }
    stream = stream.pipe(concat('scripts.js', {newLine: ';'}));
    if (config.js.sourcemap) {
        stream = stream.pipe(sourcemaps.write());
    }
    stream = stream.pipe(gulp.dest(config.dest + '/js'));
    stream.pipe(livereload());
}

config.forEach(function (source) {
    sources.push(source.source);
    gulp.task('css:' + source.source, function () {
        return css(source)
    });
    gulp.task('svg:' + source.source, function () {
        return svg(source)
    });
    gulp.task('js:' + source.source, function () {
        return js(source)
    });

    gulp.task('reload:' + source.source, function () {
        gulp.src(source.watch).pipe(livereload());
    });

    gulp.task('copy:' + source.source, function () {
        source.copy.forEach(function(files) {
            Object.keys(files).forEach(function(src) {
                gulp.src(src).pipe(gulp.dest(files[src])).pipe(livereload());
            });
        });
    });
});

gulp.task('css', (sources.map(function(source) {
    return 'css:' + source;
})), function () {});
gulp.task('svg', (sources.map(function(source) {
    return 'svg:' + source;
})), function () {});
gulp.task('js', (sources.map(function(source) {
    return 'js:' + source;
})), function () {});
gulp.task('reload', (sources.map(function(source) {
    return 'reload:' + source;
})), function () {});
gulp.task('copy', (sources.map(function(source) {
    return 'copy:' + source;
})), function () {});

gulp.task('build', ['css', 'svg', 'js'], function () {});

gulp.task('watch', function () {
    livereload.listen();
    config.forEach(function(source) {
        gulp.watch(source.source + '/less/*.less', ['css:' + source.source]);
        gulp.watch(source.source + '/sass/*.sass', ['css:' + source.source]);
        gulp.watch(source.source + '/sass/*.scss', ['css:' + source.source]);
        gulp.watch(source.source + '/svg/*.svg', ['svg:' + source.source]);
        gulp.watch(source.source + '/js/*.js', ['js:' + source.source]);
        gulp.watch(source.watch, ['reload:' + source.source]);
        var copySources = [];
        (source.copy || []).forEach(function(files) {
            Object.keys(files).forEach(function(src) {
                copySources.push(src);
            });
        });
        gulp.watch(copySources, ['copy:' + source.source]);
    });
});<|endoftext|>


<commit_before>// Modules used in this project.
var gulp = require('gulp');
var sequence = require('run-sequence');
var bs = require('browser-sync').create();
var nunjucksRender = require('gulp-nunjucks-render');
var htmlmin = require('gulp-htmlmin');
var htmlhint = require('gulp-htmlhint');
var stylelint = require('gulp-stylelint');
var jshint = require('gulp-jshint');
var sort = require('gulp-sort');
var uncss = require('gulp-uncss');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var autoprefixer = require('gulp-autoprefixer');
var csso = require('gulp-csso');

// Relevant directories
var css = 'app/styles/**/*.css';
var js = 'app/scripts/*.js';
var njk = 'app/templates/**/*.njk';
var img = 'app/images/**/*.+(jpg|png)';

// Dictionaries that are used in more than one place
var htmlHintRules = {
    "tagname-lowercase": true,
    "attr-lowercase": true,
    "attr-value-double-quotes": true,
    "attr-value-not-empty": true,
    "attr-no-duplication": true,
    "doctype-first": true,
    "tag-pair": true,
    "tag-self-close": true,
    "spec-char-escape": true,
    "id-unique": true,
    "src-not-empty": true,
    "title-require": true,
    "head-script-disabled": true,
    "alt-require": true,
    "doctype-html5": true,
    "id-class-value": "dash",
    "style-disabled": true,
    "inline-style-disabled": true,
    "inline-script-disabled": true,
    "space-tab-mixed-disabled": "space",
    "id-class-ad-disabled": true,
    "href-abs-or-rel": "rel",
    "attr-unsafe-chars": true
};
var htmlMinOptions = {
    'removeComments': true,
    'removeCommentsFromCDATA': true,
    'collapseWhitespace': true,
    'collapseBooleanAttributes': true,
    'removeRedundantAttributes': true,
    'useShortDoctype': true,
    'removeEmptyAttributes': true,
    'removeOptionalTags': true
};

// Build web site from available content
gulp.task('build', function() {
    sequence('nunjucks', 'img', 'css', 'js');
});

// Setting up the Browser Sync server
gulp.task('browser-sync', function() {
    bs.init({
        // Server base directory
        server:                 'dist',
        // Should all the screens connected to this server scroll together
        scrollProportionally:   false
    });
});

// Setting up the Browser Sync server
gulp.task('tunnel-sync', function() {
    bs.init({
        // Server base directory
        server:                 'dist',
        // Try to connect to the tunnel service of the following name
        tunnel:                 'creativopty',
        // The manner in which the project opens once the server starts
        open:                   'tunnel',
        // Should all the screens connected to this server scroll together
        scrollProportionally:   false
    });
});

// Defining what should happen if any file changes
gulp.task('default', ['browser-sync'], function() {
    // When a Nunjucks file changes
    gulp.watch(njk, ['nunjucks']);
    // When a CSS file changes
    gulp.watch(css, ['css']);
    // When a JS file changes
    gulp.watch(js, ['js']);
    // When an image changes
    gulp.watch(img, ['img']);
});

// Convert Nunjucks templates into HTML files
gulp.task('nunjucks', function() {
    return gulp.src(njk)
        // Renders template with nunjucks
        .pipe(nunjucksRender({
            // Location of templates in the project
            path: ['app/templates/']
        }))
        // Use HTML Hint to validate the HTML file
        .pipe(htmlhint(htmlHintRules))
        // Fail this task if there is an error
        .pipe(htmlhint.failReporter())
        // Minify HTML files
        .pipe(htmlmin(htmlMinOptions))
        // Output files into the dist folder
        .pipe(gulp.dest('dist'))
        // Reload the dist file in the browser
        .pipe(bs.stream());
});

// Tasks done to css files
gulp.task('css', ['css-lint'], function() {
    return gulp.src(css)
        // Sort files in alphabetical order
        .pipe(sort())
        // Remove any unused CSS rules
        .pipe(uncss({ html: ['dist/**/*.html'] }))
        // Create a source map for future reference
        .pipe(sourcemaps.init())
            // Minify CSS
            .pipe(csso())
            // Combine all of the CSS files into one
            .pipe(concat('main.css'))
            // Prefix CSS rules for browser support
            .pipe(autoprefixer({ browsers: ['> 1%'] }))
        .pipe(sourcemaps.write())
        // Copy app file to dist
        .pipe(gulp.dest('dist/styles'))
        // Reload the dist file in the browser
        .pipe(bs.stream());
});

// Lint CSS files
gulp.task('css-lint', function() {
    return gulp.src([ css, '!' + css.replace('/**/*.css', '/library/**/*.css') ])
    // Use Stylelint to validate this CSS file
    .pipe(stylelint({
        failAfterError: true,
        reporters: [ { formatter: 'string', console: true } ]
    }));
});

// Tasks done to js files
gulp.task('js', function() {
    return gulp.src(js)
        // Sort files in alphabetical order
        .pipe(sort())
        // Use JS Hint to validate this JS file
        .pipe(jshint())
        // Report using JS Hint default reporter
        .pipe(jshint.reporter('default'))
        // Fail this task if there is an error
        .pipe(jshint.reporter('fail'))
        // Copy app file to dist
        .pipe(gulp.dest('dist/scripts'))
        // Reload the dist file in the browser
        .pipe(bs.stream());
});

// Move the images files from the app folder to the distribution folder
gulp.task('img', function() {
    // Get the images from the app folder
    return gulp.src(img)
    // Output images into the distribution folder
    .pipe(gulp.dest('dist/images'))
    // Reload the distribution file in the browser
    .pipe(bs.stream());
});
<commit_msg>Temporarily disable HTML linting<commit_after>// Modules used in this project.
var gulp = require('gulp');
var sequence = require('run-sequence');
var bs = require('browser-sync').create();
var nunjucksRender = require('gulp-nunjucks-render');
var htmlmin = require('gulp-htmlmin');
var htmlhint = require('gulp-htmlhint');
var stylelint = require('gulp-stylelint');
var jshint = require('gulp-jshint');
var sort = require('gulp-sort');
var uncss = require('gulp-uncss');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var autoprefixer = require('gulp-autoprefixer');
var csso = require('gulp-csso');

// Relevant directories
var css = 'app/styles/**/*.css';
var js = 'app/scripts/*.js';
var njk = 'app/templates/**/*.njk';
var img = 'app/images/**/*.+(jpg|png)';

// Dictionaries that are used in more than one place
var htmlHintRules = {
    "tagname-lowercase": true,
    "attr-lowercase": true,
    "attr-value-double-quotes": true,
    "attr-value-not-empty": true,
    "attr-no-duplication": true,
    "doctype-first": true,
    "tag-pair": true,
    "tag-self-close": true,
    "spec-char-escape": true,
    "id-unique": true,
    "src-not-empty": true,
    "title-require": true,
    "head-script-disabled": true,
    "alt-require": true,
    "doctype-html5": true,
    "id-class-value": "dash",
    "style-disabled": true,
    "inline-style-disabled": true,
    "inline-script-disabled": true,
    "space-tab-mixed-disabled": "space",
    "id-class-ad-disabled": true,
    "href-abs-or-rel": "rel",
    "attr-unsafe-chars": true
};
var htmlMinOptions = {
    'removeComments': true,
    'removeCommentsFromCDATA': true,
    'collapseWhitespace': true,
    'collapseBooleanAttributes': true,
    'removeRedundantAttributes': true,
    'useShortDoctype': true,
    'removeEmptyAttributes': true,
    'removeOptionalTags': true
};

// Build web site from available content
gulp.task('build', function() {
    sequence('nunjucks', 'img', 'css', 'js');
});

// Setting up the Browser Sync server
gulp.task('browser-sync', function() {
    bs.init({
        // Server base directory
        server:                 'dist',
        // Should all the screens connected to this server scroll together
        scrollProportionally:   false
    });
});

// Setting up the Browser Sync server
gulp.task('tunnel-sync', function() {
    bs.init({
        // Server base directory
        server:                 'dist',
        // Try to connect to the tunnel service of the following name
        tunnel:                 'creativopty',
        // The manner in which the project opens once the server starts
        open:                   'tunnel',
        // Should all the screens connected to this server scroll together
        scrollProportionally:   false
    });
});

// Defining what should happen if any file changes
gulp.task('default', ['browser-sync'], function() {
    // When a Nunjucks file changes
    gulp.watch(njk, ['nunjucks']);
    // When a CSS file changes
    gulp.watch(css, ['css']);
    // When a JS file changes
    gulp.watch(js, ['js']);
    // When an image changes
    gulp.watch(img, ['img']);
});

// Convert Nunjucks templates into HTML files
gulp.task('nunjucks', function() {
    return gulp.src(njk)
        // Renders template with nunjucks
        .pipe(nunjucksRender({
            // Location of templates in the project
            path: ['app/templates/']
        }))
        // Minify HTML files
        .pipe(htmlmin(htmlMinOptions))
        // Output files into the dist folder
        .pipe(gulp.dest('dist'))
        // Reload the dist file in the browser
        .pipe(bs.stream());
});

// Tasks done to css files
gulp.task('css', ['css-lint'], function() {
    return gulp.src(css)
        // Sort files in alphabetical order
        .pipe(sort())
        // Remove any unused CSS rules
        .pipe(uncss({ html: ['dist/**/*.html'] }))
        // Create a source map for future reference
        .pipe(sourcemaps.init())
            // Minify CSS
            .pipe(csso())
            // Combine all of the CSS files into one
            .pipe(concat('main.css'))
            // Prefix CSS rules for browser support
            .pipe(autoprefixer({ browsers: ['> 1%'] }))
        .pipe(sourcemaps.write())
        // Copy app file to dist
        .pipe(gulp.dest('dist/styles'))
        // Reload the dist file in the browser
        .pipe(bs.stream());
});

// Lint CSS files
gulp.task('css-lint', function() {
    return gulp.src([ css, '!' + css.replace('/**/*.css', '/library/**/*.css') ])
    // Use Stylelint to validate this CSS file
    .pipe(stylelint({
        failAfterError: true,
        reporters: [ { formatter: 'string', console: true } ]
    }));
});

// Tasks done to js files
gulp.task('js', function() {
    return gulp.src(js)
        // Sort files in alphabetical order
        .pipe(sort())
        // Use JS Hint to validate this JS file
        .pipe(jshint())
        // Report using JS Hint default reporter
        .pipe(jshint.reporter('default'))
        // Fail this task if there is an error
        .pipe(jshint.reporter('fail'))
        // Copy app file to dist
        .pipe(gulp.dest('dist/scripts'))
        // Reload the dist file in the browser
        .pipe(bs.stream());
});

// Move the images files from the app folder to the distribution folder
gulp.task('img', function() {
    // Get the images from the app folder
    return gulp.src(img)
    // Output images into the distribution folder
    .pipe(gulp.dest('dist/images'))
    // Reload the distribution file in the browser
    .pipe(bs.stream());
});
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp'),
    concat = require('gulp-concat'),
    uglifycss = require('gulp-uglifycss'),
    rename = require('gulp-rename'),
    del = require('del'),
    flatten = require('gulp-flatten');

gulp.task('build-css', function() {
	gulp.src([
        'src/app/components/common/common.css',
		    'src/app/components/**/*.css'
    ])
        .pipe(concat('primeng.css'))
        .pipe(gulp.dest('dist/resources'));
});

gulp.task('build-css-prod', function() {
    gulp.src([
        'src/app/components/common/common.css',
        'src/app/components/badge/badge.css',
        'src/app/components/button/button.css',
        'src/app/components/checkbox/checkbox.css',
        'src/app/components/colorpicker/colorpicker-images.css',
        'src/app/components/inputtext/inputtext.css',
        'src/app/components/inputtextarea/inputtextarea.css',
        'src/app/components/password/password.css',
        'src/app/components/radiobutton/radiobutton.css',
        'src/app/components/ripple/ripple.css',
        'src/app/components/tooltip/tooltip.css'
    ])
    .pipe(concat('primeng.css'))
    .pipe(gulp.dest('dist/resources'))
    .pipe(uglifycss({"uglyComments": true}))
    .pipe(rename('primeng.min.css'))
    .pipe(gulp.dest('dist/resources'));
});

gulp.task('copy-component-css', function () {
    gulp.src([
        'src/app/components/**/*.css',
        'src/app/components/**/images/*.png',
        'src/app/components/**/images/*.gif'
    ])
    .pipe(gulp.dest('dist/resources/components'));
});

gulp.task('images', function() {
    return gulp.src(['src/app/components/**/images/*.png', 'src/app/components/**/images/*.gif'])
        .pipe(flatten())
        .pipe(gulp.dest('dist/resources/images'));
});

gulp.task('themes', function() {
    return gulp.src(['src/assets/components/themes/**/*',
        '!src/assets/components/themes/soho-*/**/*',
        '!src/assets/components/themes/viva-*/**/*',
        '!src/assets/components/themes/mira/**/*',
        '!src/assets/components/themes/nano/**/*'])
        .pipe(gulp.dest('dist/resources/themes'));
});

//Cleaning previous gulp tasks from project
gulp.task('clean', function() {
	del(['dist/resources']);
});

//Copy readme
gulp.task('readme', function() {
    gulp.src(['README.md'])
    .pipe(gulp.dest('dist'));
});

//Building project with run sequence
gulp.task('build-assets', gulp.series['clean','copy-component-css', 'build-css-prod', 'images', 'themes', 'readme']);

<commit_msg>Fixed gulp build<commit_after>"use strict";

var gulp = require("gulp"),
    concat = require("gulp-concat"),
    uglifycss = require("gulp-uglifycss"),
    rename = require("gulp-rename"),
    flatten = require("gulp-flatten");

gulp.task("build-css", function() {
	return gulp.src([
        "src/app/components/common/common.css",
		    "src/app/components/**/*.css"
    ])
        .pipe(concat("primeng.css"))
        .pipe(gulp.dest("dist/resources"));
});

gulp.task("build-css-prod", function() {
    return gulp.src([
        "src/app/components/common/common.css",
        "src/app/components/badge/badge.css",
        "src/app/components/button/button.css",
        "src/app/components/checkbox/checkbox.css",
        "src/app/components/colorpicker/colorpicker-images.css",
        "src/app/components/inputtext/inputtext.css",
        "src/app/components/inputtextarea/inputtextarea.css",
        "src/app/components/password/password.css",
        "src/app/components/radiobutton/radiobutton.css",
        "src/app/components/ripple/ripple.css",
        "src/app/components/tooltip/tooltip.css"
    ])
    .pipe(concat("primeng.css"))
    .pipe(gulp.dest("dist/resources"))
    .pipe(uglifycss({"uglyComments": true}))
    .pipe(rename("primeng.min.css"))
    .pipe(gulp.dest("dist/resources"));
});

gulp.task("copy-component-css", function () {
    return gulp.src([
        "src/app/components/**/*.css",
        "src/app/components/**/images/*.png",
        "src/app/components/**/images/*.gif"
    ])
    .pipe(gulp.dest("dist/resources/components"));
});

gulp.task("images", function() {
    return gulp.src(["src/app/components/**/images/*.png", "src/app/components/**/images/*.gif"])
        .pipe(flatten())
        .pipe(gulp.dest("dist/resources/images"));
});

gulp.task("themes", function() {
    return gulp.src(["src/assets/components/themes/**/*",
        "!src/assets/components/themes/soho-*/**/*",
        "!src/assets/components/themes/viva-*/**/*",
        "!src/assets/components/themes/mira/**/*",
        "!src/assets/components/themes/nano/**/*"])
        .pipe(gulp.dest("dist/resources/themes"));
});

//Copy readme
gulp.task("readme", function() {
    return gulp.src(["README.md"])
    .pipe(gulp.dest("dist"));
});

//Building project with run sequence
gulp.task("build-assets", gulp.series("copy-component-css", "build-css-prod", "images", "themes", "readme"));

<|endoftext|>


<commit_before>var gulp    = require("gulp");
var becklyn = require("becklyn-gulp");
var isDebug = !!require("yargs").argv.debug || !!require("yargs").argv.dev;

gulp.task("css", becklyn.scss("layout/assets/**/*.scss", isDebug));
gulp.task("js",  becklyn.js("layout/assets/js/**/*.js", isDebug));

gulp.task("assets", ["css", "js"],
    function ()
    {
        if (fs.existsSync("web/assets"))
        {
            fs.unlinkSync("web/assets");
        }

        fs.symlinkSync("../layout/public", "web/assets");
    }
);

gulp.task("default", ["css", "js", "assets"]);
<commit_msg>Removed "assets" from generic gulp task<commit_after>var gulp    = require("gulp");
var becklyn = require("becklyn-gulp");
var isDebug = !!require("yargs").argv.debug || !!require("yargs").argv.dev;

gulp.task("css", becklyn.scss("layout/assets/**/*.scss", isDebug));
gulp.task("js",  becklyn.js("layout/assets/js/**/*.js", isDebug));

gulp.task("assets", ["css", "js"],
    function ()
    {
        if (fs.existsSync("web/assets"))
        {
            fs.unlinkSync("web/assets");
        }

        fs.symlinkSync("../layout/public", "web/assets");
    }
);

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


<commit_before>import * as gulp from 'gulp';
import * as util from 'gulp-util';
import * as chalk from 'chalk';
import * as gulpLoadPlugins from 'gulp-load-plugins';
import { join } from 'path';
import * as _runSequence from 'run-sequence';

const TASKS_PATH = join('tools', 'tasks');

function task(taskName: string, option?: string) {
  util.log('loading task', chalk.yellow(taskName, option || ''));
  return require(join('..', 'tasks', taskName))(gulp, gulpLoadPlugins(), option);
}

function registerTask(taskName: string, fileName?: string, option: string = ''): void {
  gulp.task(taskName, task(fileName || taskName, option));
}

function scanDir(root: string, cb: (taskName: string) => void) {
  if (!existsSync(root)) return;

  walk(root);

  function walk(path) {
    let files = readdirSync(path);
    for (let i = 0, j = files.length; i < j; i+=1) {
      let file = files[i];
      let curPath = join(path, file);
      if (lstatSync(curPath).isFile() && /\.ts$/.test(file)) {
        let taskName = file.replace(/(\.ts)/, '');
        cb(taskName);
      }
    }
  }
}

export function runSequence(...sequence: any[]) {
  let tasks = [];
  let _sequence = sequence.slice(0);
  sequence.pop();

  scanDir(TASKS_PATH, taskName => tasks.push(taskName));

  sequence.forEach(task => {
    if (tasks.indexOf(task) > -1) {
      registerTask(task);
    }
  });

  return _runSequence(..._sequence);
}

// ---------------
// Copy SCSS
gulp.task('copy', done => {
  console.log('-------- COPY TASK ------');
  // runSequence('copy.assets', done);
});<commit_msg>build: add gulp CSS task (needs to refactor later)<commit_after>'use strict';

const gulp = require('gulp');
const path = require('path');
const sass = require("gulp-sass");

gulp.task('copy', () => {
  return gulp.src([
    path.join('src/lib/card', '**', '*.scss'),
    '!' + path.join('src/lib', '**', '*.ts')
    ])
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('dist/card'));
});<|endoftext|>


<commit_before>/* eslint vars-on-top:0 no-console:0 */
'use strict';
var path = require('path');
var gulp = require('gulp');
var connect = require('gulp-connect');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var gutil = require('gulp-util');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var insert = require('gulp-insert');
var stylus = require('gulp-stylus');
var through = require('through2');
var preprocessify = require('preprocessify');

// KARMA
var KarmaServer = require('karma').server;
var karmaConfigParser = require('karma/lib/config').parseConfig;

var banner = [
'/** _____               _     _   _ ___    ____      _                  _      _',
' * |_   _|__   __ _ ___| |_  | | | |_ _|  / ___|___ | | ___  _ __ _ __ (_) ___| | _____ _ __',
' *   | |/ _ \\ / _` / __| __| | | | || |  | |   / _ \\| |/ _ \\| \'__| \'_ \\| |/ __| |/ / _ \\ \'__|',
' *   | | (_) | (_| \\__ \\ |_  | |_| || |  | |__| (_) | | (_) | |  | |_) | | (__|   <  __/ |',
' *   |_|\\___/ \\__,_|___/\\__|  \\___/|___|  \\____\\___/|_|\\___/|_|  | .__/|_|\\___|_|\\_\\___|_|',
' *                                                               |_|',
' * @version {{version}}',
' */\n',
].join('\n');

gulp.task('default', function(done) {
    var config = karmaConfigParser(path.resolve('karma.conf.js'), {});
    config.singleRun = true;

    KarmaServer.start(config, function(exitCode) {
        gutil.log('Karma has exited with ' + exitCode);
        done();
        process.exit(exitCode);
    });
});

gulp.task('connect', function() {
    connect.server({
        livereload: true
    });
    gulp.watch([
        './src/**/*',
        './index.js',
        './demo/**/*.html',
        './demo-dev/**/*.html'
    ], ['bundle-dev']);
});

function bundle(outputPath, isProduction) {
    var pkg = require('./package.json');
    var versionHeader = banner.replace('{{version}}', pkg.version);

    if (isProduction) {
        gutil.log(gutil.colors.yellow('<< Bundling for Production >>'));
    }

    outputPath = outputPath || 'dist';

    gulp.src('./src/styl/**/*.styl')
        .pipe(stylus())
        .pipe(insert.prepend(versionHeader))
        .pipe(gulp.dest(outputPath))
        .pipe(isProduction ? rename({extname: '.min.css'}) : gutil.noop())
        .pipe(isProduction ? gulp.dest(outputPath) : gutil.noop());

    var b = browserify({
        entries: 'index.js',
        debug: true
    });

    var added = false;
    function prependTransform() {
        return through(function (buf, enc, next) {
            if (!added) {
                this.push(versionHeader + buf.toString('utf8'));
                added = true;
            } else {
                this.push(buf.toString('utf8'));
            }
            next();
        });
    }

    if (isProduction) {
        b.ignore('tui-code-snippet');
    }

    return b.transform(prependTransform)
        .transform(preprocessify({ENV: (isProduction ? 'RELEASE' : 'DEBUG')}))
        .bundle()
        .on('error', function(err) {
            console.log(err.message);
            this.emit('end');
        })
        .pipe(source('colorpicker.js'))
        .pipe(buffer())
        .pipe(gulp.dest(outputPath))
        .pipe(isProduction ? uglify({compress:{}}) : gutil.noop())
        .pipe(isProduction ? rename({extname: '.min.js'}) : gutil.noop())
        .pipe(isProduction ? insert.prepend(versionHeader) : gutil.noop())
        .pipe(isProduction ? gulp.dest(outputPath) : gutil.noop())
        .pipe(connect.reload());
}

gulp.task('bundle-dev', function() {
    return bundle('build', false);
});

gulp.task('bundle', function() {
    return bundle('dist', gutil.env.production);
});

gulp.task('dev', function() {
    gulp.watch(['index.js', 'src/**/*.js'], ['bundle']);
});

gulp.task('test-w', function(done) {
    var config = karmaConfigParser(path.resolve('karma.conf.local.js'), {});

    KarmaServer.start(config, function(exitCode) {
        gutil.log('Karma has exited with ' + exitCode);
        done();
        process.exit(exitCode);
    });
});

<commit_msg>remove Ascii banner in bundle sources<commit_after>/* eslint vars-on-top:0 no-console:0 */
'use strict';
var path = require('path');
var gulp = require('gulp');
var connect = require('gulp-connect');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var gutil = require('gulp-util');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var insert = require('gulp-insert');
var stylus = require('gulp-stylus');
var through = require('through2');
var preprocessify = require('preprocessify');

// KARMA
var KarmaServer = require('karma').server;
var karmaConfigParser = require('karma/lib/config').parseConfig;

var banner = [
'/**',
' * Toast UI Colorpicker',
' * @version {{version}}',
' */\n',
].join('\n');

gulp.task('default', function(done) {
    var config = karmaConfigParser(path.resolve('karma.conf.js'), {});
    config.singleRun = true;

    KarmaServer.start(config, function(exitCode) {
        gutil.log('Karma has exited with ' + exitCode);
        done();
        process.exit(exitCode);
    });
});

gulp.task('connect', function() {
    connect.server({
        livereload: true
    });
    gulp.watch([
        './src/**/*',
        './index.js',
        './demo/**/*.html',
        './demo-dev/**/*.html'
    ], ['bundle-dev']);
});

function bundle(outputPath, isProduction) {
    var pkg = require('./package.json');
    var versionHeader = banner.replace('{{version}}', pkg.version);

    if (isProduction) {
        gutil.log(gutil.colors.yellow('<< Bundling for Production >>'));
    }

    outputPath = outputPath || 'dist';

    gulp.src('./src/styl/**/*.styl')
        .pipe(stylus())
        .pipe(insert.prepend(versionHeader))
        .pipe(gulp.dest(outputPath))
        .pipe(isProduction ? rename({extname: '.min.css'}) : gutil.noop())
        .pipe(isProduction ? gulp.dest(outputPath) : gutil.noop());

    var b = browserify({
        entries: 'index.js',
        debug: true
    });

    var added = false;
    function prependTransform() {
        return through(function (buf, enc, next) {
            if (!added) {
                this.push(versionHeader + buf.toString('utf8'));
                added = true;
            } else {
                this.push(buf.toString('utf8'));
            }
            next();
        });
    }

    if (isProduction) {
        b.ignore('tui-code-snippet');
    }

    return b.transform(prependTransform)
        .transform(preprocessify({ENV: (isProduction ? 'RELEASE' : 'DEBUG')}))
        .bundle()
        .on('error', function(err) {
            console.log(err.message);
            this.emit('end');
        })
        .pipe(source('colorpicker.js'))
        .pipe(buffer())
        .pipe(gulp.dest(outputPath))
        .pipe(isProduction ? uglify({compress:{}}) : gutil.noop())
        .pipe(isProduction ? rename({extname: '.min.js'}) : gutil.noop())
        .pipe(isProduction ? insert.prepend(versionHeader) : gutil.noop())
        .pipe(isProduction ? gulp.dest(outputPath) : gutil.noop())
        .pipe(connect.reload());
}

gulp.task('bundle-dev', function() {
    return bundle('build', false);
});

gulp.task('bundle', function() {
    return bundle('dist', gutil.env.production);
});

gulp.task('dev', function() {
    gulp.watch(['index.js', 'src/**/*.js'], ['bundle']);
});

gulp.task('test-w', function(done) {
    var config = karmaConfigParser(path.resolve('karma.conf.local.js'), {});

    KarmaServer.start(config, function(exitCode) {
        gutil.log('Karma has exited with ' + exitCode);
        done();
        process.exit(exitCode);
    });
});

<|endoftext|>


<commit_before>// Assigning modules to local variables
var gulp = require('gulp');
var less = require('gulp-less');
var browserSync = require('browser-sync').create();
var header = require('gulp-header');
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var uglify = require('gulp-uglify');
var pkg = require('./package.json');

// Set the banner content
var banner = ['/*!\n',
    ' * Start Bootstrap - <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
    ' * Copyright 2013-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
    ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n',
    ' */\n',
    ''
].join('');

// Default task
gulp.task('default', ['less', 'minify-css', 'minify-js', 'copy']);

// Less task to compile the less files and add the banner
gulp.task('less', function() {
    return gulp.src('less/agency.less')
        .pipe(less())
        .pipe(header(banner, { pkg: pkg }))
        .pipe(gulp.dest('css'))
        .pipe(browserSync.reload({
            stream: true
        }))
});

// Minify CSS
gulp.task('minify-css', function() {
    return gulp.src('css/agency.css')
        .pipe(cleanCSS({ compatibility: 'ie8' }))
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('css'))
        .pipe(browserSync.reload({
            stream: true
        }))
});

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

// Copy Bootstrap core files from node_modules to vendor directory
gulp.task('bootstrap', function() {
    return gulp.src(['node_modules/bootstrap/dist/**/*', '!**/npm.js', '!**/bootstrap-theme.*', '!**/*.map'])
        .pipe(gulp.dest('vendor/bootstrap'))
})

// Copy jQuery core files from node_modules to vendor directory
gulp.task('jquery', function() {
    return gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js'])
        .pipe(gulp.dest('vendor/jquery'))
})

// Copy Font Awesome core files from node_modules to vendor directory
gulp.task('fontawesome', function() {
    return gulp.src([
            'node_modules/font-awesome/**',
            '!node_modules/font-awesome/**/*.map',
            '!node_modules/font-awesome/.npmignore',
            '!node_modules/font-awesome/*.txt',
            '!node_modules/font-awesome/*.md',
            '!node_modules/font-awesome/*.json'
        ])
        .pipe(gulp.dest('vendor/font-awesome'))
})

// Copy all third party dependencies from node_modules to vendor directory
gulp.task('copy', ['bootstrap', 'jquery', 'fontawesome']);

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

// Watch Task that compiles LESS and watches for HTML or JS changes and reloads with browserSync
gulp.task('dev', ['browserSync', 'less', 'minify-css', 'minify-js'], function() {
    gulp.watch('less/*.less', ['less']);
    gulp.watch('css/*.css', ['minify-css']);
    gulp.watch('js/*.js', ['minify-js']);
    // Reloads the browser whenever HTML or JS files change
    gulp.watch('*.html', browserSync.reload);
    gulp.watch('js/**/*.js', browserSync.reload);
});<commit_msg>require less to run before minify-css in gulpfile<commit_after>// Assigning modules to local variables
var gulp = require('gulp');
var less = require('gulp-less');
var browserSync = require('browser-sync').create();
var header = require('gulp-header');
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var uglify = require('gulp-uglify');
var pkg = require('./package.json');

// Set the banner content
var banner = ['/*!\n',
    ' * Start Bootstrap - <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
    ' * Copyright 2013-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
    ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n',
    ' */\n',
    ''
].join('');

// Default task
gulp.task('default', ['less', 'minify-css', 'minify-js', 'copy']);

// Less task to compile the less files and add the banner
gulp.task('less', function() {
    return gulp.src('less/agency.less')
        .pipe(less())
        .pipe(header(banner, { pkg: pkg }))
        .pipe(gulp.dest('css'))
        .pipe(browserSync.reload({
            stream: true
        }))
});

// Minify CSS
gulp.task('minify-css', ['less'], function() {
    return gulp.src('css/agency.css')
        .pipe(cleanCSS({ compatibility: 'ie8' }))
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('css'))
        .pipe(browserSync.reload({
            stream: true
        }))
});

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

// Copy Bootstrap core files from node_modules to vendor directory
gulp.task('bootstrap', function() {
    return gulp.src(['node_modules/bootstrap/dist/**/*', '!**/npm.js', '!**/bootstrap-theme.*', '!**/*.map'])
        .pipe(gulp.dest('vendor/bootstrap'))
})

// Copy jQuery core files from node_modules to vendor directory
gulp.task('jquery', function() {
    return gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js'])
        .pipe(gulp.dest('vendor/jquery'))
})

// Copy Font Awesome core files from node_modules to vendor directory
gulp.task('fontawesome', function() {
    return gulp.src([
            'node_modules/font-awesome/**',
            '!node_modules/font-awesome/**/*.map',
            '!node_modules/font-awesome/.npmignore',
            '!node_modules/font-awesome/*.txt',
            '!node_modules/font-awesome/*.md',
            '!node_modules/font-awesome/*.json'
        ])
        .pipe(gulp.dest('vendor/font-awesome'))
})

// Copy all third party dependencies from node_modules to vendor directory
gulp.task('copy', ['bootstrap', 'jquery', 'fontawesome']);

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

// Watch Task that compiles LESS and watches for HTML or JS changes and reloads with browserSync
gulp.task('dev', ['browserSync', 'less', 'minify-css', 'minify-js'], function() {
    gulp.watch('less/*.less', ['less']);
    gulp.watch('css/*.css', ['minify-css']);
    gulp.watch('js/*.js', ['minify-js']);
    // Reloads the browser whenever HTML or JS files change
    gulp.watch('*.html', browserSync.reload);
    gulp.watch('js/**/*.js', browserSync.reload);
});<|endoftext|>


<commit_before>'use strict';

const gulp = require('gulp');
const log = require('fancy-log');
const chalk = require('chalk');
const ejs = require('gulp-ejs');
const zip = require('gulp-zip');
const mergeStream = require('merge-stream');
const {
	formatVersionFolder,
	compareStrings,
	formatPackageUpgrades,
	getLibraries,
	getUpgradeVersions,
} = require('./utility');

const libraries = getLibraries();

libraries.forEach(library =>
	gulp.task(library.path, () => {
		const mainFileStream = gulp.src(library.manifest.files);
		const resourceZipStream = gulp
			.src(library.manifest.resources || [])
			.pipe(zip('Resources.zip'));

		const templateData = {
			version: library.version,
			versionFolder: formatVersionFolder(library.version),
		};
		const packageFilesStream = gulp
			.src(['LICENSE.htm', 'CHANGES.htm', '*.dnn'], {
				cwd: library.path,
			})
			.pipe(ejs(templateData, { delimiter: '~' }));

		return mergeStream(
			mainFileStream,
			resourceZipStream,
			packageFilesStream
		)
			.pipe(zip(`${library.name}_${library.version}.zip`))
			.pipe(gulp.dest('./_InstallPackages/'));
	})
);

const libraryTaskNames = libraries.map(library => library.path);

gulp.task('default', libraryTaskNames);

gulp.task('outdated', () => {
	const allUpgradesPromises = libraries.map(library =>
		getUpgradeVersions(library).then(upgrades =>
			Object.assign(library, { upgrades })
		)
	);

	return Promise.all(allUpgradesPromises).then(allUpgrades => {
		const validUpgrades = allUpgrades
			.filter(({ upgrades }) => upgrades.size > 0)
			.sort(({ name: a }, { name: b }) => compareStrings(a, b));

		if (validUpgrades.length === 0) {
			log.warn(
				chalk`All {yellow ${allUpgrades.length}} packages up-to-date`
			);

			return;
		}

		log.info(`
${formatPackageUpgrades(validUpgrades)}`);
	});
});

['patch', 'minor', 'major'].forEach(upgradeType =>
	gulp.task(`upgrade-${upgradeType}`, () => {
		const allUpgradesPromises = libraries.map(library =>
			getUpgradeVersions(library).then(upgrades =>
				Object.assign(library, { upgrades })
			)
		);

		return Promise.all(allUpgradesPromises).then(allUpgrades => {
			const validUpgrades = allUpgrades.filter(({ upgrades }) =>
				upgrades.get(upgradeType)
			);

			if (validUpgrades.length === 0) {
				log.warn(`No ${upgradeType} upgrades to process`);

				return;
			}

			const upgradeWarnings = validUpgrades.map(
				({ name, version, upgrades, manifest }) => {
					const newVersion = upgrades.get(upgradeType);
					log(
						chalk`Upgrading {magenta ${name}} from {yellow ${version}} to {yellow ${newVersion}}`
					);

					const spawn = require('cross-spawn');
					spawn.sync(
						'yarn',
						[
							'upgrade',
							'--exact',
							'--non-interactive',
							`${name}@${newVersion}`,
						],
						{
							stdio: 'inherit',
						}
					);
					spawn.sync(
						'git',
						[
							'commit',
							'--all',
							'--message',
							`Upgrade ${name} to ${newVersion} (from ${version})`,
						],
						{ stdio: 'inherit' }
					);

					if (
						manifest.files
							.concat(manifest.resources || [])
							.some(f => !f.startsWith('node_modules'))
					) {
						return name;
					}
				}
			);

			upgradeWarnings.forEach(libraryName =>
				log.warn(
					chalk`The library {magenta ${libraryName}} has some resources that do not come from {gray node_modules}, please verify that the upgrade was complete`
				)
			);
		});
	})
);
<commit_msg>Create tag for each upgrade<commit_after>'use strict';

const gulp = require('gulp');
const log = require('fancy-log');
const chalk = require('chalk');
const ejs = require('gulp-ejs');
const zip = require('gulp-zip');
const mergeStream = require('merge-stream');
const {
	formatVersionFolder,
	compareStrings,
	formatPackageUpgrades,
	getLibraries,
	getUpgradeVersions,
} = require('./utility');

const libraries = getLibraries();

libraries.forEach(library =>
	gulp.task(library.path, () => {
		const mainFileStream = gulp.src(library.manifest.files);
		const resourceZipStream = gulp
			.src(library.manifest.resources || [])
			.pipe(zip('Resources.zip'));

		const templateData = {
			version: library.version,
			versionFolder: formatVersionFolder(library.version),
		};
		const packageFilesStream = gulp
			.src(['LICENSE.htm', 'CHANGES.htm', '*.dnn'], {
				cwd: library.path,
			})
			.pipe(ejs(templateData, { delimiter: '~' }));

		return mergeStream(
			mainFileStream,
			resourceZipStream,
			packageFilesStream
		)
			.pipe(zip(`${library.name}_${library.version}.zip`))
			.pipe(gulp.dest('./_InstallPackages/'));
	})
);

const libraryTaskNames = libraries.map(library => library.path);

gulp.task('default', libraryTaskNames);

gulp.task('outdated', () => {
	const allUpgradesPromises = libraries.map(library =>
		getUpgradeVersions(library).then(upgrades =>
			Object.assign(library, { upgrades })
		)
	);

	return Promise.all(allUpgradesPromises).then(allUpgrades => {
		const validUpgrades = allUpgrades
			.filter(({ upgrades }) => upgrades.size > 0)
			.sort(({ name: a }, { name: b }) => compareStrings(a, b));

		if (validUpgrades.length === 0) {
			log.warn(
				chalk`All {yellow ${allUpgrades.length}} packages up-to-date`
			);

			return;
		}

		log.info(`
${formatPackageUpgrades(validUpgrades)}`);
	});
});

['patch', 'minor', 'major'].forEach(upgradeType =>
	gulp.task(`upgrade-${upgradeType}`, () => {
		const allUpgradesPromises = libraries.map(library =>
			getUpgradeVersions(library).then(upgrades =>
				Object.assign(library, { upgrades })
			)
		);

		return Promise.all(allUpgradesPromises).then(allUpgrades => {
			const validUpgrades = allUpgrades.filter(({ upgrades }) =>
				upgrades.get(upgradeType)
			);

			if (validUpgrades.length === 0) {
				log.warn(`No ${upgradeType} upgrades to process`);

				return;
			}

			const upgradeWarnings = validUpgrades.map(
				({ name, version, upgrades, manifest }) => {
					const newVersion = upgrades.get(upgradeType);
					log(
						chalk`Upgrading {magenta ${name}} from {yellow ${version}} to {yellow ${newVersion}}`
					);

					const spawn = require('cross-spawn');
					spawn.sync(
						'yarn',
						[
							'upgrade',
							'--exact',
							'--non-interactive',
							`${name}@${newVersion}`,
						],
						{
							stdio: 'inherit',
						}
					);
					spawn.sync(
						'git',
						[
							'commit',
							'--all',
							'--message',
							`Upgrade ${name} to ${newVersion} (from ${version})`,
						],
						{ stdio: 'inherit' }
					);
					spawn.sync(
						'git',
						[
							'tag',
							'--sign',
							'--message',
							`Automatic ${upgradeType} upgrade of ${name} to ${newVersion} (from ${version})`,
							`${name}_${newVersion}`,
						],
						{ stdio: 'inherit' }
					);

					if (
						manifest.files
							.concat(manifest.resources || [])
							.some(f => !f.startsWith('node_modules'))
					) {
						return name;
					}
				}
			);

			upgradeWarnings.forEach(libraryName =>
				log.warn(
					chalk`The library {magenta ${libraryName}} has some resources that do not come from {gray node_modules}, please verify that the upgrade was complete`
				)
			);
		});
	})
);
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    gutil = require('gulp-util'),
    plumber = require('gulp-plumber'),
    rename = require('gulp-rename'),
    consolidate = require('gulp-consolidate'),
    concat = require('gulp-concat'),
    coffee = require('gulp-coffee'),
    imagemin = require('gulp-imagemin'),
    fontgen = require('gulp-fontgen'),
    iconfont = require('gulp-iconfont'),
    iconfontcss = require('gulp-iconfont-css'),
    sass = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    sourcemaps = require('gulp-sourcemaps'),
    gulpSequence = require('gulp-sequence').use(gulp),
    shell = require('gulp-shell'),
    livereload = require('gulp-livereload'),
    parseTwig = require('./gulp-helpers/parse-twig'),
    stripPath = require('./gulp-helpers/strip-path');

var config = {
  assetsDir:    'web/assets'
};

var minify = true;

function showStatus(task, message, type) {
  message = '--> [' + task + '] ' + message;

  if (type === 'success') {
    message = gutil.colors.green(message);
  }
  else if (type === 'warning') {
    message = gutil.colors.yellow(message);
  }
  else if (type === 'error') {
    message = gutil.colors.red(message);
  }

  gutil.log(message);
}
function showError(error) {
  showStatus('ERROR', error.message, 'error');
}
function handleWatchEvent(event) {
  showStatus('watch', 'File ' + event.path.replace(__dirname, '.') + ' was ' + event.type + '.');
}

gulp.task('coffee', function() {
  return gulp.src(
      [
        './app/Resources/assets/coffee/***.coffee',
        './src/**/Resources/assets/coffee/***.coffee',
        './vendor/sumocoders/**/Resources/assets/coffee/***.coffee'
      ]
  )
      .pipe(plumber())
      .pipe(sourcemaps.init())
      .pipe(coffee({}).on('error', gutil.log))
      .on('end', function() { showStatus('coffee', 'Coffee-files compiled', 'success')})
      .pipe(rename(function(path) {
        var end = path.dirname.indexOf('Bundle') + 6;
        var start = path.dirname.substr(0, end).lastIndexOf('/') + 1;
        var bundle = path.dirname.substr(start, end - start);

        path.dirname = '';
        path.basename = bundle.toLowerCase() + '.' + path.basename;
      }))
      .on('end', function() { showStatus('coffee', 'Coffee-files renamed', 'success')})
      .pipe(sourcemaps.write())
      .pipe(gulp.dest(config.assetsDir + '/js'))
      .on('end', function() { showStatus('coffee', 'Coffee-files saved', 'success')})
      .pipe(livereload());
});

gulp.task('js', function() {
  return gulp.src(
      [
        './app/Resources/assets/js/**',
        './src/**/Resources/assets/js/**',
        './vendor/sumocoders/**/Resources/assets/js/**'
      ]
  )
      .pipe(sourcemaps.init())
      .pipe(rename(function(path) {
        if (path.extname === '') {
          path.dirname = '';
          path.basename = '';
          return;
        }

        path.dirname = stripPath('/js/', path.dirname);
      }))
      .on('end', function() { showStatus('js', 'JS-files renamed', 'success')})
      .pipe(sourcemaps.write())
      .pipe(gulp.dest(config.assetsDir + '/js'))
      .on('end', function() { showStatus('js', 'JS-files saved', 'success')})
      .pipe(livereload());
});

gulp.task('js:concat', ['js', 'coffee'], function() {
  var action = function(grouped) {
    // loop trough all the collected js groups and concat them
    for (var destination in grouped) {
      gulp.src(grouped[destination])
        .pipe(sourcemaps.init())
        .pipe(concat(stripPath('/assets/js/', destination)))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(config.assetsDir + '/js'));
    }
  }

  return gulp.src([
    './app/Resources/views/**/*.html.twig',
    './src/**/Resources/views/**/*.html.twig',
    '/vendor/sumocoders/**/Resources/views/**/*.html.twig',
  ])
    .pipe(parseTwig(action));
});

gulp.task('images', function() {
  return gulp.src(
      [
        './app/Resources/assets/images/**',
        './src/**/Resources/assets/images/**',
        './vendor/sumocoders/**/Resources/assets/images/**'
      ]
  )
      .pipe(rename(function(path) {
        if (path.extname === '') {
          path.dirname = '';
          path.basename = '';
          return;
        }

        path.dirname = stripPath('/images/', path.dirname);
      }))
      .on('end', function() { showStatus('images', 'image-files renamed', 'success')})
      .pipe(imagemin())
      .on('end', function() { showStatus('images', 'image-files minified', 'success')})
      .pipe(gulp.dest(config.assetsDir + '/images'))
      .on('end', function() { showStatus('images', 'image-files saved', 'success')})
      .pipe(livereload());
});

gulp.task('fonts', gulpSequence(
    'del:cleanup_useless_font_css',
    'fonts:generate'
));

gulp.task('fonts:generate', function() {
  return gulp.src(
      [
        './app/Resources/assets/fonts/**/*.ttf',
        './app/Resources/assets/fonts/**/*.otf',
        './src/**/Resources/assets/fonts/**/*.ttf',
        './src/**/Resources/assets/fonts/**/*.otf',
        './vendor/sumocoders/**/Resources/assets/fonts/**/*.ttf',
        './vendor/sumocoders/**/Resources/assets/fonts/**/*.otf'
      ]
  )
      .pipe(rename(function(path) {
        path.dirname = '';
      }))
      .on('end', function() { showStatus('fonts', 'font-files renamed', 'success')})
      .pipe(gulp.dest(config.assetsDir + '/fonts'))
      .on('end', function() { showStatus('fonts', 'font-files saved', 'success')})
      .pipe(fontgen({
        dest: config.assetsDir + '/fonts'
      }))
      .on('end', function() { showStatus('fonts', 'other formats generated', 'success')})
      .pipe(livereload());
});

gulp.task('del:cleanup_useless_font_css', shell.task('rm -rf ' + config.assetsDir + '/fonts/*.css'));

gulp.task('icons', function() {
  return gulp.src(
      [
        './app/Resources/assets/icon-font/**/*.svg',
        './src/**/Resources/assets/icon-font/**/*.svg',
        './vendor/sumocoders/**/Resources/assets/icon-font/**/*.svg',
      ]
  )
      .pipe(iconfont({
        fontName:   'icons',
      }))
      .on('glyphs', function(glyphs) {
        var options = {
          glyphs: glyphs,
          fontName: 'icons',
          fontPath: '../fonts/',
          className: 'icon'
        };

        gulp.src('./src/SumoCoders/FrameworkCoreBundle/Resources/assets/sass/base/_iconfont-template.scss')
          .pipe(consolidate('lodash', options))
          .pipe(rename({ basename: '_icons' }))
          .pipe(gulp.dest('./src/SumoCoders/FrameworkCoreBundle/Resources/assets/sass/'));
      })
      .pipe(gulp.dest(config.assetsDir + '/fonts'))
      .on('end', function() { showStatus('icons', 'icon-font generated', 'success')});
});

gulp.task('sass', ['sass:generate_css']);
gulp.task('sass:generate_css', ['icons'], function() {
  var outputStyle = 'compressed';
  if (minify === false) {
    outputStyle = 'expanded';
  }

  return gulp.src(
      [
        './app/Resources/assets/sass/**',
        './src/**/Resources/assets/sass/**',
        './vendor/sumocoders/**/Resources/assets/sass/**'
      ]
  )
      .pipe(sourcemaps.init())
      .pipe(plumber())
      .pipe(sass({
        includePaths: [
          './web/assets/vendor/bootstrap-sass/assets/stylesheets',
          './web/assets/vendor'
        ],
        outputStyle:  outputStyle,
        precision: 10

      }).on('error', showError))
      .pipe(rename(function(path){ path.dirname = ''; }))
      .on('end', function() { showStatus('sass', 'SCSS-files compiled', 'success')})
      .pipe(autoprefixer({}))
      .on('end', function() { showStatus('sass', 'Added prefixes', 'success')})
      .pipe(sourcemaps.write())
      .pipe(gulp.dest(config.assetsDir + '/css'))
      .on('end', function() { showStatus('sass', 'CSS-files generated', 'success')})
      .pipe(livereload());
});
gulp.task('sass:cleanup', ['sass'], shell.task([
    'rm src/SumoCoders/FrameworkCoreBundle/Resources/assets/sass/_icons.scss'
  ])
);

gulp.task('translations', ['translations:cleanup'], function() {
  return gulp.src(
      [
        './app/Resources/translations/**',
        './src/**/Resources/translations/**',
        './vendor/sumocoders/**/Resources/assets/translations/**'
      ]
  )
      .pipe(livereload());
});
gulp.task('translations:cleanup', shell.task([
    'rm -rf ./app/cache/dev/translations'
  ])
);

gulp.task('watch', [], function() {
  minify = false;

  livereload.listen();

  gulp.watch(
      [
        './app/Resources/assets/coffee/***.coffee',
        './src/**/Resources/assets/coffee/***.coffee',
        './vendor/sumocoders/**/Resources/assets/coffee/***.coffee'
      ],
      ['coffee']
  ).on('change', handleWatchEvent);

  gulp.watch(
      [
        './app/Resources/assets/js/**',
        './src/**/Resources/assets/js/**',
        './vendor/sumocoders/**/Resources/assets/js/**'
      ],
      ['js']
  ).on('change', handleWatchEvent);

  gulp.watch(
      [
        './app/Resources/assets/images/**',
        './src/**/Resources/assets/images/**',
        './vendor/sumocoders/**/Resources/assets/images/**'
      ],
      ['images']
  ).on('change', handleWatchEvent);

  gulp.watch(
      [
        './app/Resources/assets/fonts/**/*.ttf',
        './app/Resources/assets/fonts/**/*.otf',
        './src/**/Resources/assets/fonts/**/*.ttf',
        './src/**/Resources/assets/fonts/**/*.otf',
        './vendor/sumocoders/**/Resources/assets/fonts/**/*.ttf',
        './vendor/sumocoders/**/Resources/assets/fonts/**/*.otf'
      ],
      ['fonts']
  ).on('change', handleWatchEvent);

  gulp.watch(
      [
        './app/Resources/assets/icon-font/**/*.svg',
        './src/**/Resources/assets/icon-font/**/*.svg',
        './vendor/sumocoders/**/Resources/assets/icon-font/**/*.svg',
        './app/Resources/assets/sass/**',
        './src/**/Resources/assets/sass/**',
        './vendor/sumocoders/**/Resources/assets/sass/**'
      ],
      ['sass','sass:cleanup']
  ).on('change', handleWatchEvent);
  gulp.watch(
      [
        './app/Resources/translations/**',
        './src/**/Resources/translations/**',
        './vendor/sumocoders/**/Resources/assets/translations/**'
      ],
      ['translations']
  ).on('change', handleWatchEvent);

});

// public tasks
gulp.task('default', function() {
  gulp.start('build');
});

gulp.task('build', function() {
  gulp.start('coffee', 'js', 'js:concat', 'images', 'fonts', 'sass', 'sass:cleanup');
});

gulp.task('serve', function() {
  gulp.start('watch');
});
<commit_msg>Watch the twig files.<commit_after>var gulp = require('gulp'),
    gutil = require('gulp-util'),
    plumber = require('gulp-plumber'),
    rename = require('gulp-rename'),
    consolidate = require('gulp-consolidate'),
    concat = require('gulp-concat'),
    coffee = require('gulp-coffee'),
    imagemin = require('gulp-imagemin'),
    fontgen = require('gulp-fontgen'),
    iconfont = require('gulp-iconfont'),
    iconfontcss = require('gulp-iconfont-css'),
    sass = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    sourcemaps = require('gulp-sourcemaps'),
    gulpSequence = require('gulp-sequence').use(gulp),
    shell = require('gulp-shell'),
    livereload = require('gulp-livereload'),
    parseTwig = require('./gulp-helpers/parse-twig'),
    stripPath = require('./gulp-helpers/strip-path');

var config = {
  assetsDir:    'web/assets'
};

var minify = true;

function showStatus(task, message, type) {
  message = '--> [' + task + '] ' + message;

  if (type === 'success') {
    message = gutil.colors.green(message);
  }
  else if (type === 'warning') {
    message = gutil.colors.yellow(message);
  }
  else if (type === 'error') {
    message = gutil.colors.red(message);
  }

  gutil.log(message);
}
function showError(error) {
  showStatus('ERROR', error.message, 'error');
}
function handleWatchEvent(event) {
  showStatus('watch', 'File ' + event.path.replace(__dirname, '.') + ' was ' + event.type + '.');
}

gulp.task('coffee', function() {
  return gulp.src(
      [
        './app/Resources/assets/coffee/***.coffee',
        './src/**/Resources/assets/coffee/***.coffee',
        './vendor/sumocoders/**/Resources/assets/coffee/***.coffee'
      ]
  )
      .pipe(plumber())
      .pipe(sourcemaps.init())
      .pipe(coffee({}).on('error', gutil.log))
      .on('end', function() { showStatus('coffee', 'Coffee-files compiled', 'success')})
      .pipe(rename(function(path) {
        var end = path.dirname.indexOf('Bundle') + 6;
        var start = path.dirname.substr(0, end).lastIndexOf('/') + 1;
        var bundle = path.dirname.substr(start, end - start);

        path.dirname = '';
        path.basename = bundle.toLowerCase() + '.' + path.basename;
      }))
      .on('end', function() { showStatus('coffee', 'Coffee-files renamed', 'success')})
      .pipe(sourcemaps.write())
      .pipe(gulp.dest(config.assetsDir + '/js'))
      .on('end', function() { showStatus('coffee', 'Coffee-files saved', 'success')})
      .pipe(livereload());
});

gulp.task('js', function() {
  return gulp.src(
      [
        './app/Resources/assets/js/**',
        './src/**/Resources/assets/js/**',
        './vendor/sumocoders/**/Resources/assets/js/**'
      ]
  )
      .pipe(sourcemaps.init())
      .pipe(rename(function(path) {
        if (path.extname === '') {
          path.dirname = '';
          path.basename = '';
          return;
        }

        path.dirname = stripPath('/js/', path.dirname);
      }))
      .on('end', function() { showStatus('js', 'JS-files renamed', 'success')})
      .pipe(sourcemaps.write())
      .pipe(gulp.dest(config.assetsDir + '/js'))
      .on('end', function() { showStatus('js', 'JS-files saved', 'success')})
      .pipe(livereload());
});

gulp.task('js:concat', ['js', 'coffee'], function() {
  var action = function(grouped) {
    // loop trough all the collected js groups and concat them
    for (var destination in grouped) {
      gulp.src(grouped[destination])
        .pipe(sourcemaps.init())
        .pipe(concat(stripPath('/assets/js/', destination)))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(config.assetsDir + '/js'));
    }
  }

  return gulp.src([
    './app/Resources/views/**/*.html.twig',
    './src/**/Resources/views/**/*.html.twig',
    '/vendor/sumocoders/**/Resources/views/**/*.html.twig',
  ])
    .pipe(parseTwig(action));
});

gulp.task('images', function() {
  return gulp.src(
      [
        './app/Resources/assets/images/**',
        './src/**/Resources/assets/images/**',
        './vendor/sumocoders/**/Resources/assets/images/**'
      ]
  )
      .pipe(rename(function(path) {
        if (path.extname === '') {
          path.dirname = '';
          path.basename = '';
          return;
        }

        path.dirname = stripPath('/images/', path.dirname);
      }))
      .on('end', function() { showStatus('images', 'image-files renamed', 'success')})
      .pipe(imagemin())
      .on('end', function() { showStatus('images', 'image-files minified', 'success')})
      .pipe(gulp.dest(config.assetsDir + '/images'))
      .on('end', function() { showStatus('images', 'image-files saved', 'success')})
      .pipe(livereload());
});

gulp.task('fonts', gulpSequence(
    'del:cleanup_useless_font_css',
    'fonts:generate'
));

gulp.task('fonts:generate', function() {
  return gulp.src(
      [
        './app/Resources/assets/fonts/**/*.ttf',
        './app/Resources/assets/fonts/**/*.otf',
        './src/**/Resources/assets/fonts/**/*.ttf',
        './src/**/Resources/assets/fonts/**/*.otf',
        './vendor/sumocoders/**/Resources/assets/fonts/**/*.ttf',
        './vendor/sumocoders/**/Resources/assets/fonts/**/*.otf'
      ]
  )
      .pipe(rename(function(path) {
        path.dirname = '';
      }))
      .on('end', function() { showStatus('fonts', 'font-files renamed', 'success')})
      .pipe(gulp.dest(config.assetsDir + '/fonts'))
      .on('end', function() { showStatus('fonts', 'font-files saved', 'success')})
      .pipe(fontgen({
        dest: config.assetsDir + '/fonts'
      }))
      .on('end', function() { showStatus('fonts', 'other formats generated', 'success')})
      .pipe(livereload());
});

gulp.task('del:cleanup_useless_font_css', shell.task('rm -rf ' + config.assetsDir + '/fonts/*.css'));

gulp.task('icons', function() {
  return gulp.src(
      [
        './app/Resources/assets/icon-font/**/*.svg',
        './src/**/Resources/assets/icon-font/**/*.svg',
        './vendor/sumocoders/**/Resources/assets/icon-font/**/*.svg',
      ]
  )
      .pipe(iconfont({
        fontName:   'icons',
      }))
      .on('glyphs', function(glyphs) {
        var options = {
          glyphs: glyphs,
          fontName: 'icons',
          fontPath: '../fonts/',
          className: 'icon'
        };

        gulp.src('./src/SumoCoders/FrameworkCoreBundle/Resources/assets/sass/base/_iconfont-template.scss')
          .pipe(consolidate('lodash', options))
          .pipe(rename({ basename: '_icons' }))
          .pipe(gulp.dest('./src/SumoCoders/FrameworkCoreBundle/Resources/assets/sass/'));
      })
      .pipe(gulp.dest(config.assetsDir + '/fonts'))
      .on('end', function() { showStatus('icons', 'icon-font generated', 'success')});
});

gulp.task('sass', ['sass:generate_css']);
gulp.task('sass:generate_css', ['icons'], function() {
  var outputStyle = 'compressed';
  if (minify === false) {
    outputStyle = 'expanded';
  }

  return gulp.src(
      [
        './app/Resources/assets/sass/**',
        './src/**/Resources/assets/sass/**',
        './vendor/sumocoders/**/Resources/assets/sass/**'
      ]
  )
      .pipe(sourcemaps.init())
      .pipe(plumber())
      .pipe(sass({
        includePaths: [
          './web/assets/vendor/bootstrap-sass/assets/stylesheets',
          './web/assets/vendor'
        ],
        outputStyle:  outputStyle,
        precision: 10

      }).on('error', showError))
      .pipe(rename(function(path){ path.dirname = ''; }))
      .on('end', function() { showStatus('sass', 'SCSS-files compiled', 'success')})
      .pipe(autoprefixer({}))
      .on('end', function() { showStatus('sass', 'Added prefixes', 'success')})
      .pipe(sourcemaps.write())
      .pipe(gulp.dest(config.assetsDir + '/css'))
      .on('end', function() { showStatus('sass', 'CSS-files generated', 'success')})
      .pipe(livereload());
});
gulp.task('sass:cleanup', ['sass'], shell.task([
    'rm src/SumoCoders/FrameworkCoreBundle/Resources/assets/sass/_icons.scss'
  ])
);

gulp.task('translations', ['translations:cleanup'], function() {
  return gulp.src(
      [
        './app/Resources/translations/**',
        './src/**/Resources/translations/**',
        './vendor/sumocoders/**/Resources/assets/translations/**'
      ]
  )
      .pipe(livereload());
});
gulp.task('translations:cleanup', shell.task([
    'rm -rf ./app/cache/dev/translations'
  ])
);

gulp.task('watch', [], function() {
  minify = false;

  livereload.listen();

  gulp.watch(
      [
        './app/Resources/assets/coffee/***.coffee',
        './src/**/Resources/assets/coffee/***.coffee',
        './vendor/sumocoders/**/Resources/assets/coffee/***.coffee'
      ],
      ['coffee']
  ).on('change', handleWatchEvent);

  gulp.watch(
      [
        './app/Resources/assets/js/**',
        './src/**/Resources/assets/js/**',
        './vendor/sumocoders/**/Resources/assets/js/**'
      ],
      ['js']
  ).on('change', handleWatchEvent);

  gulp.watch(
      [
        './app/Resources/views/**/*.html.twig',
        './src/**/Resources/views/**/*.html.twig',
        '/vendor/sumocoders/**/Resources/views/**/*.html.twig',
      ],
      ['js:concat']
  ).on('change', handleWatchEvent);

  gulp.watch(
      [
        './app/Resources/assets/images/**',
        './src/**/Resources/assets/images/**',
        './vendor/sumocoders/**/Resources/assets/images/**'
      ],
      ['images']
  ).on('change', handleWatchEvent);

  gulp.watch(
      [
        './app/Resources/assets/fonts/**/*.ttf',
        './app/Resources/assets/fonts/**/*.otf',
        './src/**/Resources/assets/fonts/**/*.ttf',
        './src/**/Resources/assets/fonts/**/*.otf',
        './vendor/sumocoders/**/Resources/assets/fonts/**/*.ttf',
        './vendor/sumocoders/**/Resources/assets/fonts/**/*.otf'
      ],
      ['fonts']
  ).on('change', handleWatchEvent);

  gulp.watch(
      [
        './app/Resources/assets/icon-font/**/*.svg',
        './src/**/Resources/assets/icon-font/**/*.svg',
        './vendor/sumocoders/**/Resources/assets/icon-font/**/*.svg',
        './app/Resources/assets/sass/**',
        './src/**/Resources/assets/sass/**',
        './vendor/sumocoders/**/Resources/assets/sass/**'
      ],
      ['sass','sass:cleanup']
  ).on('change', handleWatchEvent);
  gulp.watch(
      [
        './app/Resources/translations/**',
        './src/**/Resources/translations/**',
        './vendor/sumocoders/**/Resources/assets/translations/**'
      ],
      ['translations']
  ).on('change', handleWatchEvent);

});

// public tasks
gulp.task('default', function() {
  gulp.start('build');
});

gulp.task('build', function() {
  gulp.start('coffee', 'js', 'js:concat', 'images', 'fonts', 'sass', 'sass:cleanup');
});

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


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

var clean = require('gulp-clean');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var browserSync = require('browser-sync').create();
var surge = require('gulp-surge');
var concat = require('gulp-concat');

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

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

gulp.task('csscompile', ['cssclean'], function(){
	return gulp
		.src('src/sass/index.scss')
		.pipe(sass().on('error', sass.logError))
		.pipe(sourcemaps.init())
		.pipe(postcss([autoprefixer()]))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('dist'))
		.pipe(browserSync.stream());
});

gulp.task('jsconcat', ['jsclean'], function(){
	return gulp.src([
		'src/js/highlight.pack.js',
		'src/js/jquery-3.1.1.min.js',
		// 'src/js/toc.min.js',
		'src/js/marked.js',
		'src/js/flat-file.js'
	])
		.pipe(concat('all.js'))
		.pipe(gulp.dest('dist'));
});

gulp.task('develop', ['distprep'], function(){
	browserSync.init({
		server: {
			baseDir: './',
			serveStaticOptions: {
				extensions: ['html']
			}
		},
		port: 3030,
		files: [
			'*.html',
			'lekce/**/*.(html|md)',
			'dist/**/*.css',
			'dist/**/*.js'
		]
	});

	gulp.watch('src/sass/*.scss', ['csscompile']);
	gulp.watch('src/js/*.js', ['jsconcat']);
});

gulp.task('distprep', ['csscompile', 'jsconcat']);

gulp.task('deploy', ['distprep'], function(){
	return surge({
		project: './',
		domain: 'webkurz.pyladies.cz'
	})
});

gulp.task('default', ['develop']);
<commit_msg>REFACTOR: TOC removal<commit_after>var gulp = require('gulp');

var clean = require('gulp-clean');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var browserSync = require('browser-sync').create();
var surge = require('gulp-surge');
var concat = require('gulp-concat');

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

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

gulp.task('csscompile', ['cssclean'], function(){
	return gulp
		.src('src/sass/index.scss')
		.pipe(sass().on('error', sass.logError))
		.pipe(sourcemaps.init())
		.pipe(postcss([autoprefixer()]))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('dist'))
		.pipe(browserSync.stream());
});

gulp.task('jsconcat', ['jsclean'], function(){
	return gulp.src([
		'src/js/highlight.pack.js',
		'src/js/jquery-3.1.1.min.js',
		'src/js/marked.js',
		'src/js/flat-file.js'
	])
		.pipe(concat('all.js'))
		.pipe(gulp.dest('dist'));
});

gulp.task('develop', ['distprep'], function(){
	browserSync.init({
		server: {
			baseDir: './',
			serveStaticOptions: {
				extensions: ['html']
			}
		},
		port: 3030,
		files: [
			'*.html',
			'lekce/**/*.(html|md)',
			'dist/**/*.css',
			'dist/**/*.js'
		]
	});

	gulp.watch('src/sass/*.scss', ['csscompile']);
	gulp.watch('src/js/*.js', ['jsconcat']);
});

gulp.task('distprep', ['csscompile', 'jsconcat']);

gulp.task('deploy', ['distprep'], function(){
	return surge({
		project: './',
		domain: 'webkurz.pyladies.cz'
	})
});

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


<commit_before>var gulp = require('gulp');
var babel = require('gulp-babel');
var jshint = require('gulp-jshint');
var nodemon = require('gulp-nodemon');
var uglify = require('gulp-uglify');
var mocha = require('gulp-mocha');
var webpack = require('webpack-stream');

gulp.task('build', ['build-client', 'build-server', 'test']);

gulp.task('test', ['lint-client', 'lint-server'], function () {
    gulp.src(['test/**/*.js'])
        .pipe(mocha());
});

gulp.task('lint-client', function () {
  return gulp.src('client/js/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('default', { verbose: true}));
});

gulp.task('build-client', ['lint-client', 'move-client'], function () {
  return gulp.src(['client/js/app.js'])
    .pipe(webpack(require('./webpack.config.js')))
    //.pipe(uglify())
    .pipe(gulp.dest('bin/client/js/'));
});

gulp.task('move-client', function () {
  return gulp.src(['client/**/*.*', '!client/js/*.js'])
    .pipe(gulp.dest('./bin/client/'));
});

gulp.task('lint-server', function () {
  return gulp.src('server/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('default', { verbose: true}));
});

gulp.task('build-server', ['lint-server', 'move-server'], function () {
  return gulp.src('server/*.js')
    .pipe(gulp.dest('bin/server/'));
});

gulp.task('move-server', function () {
  return gulp.src(['server/**/*.*', 'server/**/*.js'])
    .pipe(gulp.dest('./bin/server/'));
});

gulp.task('watch', ["build"], function () {
  gulp.watch('client/**/*.*', ['build-client', 'move-client']);
  gulp.watch('server/*.*', 'server/**/*.js', ['build-server']);
  gulp.start("run");
});

gulp.task('run', ["build"], function () {
    nodemon({
        delay: 10,
        script: 'server/server.js',
        cwd: "./bin/",
        args: ["/server/config.json"],
        ext: 'html js css'
    })
    .on('restart', function () {
        console.log('restarted!');
    });
});
<commit_msg>Unify lint-client and lint-server to lint.<commit_after>var gulp = require('gulp');
var babel = require('gulp-babel');
var jshint = require('gulp-jshint');
var nodemon = require('gulp-nodemon');
var uglify = require('gulp-uglify');
var mocha = require('gulp-mocha');
var webpack = require('webpack-stream');

gulp.task('build', ['build-client', 'build-server', 'test']);

gulp.task('test', ['lint'], function () {
    gulp.src(['test/**/*.js'])
        .pipe(mocha());
});

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

gulp.task('build-client', ['lint', 'move-client'], function () {
  return gulp.src(['client/js/app.js'])
    .pipe(webpack(require('./webpack.config.js')))
    //.pipe(uglify())
    .pipe(gulp.dest('bin/client/js/'));
});

gulp.task('move-client', function () {
  return gulp.src(['client/**/*.*', '!client/js/*.js'])
    .pipe(gulp.dest('./bin/client/'));
});

gulp.task('build-server', ['lint', 'move-server'], function () {
  return gulp.src('server/*.js')
    .pipe(gulp.dest('bin/server/'));
});

gulp.task('move-server', function () {
  return gulp.src(['server/**/*.*', 'server/**/*.js'])
    .pipe(gulp.dest('./bin/server/'));
});

gulp.task('watch', ["build"], function () {
  gulp.watch('client/**/*.*', ['build-client', 'move-client']);
  gulp.watch('server/*.*', 'server/**/*.js', ['build-server']);
  gulp.start("run");
});

gulp.task('run', ["build"], function () {
    nodemon({
        delay: 10,
        script: 'server/server.js',
        cwd: "./bin/",
        args: ["/server/config.json"],
        ext: 'html js css'
    })
    .on('restart', function () {
        console.log('restarted!');
    });
});
<|endoftext|>