<commit_before>/* eslint-env node */

"use strict";
module.exports = function (grunt) {
    // boomerang.js and plugins/*.js order
    var src = [ "boomerang.js" ];
    var plugins = grunt.file.readJSON("plugins.json");
    src.push(plugins.plugins);
    src.push("plugins/zzz_last_plugin.js");

    grunt.initConfig({
        pkg:  grunt.file.readJSON("package.json"),
        buildDate: Math.round(Date.now() / 1000),
        concat: {
            options: {
                stripBanners: false,
                seperator: ";"
            },
            debug: {
                src: src,
                dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.js"
            },
            release: {
                src: src,
                dest: "build/<%= pkg.name %>-<%= buildDate %>.js"
            }
        },
        eslint: {
            target: [
                "Gruntfile.js",
                "boomerang.js",
                "plugins/*.js",
                "tests/unit/*.js",
                "tests/e2e/*.js"
            ]
        },
        "string-replace": {
            all: {
                files: [
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>.js"
                    },
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>-debug.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.js"
                    }
                ],
                options: {
                    replacements: [
                        {
                            // Replace 0.9 with 0.9.[date]
                            pattern: /BOOMR.version\s*=\s*".*";/,
                            replacement: "BOOMR.version = \"<%= buildDate %>\";"
                        },
                        {
                            // strip out BOOMR = BOOMR || {}; in plugins
                            pattern: /BOOMR\s*=\s*BOOMR\s*\|\|\s*{};/g,
                            replacement: ""
                        },
                        {
                            // strip out BOOMR.plugins = BOOMR.plugins || {}; in plugins
                            pattern: /BOOMR\.plugins\s*=\s*BOOMR\.plugins\s*\|\|\s*{};/g,
                            replacement: ""
                        }
                    ]
                }
            },
            debug: {
                files: [{
                    src: "build/<%= pkg.name %>-<%= buildDate %>-debug.js",
                    dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.js"
                }],
                options: {
                    replacements: [
                        {
                            // Add &debug key to request
                            pattern: /key=%client_apikey%/,
                            replacement: "debug=\&key=%client_apikey%"
                        }
                    ]
                }
            },
            release: {
                files: [{
                    src: "build/<%= pkg.name %>-<%= buildDate %>.js",
                    dest: "build/<%= pkg.name %>-<%= buildDate %>.js"
                }],
                options: {
                    // strip out some NOPs
                    replacements: [
                        {
                            pattern: /else{}/g,
                            replacement: ""
                        },
                        {
                            pattern: /\(window\)\);/g,
                            replacement: "\(window\)\);\n"
                        },
                        {
                            pattern: /\(\)\);\(function\(/g,
                            replacement: "\(\)\);\n(function("
                        }
                    ]
                }
            }
        },
        copy: {
            // copy files to tests\build\boomerang-latest.js so test/index.html points to the latest version always
            latest: {
                files: [
                    {
                        nonull: true,
                        src: "build/<%= pkg.name %>-<%= buildDate %>-debug.js",
                        dest: "tests/build/<%= pkg.name %>-latest-debug.js"
                    }
                ]
            }
        },
        uglify: {
            options: {
                preserveComments: false,
                mangle: true,
                sourceMap: true
            },
            min_release: {
                src: "build/<%= pkg.name %>-<%= buildDate %>.js",
                dest: "build/<%= pkg.name %>-<%= buildDate %>.min.js"
            },
            min_debug: {
                src: "build/<%= pkg.name %>-<%= buildDate %>-debug.js",
                dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.min.js"
            }
        },
        compress: {
            main: {
                options: {
                    mode: "gzip",
                    level: 9
                },
                files: [
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>.js.gz"
                    },
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>-debug.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.js.gz"
                    },
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>.min.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>.min.js.gz"
                    },
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>-debug.min.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.min.js.gz"
                    }
                ]
            }
        },
        filesize: {
            files: [ "build/<%= pkg.name %>-<%= buildDate %>.min.js.gz" ]
        },
        clean: {
            options: {},
            build: ["build/", "tests/build/"],
            src: ["plugins/*~", "*.js~"]
        },
        karma: {
            options: {
                singleRun: true,
                colors: true,
                configFile: "./karma.config.js",
                preprocessors: {
                    "./tests/build/*.js": ["coverage"]
                },
                basePath: "./",
                files: [
                    "tests/vendor/mocha/mocha.css",
                    "tests/vendor/mocha/mocha.js",
                    "tests/vendor/chai/chai.js",
                    "tests/vendor/expect/index.js",
                    "tests/unit/*.js",
                    "tests/build/*.js"
                ]
            },
            unit: {
                browsers: ["PhantomJS"],
                frameworks: ["mocha"]
            },<commit_msg>grunt clean should clean up results and coverage<commit_after>/* eslint-env node */

"use strict";
module.exports = function (grunt) {
    // boomerang.js and plugins/*.js order
    var src = [ "boomerang.js" ];
    var plugins = grunt.file.readJSON("plugins.json");
    src.push(plugins.plugins);
    src.push("plugins/zzz_last_plugin.js");

    grunt.initConfig({
        pkg:  grunt.file.readJSON("package.json"),
        buildDate: Math.round(Date.now() / 1000),
        concat: {
            options: {
                stripBanners: false,
                seperator: ";"
            },
            debug: {
                src: src,
                dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.js"
            },
            release: {
                src: src,
                dest: "build/<%= pkg.name %>-<%= buildDate %>.js"
            }
        },
        eslint: {
            target: [
                "Gruntfile.js",
                "boomerang.js",
                "plugins/*.js",
                "tests/unit/*.js",
                "tests/e2e/*.js"
            ]
        },
        "string-replace": {
            all: {
                files: [
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>.js"
                    },
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>-debug.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.js"
                    }
                ],
                options: {
                    replacements: [
                        {
                            // Replace 0.9 with 0.9.[date]
                            pattern: /BOOMR.version\s*=\s*".*";/,
                            replacement: "BOOMR.version = \"<%= buildDate %>\";"
                        },
                        {
                            // strip out BOOMR = BOOMR || {}; in plugins
                            pattern: /BOOMR\s*=\s*BOOMR\s*\|\|\s*{};/g,
                            replacement: ""
                        },
                        {
                            // strip out BOOMR.plugins = BOOMR.plugins || {}; in plugins
                            pattern: /BOOMR\.plugins\s*=\s*BOOMR\.plugins\s*\|\|\s*{};/g,
                            replacement: ""
                        }
                    ]
                }
            },
            debug: {
                files: [{
                    src: "build/<%= pkg.name %>-<%= buildDate %>-debug.js",
                    dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.js"
                }],
                options: {
                    replacements: [
                        {
                            // Add &debug key to request
                            pattern: /key=%client_apikey%/,
                            replacement: "debug=\&key=%client_apikey%"
                        }
                    ]
                }
            },
            release: {
                files: [{
                    src: "build/<%= pkg.name %>-<%= buildDate %>.js",
                    dest: "build/<%= pkg.name %>-<%= buildDate %>.js"
                }],
                options: {
                    // strip out some NOPs
                    replacements: [
                        {
                            pattern: /else{}/g,
                            replacement: ""
                        },
                        {
                            pattern: /\(window\)\);/g,
                            replacement: "\(window\)\);\n"
                        },
                        {
                            pattern: /\(\)\);\(function\(/g,
                            replacement: "\(\)\);\n(function("
                        }
                    ]
                }
            }
        },
        copy: {
            // copy files to tests\build\boomerang-latest.js so test/index.html points to the latest version always
            latest: {
                files: [
                    {
                        nonull: true,
                        src: "build/<%= pkg.name %>-<%= buildDate %>-debug.js",
                        dest: "tests/build/<%= pkg.name %>-latest-debug.js"
                    }
                ]
            }
        },
        uglify: {
            options: {
                preserveComments: false,
                mangle: true,
                sourceMap: true
            },
            min_release: {
                src: "build/<%= pkg.name %>-<%= buildDate %>.js",
                dest: "build/<%= pkg.name %>-<%= buildDate %>.min.js"
            },
            min_debug: {
                src: "build/<%= pkg.name %>-<%= buildDate %>-debug.js",
                dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.min.js"
            }
        },
        compress: {
            main: {
                options: {
                    mode: "gzip",
                    level: 9
                },
                files: [
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>.js.gz"
                    },
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>-debug.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.js.gz"
                    },
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>.min.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>.min.js.gz"
                    },
                    {
                        src: "build/<%= pkg.name %>-<%= buildDate %>-debug.min.js",
                        dest: "build/<%= pkg.name %>-<%= buildDate %>-debug.min.js.gz"
                    }
                ]
            }
        },
        filesize: {
            files: [ "build/<%= pkg.name %>-<%= buildDate %>.min.js.gz" ]
        },
        clean: {
            options: {},
            build: ["build/", "tests/build/", "tests/results/", "tests/coverage/"],
            src: ["plugins/*~", "*.js~"]
        },
        karma: {
            options: {
                singleRun: true,
                colors: true,
                configFile: "./karma.config.js",
                preprocessors: {
                    "./tests/build/*.js": ["coverage"]
                },
                basePath: "./",
                files: [
                    "tests/vendor/mocha/mocha.css",
                    "tests/vendor/mocha/mocha.js",
                    "tests/vendor/chai/chai.js",
                    "tests/vendor/expect/index.js",
                    "tests/unit/*.js",
                    "tests/build/*.js"
                ]
            },
            unit: {
                browsers: ["PhantomJS"],
                frameworks: ["mocha"]
            },
{'fraction_non_alphanumeric': 0.1533035842809846, 'fraction_numerical': 0.0014394702749388226, 'mean_word_length': 0.7673619944034596, 'pattern_counts': {'":': 4, '<': 103, '<?xml version=': 0, '>': 103, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1588618', 'n_tokens_mistral': 4028, 'n_tokens_neox': 3551, 'n_words': 609}