<commit_before>var gulp = require('gulp');
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var url = require('url');
var proxy = require('proxy-middleware');
var modRewrite = require('connect-modrewrite');
var reload = browserSync.reload;
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var sort = require('gulp-sort');
var addSrc = require('gulp-add-src');
var minifyCss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var argv = require('yargs').argv;
var ngHtml2Js = require("gulp-ng-html2js");
var minifyHtml = require("gulp-minify-html");
var replace = require('gulp-replace');

var paths = {
    "build": 'dist/',
    "lib": "node_modules/"
};

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

var cssDeps = [
    //paths.lib + 'bootstrap-css-only/css/bootstrap.min.css'
];

var jsDeps = [
    paths.lib + 'd3/d3.min.js',
    paths.lib + 'angular/angular.min.js',
    paths.lib + 'angular-route/angular-route.min.js',
    paths.lib + 'angular-ui-bootstrap/dist/ui-bootstrap.js',
    paths.lib + 'angular-resource/angular-resource.min.js',
    paths.lib + 'angular-i18n/angular-locale_de-de.js',
    paths.lib + 'idai-components/dist/idai-components.min.js'
];

gulp.task('compile-css', function () {

    return gulp.src('scss/app.scss')
        .pipe(sass({
            includePaths: [
                paths.lib + 'bootstrap-sass/assets/stylesheets/',
                paths.lib + 'idai-components/src/scss/'
            ],
            precision: 8
        }))
        .pipe(addSrc(cssDeps))
        .pipe(concat(pkg.name + '.css'))
        .pipe(gulp.dest(paths.build + '/css'))
        .pipe(reload({stream: true}));
});

// minify css files in build dir
gulp.task('minify-css', ['compile-css'], function () {

    return gulp.src('dist/css/*.css')
        .pipe(minifyCss())
        .pipe(concat(pkg.name + '.min.css'))
        .pipe(gulp.dest('dist/css'));
});

// concatenates and minifies all dependecies into a single file in build dir
gulp.task('concat-deps', function () {

    return gulp.src(jsDeps)
        .pipe(concat(pkg.name + '-deps.js'))
        //.pipe(uglify())
        .pipe(gulp.dest('dist/js/'));
});

// concatenates all js files in src into a single file in build dir
gulp.task('concat-js', function () {

    return gulp.src(['js/**/*.js'])
        .pipe(sort())
        .pipe(concat(pkg.name + '.js'))
        .pipe(gulp.dest('dist/js/'))
        .pipe(reload({stream: true}));
});

// converts, minifies and concatenates html partials
// to a single js file in build dir
gulp.task('html2js', function () {

    return gulp.src('partials/**/*.html')
        .pipe(minifyHtml())
        .pipe(ngHtml2Js({moduleName: pkg.name + '.templates', prefix: 'partials/'}))
        .pipe(concat(pkg.name + '-tpls.js'))
        .pipe(gulp.dest('dist/js'));
});

// minifies and concatenates js files in build dir
gulp.task('minify-js', ['concat-js', 'html2js'], function () {

    return gulp.src([paths.build + 'js/' + pkg.name + '.js',
        paths.build + pkg.name + '-tpls.js'])
        .pipe(concat(pkg.name + '.js'))
        .pipe(gulp.dest(paths.build + 'js'))
        .pipe(uglify())
        .pipe(concat(pkg.name + '.min.js'))
        .pipe(gulp.dest(paths.build + 'js'));
});

gulp.task('copy-fonts', function () {

    var bsFontPath = paths.lib + 'bootstrap-sass/assets/fonts/';
    return gulp.src(bsFontPath + '**/*', {base: bsFontPath})
        .pipe(gulp.dest(paths.build + '/fonts'));
});

gulp.task('copy-imgs', function () {

    return gulp.src('img/**/*', {base: 'img'})
        .pipe(gulp.dest(paths.build + '/img'));
});

gulp.task('copy-partials', function () {

    return gulp.src('partials/**/*', {base: 'partials'})
        .pipe(gulp.dest(paths.build + '/partials'));
});

gulp.task('copy-resources', ['copy-fonts', 'copy-imgs', 'copy-index', 'copy-info', 'copy-config', 'copy-partials']);

// copy index.html to dist and set version
gulp.task('copy-index', function () {

    var buildNo = "SNAPSHOT";
    if (argv.build) buildNo = argv.build;
    var versionString = pkg.version + " (build #" + buildNo + ")";
    gulp.src(['index.html'])
        .pipe(replace(/version="[^"]*"/g, 'version="v' + versionString + '"'))
        .pipe(replace(/build=BUILD_NO/g, 'build=' + buildNo))
        .pipe(gulp.dest(paths.build));
});

gulp.task('copy-info', function () {

    return gulp.src('info/**/*', {base: 'info'})
        .pipe(gulp.dest(paths.build + '/info'));
});

gulp.task('copy-config', function () {

    return gulp.src('config/**/*', {base: 'config'})
        .pipe(gulp.dest(paths.build + '/config'));
});

gulp.task('build', [
    'minify-css',
    'concat-deps',
    'minify-js',
    'copy-resources'
]);

// clean
gulp.task('clean', function () {

    return del(paths.build + '/**/*');
});

// runs the development server and sets up browser reloading
gulp.task('server', ['compile-css', 'minify-js', 'concat-deps', 'copy-resources'], function () {

    var proxyOptions = url.parse('http://localhost:4567/');
    proxyOptions.route = '/data';

    browserSync({
        server: {
            baseDir: 'dist',
            middleware: [
                proxy(proxyOptions),
                // rewrite for AngularJS HTML5 mode, redirect all non-file urls to index.html
                modRewrite(['!\\.html|\\.js|\\.svg|\\.css|\\.png|\\.jpg|\\.gif|\\.json|\\.woff2|\\.woff|\\.ttf$ /index.html [L]']),
            ]
        },
        port: 1238
    });

    gulp.watch('scss/**/*.scss', ['compile-css']);
    gulp.watch('js/**/*.js', ['minify-js']);
    gulp.watch('partials/**/*.html', ['minify-js']);
    gulp.watch('index.html', ['copy-index']);

    gulp.watch(['index.html', 'partials/**/*.html', 'js/**/*.js'], reload);
});

gulp.task('default', function () {
    runSequence('clean', 'build');
});<commit_msg>Copy partials on changes.<commit_after>var gulp = require('gulp');
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var url = require('url');
var proxy = require('proxy-middleware');
var modRewrite = require('connect-modrewrite');
var reload = browserSync.reload;
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var sort = require('gulp-sort');
var addSrc = require('gulp-add-src');
var minifyCss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var argv = require('yargs').argv;
var ngHtml2Js = require("gulp-ng-html2js");
var minifyHtml = require("gulp-minify-html");
var replace = require('gulp-replace');

var paths = {
    "build": 'dist/',
    "lib": "node_modules/"
};

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

var cssDeps = [
    //paths.lib + 'bootstrap-css-only/css/bootstrap.min.css'
];

var jsDeps = [
    paths.lib + 'd3/d3.min.js',
    paths.lib + 'angular/angular.min.js',
    paths.lib + 'angular-route/angular-route.min.js',
    paths.lib + 'angular-ui-bootstrap/dist/ui-bootstrap.js',
    paths.lib + 'angular-resource/angular-resource.min.js',
    paths.lib + 'angular-i18n/angular-locale_de-de.js',
    paths.lib + 'idai-components/dist/idai-components.min.js'
];

gulp.task('compile-css', function () {

    return gulp.src('scss/app.scss')
        .pipe(sass({
            includePaths: [
                paths.lib + 'bootstrap-sass/assets/stylesheets/',
                paths.lib + 'idai-components/src/scss/'
            ],
            precision: 8
        }))
        .pipe(addSrc(cssDeps))
        .pipe(concat(pkg.name + '.css'))
        .pipe(gulp.dest(paths.build + '/css'))
        .pipe(reload({stream: true}));
});

// minify css files in build dir
gulp.task('minify-css', ['compile-css'], function () {

    return gulp.src('dist/css/*.css')
        .pipe(minifyCss())
        .pipe(concat(pkg.name + '.min.css'))
        .pipe(gulp.dest('dist/css'));
});

// concatenates and minifies all dependecies into a single file in build dir
gulp.task('concat-deps', function () {

    return gulp.src(jsDeps)
        .pipe(concat(pkg.name + '-deps.js'))
        //.pipe(uglify())
        .pipe(gulp.dest('dist/js/'));
});

// concatenates all js files in src into a single file in build dir
gulp.task('concat-js', function () {

    return gulp.src(['js/**/*.js'])
        .pipe(sort())
        .pipe(concat(pkg.name + '.js'))
        .pipe(gulp.dest('dist/js/'))
        .pipe(reload({stream: true}));
});

// converts, minifies and concatenates html partials
// to a single js file in build dir
gulp.task('html2js', function () {

    return gulp.src('partials/**/*.html')
        .pipe(minifyHtml())
        .pipe(ngHtml2Js({moduleName: pkg.name + '.templates', prefix: 'partials/'}))
        .pipe(concat(pkg.name + '-tpls.js'))
        .pipe(gulp.dest('dist/js'));
});

// minifies and concatenates js files in build dir
gulp.task('minify-js', ['concat-js', 'html2js'], function () {

    return gulp.src([paths.build + 'js/' + pkg.name + '.js',
        paths.build + pkg.name + '-tpls.js'])
        .pipe(concat(pkg.name + '.js'))
        .pipe(gulp.dest(paths.build + 'js'))
        .pipe(uglify())
        .pipe(concat(pkg.name + '.min.js'))
        .pipe(gulp.dest(paths.build + 'js'));
});

gulp.task('copy-fonts', function () {

    var bsFontPath = paths.lib + 'bootstrap-sass/assets/fonts/';
    return gulp.src(bsFontPath + '**/*', {base: bsFontPath})
        .pipe(gulp.dest(paths.build + '/fonts'));
});

gulp.task('copy-imgs', function () {

    return gulp.src('img/**/*', {base: 'img'})
        .pipe(gulp.dest(paths.build + '/img'));
});

gulp.task('copy-partials', function () {

    return gulp.src('partials/**/*', {base: 'partials'})
        .pipe(gulp.dest(paths.build + '/partials'));
});

gulp.task('copy-resources', ['copy-fonts', 'copy-imgs', 'copy-index', 'copy-info', 'copy-config', 'copy-partials']);

// copy index.html to dist and set version
gulp.task('copy-index', function () {

    var buildNo = "SNAPSHOT";
    if (argv.build) buildNo = argv.build;
    var versionString = pkg.version + " (build #" + buildNo + ")";
    gulp.src(['index.html'])
        .pipe(replace(/version="[^"]*"/g, 'version="v' + versionString + '"'))
        .pipe(replace(/build=BUILD_NO/g, 'build=' + buildNo))
        .pipe(gulp.dest(paths.build));
});

gulp.task('copy-info', function () {

    return gulp.src('info/**/*', {base: 'info'})
        .pipe(gulp.dest(paths.build + '/info'));
});

gulp.task('copy-config', function () {

    return gulp.src('config/**/*', {base: 'config'})
        .pipe(gulp.dest(paths.build + '/config'));
});

gulp.task('build', [
    'minify-css',
    'concat-deps',
    'minify-js',
    'copy-resources'
]);

// clean
gulp.task('clean', function () {

    return del(paths.build + '/**/*');
});

// runs the development server and sets up browser reloading
gulp.task('server', ['compile-css', 'minify-js', 'concat-deps', 'copy-resources'], function () {

    var proxyOptions = url.parse('http://localhost:4567/');
    proxyOptions.route = '/data';

    browserSync({
        server: {
            baseDir: 'dist',
            middleware: [
                proxy(proxyOptions),
                // rewrite for AngularJS HTML5 mode, redirect all non-file urls to index.html
                modRewrite(['!\\.html|\\.js|\\.svg|\\.css|\\.png|\\.jpg|\\.gif|\\.json|\\.woff2|\\.woff|\\.ttf$ /index.html [L]']),
            ]
        },
        port: 1238
    });

    gulp.watch('scss/**/*.scss', ['compile-css']);
    gulp.watch('js/**/*.js', ['minify-js']);
    gulp.watch('partials/**/*.html', ['minify-js', 'copy-partials']);
    gulp.watch('index.html', ['copy-index']);

    gulp.watch(['index.html', 'partials/**/*.html', 'js/**/*.js'], reload);
});

gulp.task('default', function () {
    runSequence('clean', 'build');
});
{'fraction_non_alphanumeric': 0.217191879724794, 'fraction_numerical': 0.00339760468869447, 'mean_word_length': 2.861593965234503, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1138992', 'n_tokens_mistral': 4163, 'n_tokens_neox': 4054, 'n_words': 732}