<commit_before>/**
 * Canv-Gauge Dev Tasks Runner
 *
 * @author <NAME> <<EMAIL>>
 */
const gulp = require('gulp');
const usage = require('gulp-help-doc');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const rename = require('gulp-rename');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const rimraf = require('rimraf');
const esdoc = require('gulp-esdoc');
const eslint = require('gulp-eslint');
const gzip = require('gulp-gzip');
const KarmaServer = require('karma').Server;
const gutil = require('gulp-util');
const chalk = require('chalk');
const http = require('https');
const fs = require('fs');
const selenium = require('selenium-standalone');
const mocha = require('gulp-mocha');
const cp = require('child_process');
const concat = require('gulp-concat');
const yargs = require('yargs');
const replace = require('gulp-replace');
const babel = require('gulp-babel');
const fsc = require('fs-cli');
const semver = require('semver');

/**
 * @typedef {{argv: object}} yargs
 * @typedef {{parse:function, stringify:function}} JSON
 */

let types = ['all', 'radial', 'linear'];

function es6concat(type = 'all') {
    let bundle = [
        'lib/polyfill.js',
        'lib/vendorize.js',
        'lib/Animation.js',
        'lib/DomObserver.js',
        'lib/SmartCanvas.js',
        'lib/GenericOptions.js',
        'lib/Collection.js',
        'lib/BaseGauge.js',
        'lib/drawings.js'
    ];

    switch (type.toLowerCase()) {
        case 'radial':
        case 'radial-gauge':
        case 'radialgauge':
            bundle.push('lib/RadialGauge.js');
            break;
        case 'linear':
        case 'linear-gauge':
        case 'lineargauge':
            bundle.push('lib/LinearGauge.js');
            break;
        default:
            bundle.push('lib/RadialGauge.js', 'lib/LinearGauge.js');
    }

    return gulp.src(bundle)
        .pipe(concat('gauge.es6.js'))
        .pipe(replace(/((var|const|let)\s+.*?=\s*)?require\(.*?\);?/g, ''))
        .pipe(replace(/(module\.)?exports(.default)?\s+=\s*.*?\r?\n/g, ''))
        .pipe(replace(/export\s+(default\s+)?(GenericOptions;)?/g, ''));
}

/**
 * Displays this usage information.
 *
 * @task {help}
 */
gulp.task('help', () => usage(gulp));

/**
 * Builds production packages
 *
 * @task {build:prod}
 */
gulp.task('build:prod', done => {
    rimraf('dist', () => {
        Promise.all(types.map(type => {
            return new Promise(resolve => {
                es6concat(type)
                    .pipe(rename('gauge.es5.js'))
                    .pipe(babel({
                        presets: ['es2015'],
                        compact: false
                    }))
                    .on('error', function(err) {
                        gutil.log(err);
                        this.emit('end');
                        resolve();
                    })
                    .pipe(rename('gauge.min.js'))
                    .pipe(replace(/^/, '(function() {'))
                    .pipe(replace(/$/, '}());'))
                    .pipe(uglify())
                    .pipe(gulp.dest('dist/' + type))
                    .on('end', () => {
                        let pkg = JSON.parse(fs.readFileSync('./package.json'));

                        delete pkg.devDependencies;
                        delete pkg.scripts;
                        delete pkg.directories;

                        if (type !== 'all') {
                            pkg.version += '-' + type;
                            pkg.keywords.push(type + '-gauge');
                        }

                        else {
                            for (let i = 1; i < types.length; i++) {
                                pkg.keywords.push(types[i] + '-gauge');
                            }
                        }

                        fs.writeFileSync('dist/' + type + '/package.json',
                            JSON.stringify(pkg, null, 2));

                        fs.writeFileSync('dist/' + type + '/README.md',
                            fs.readFileSync('README.md'));

                        fs.writeFileSync('dist/' + type + '/LICENSE',
                            fs.readFileSync('LICENSE'));

                        resolve();
                    });
            });
        })).then(() => {
            let version = require('./package.json').version;
            let cmd = '';

            console.log(chalk.bold.green('Production packages are now ready!'));
            console.log('To publish each production package, please run the ' +
                'following commands:');

            types.reverse().forEach(type => {
                let v = version;
                let entry = type === 'linear' ? './' : '../../';

                if (cmd) cmd += ' && ';

                cmd += 'cd ' + entry + 'dist/' + type;

                if (type === 'all') type = 'latest';
                else v += '-' + type;

                cmd += ' && npm publish';

                if (type !== 'latest')
                    cmd += ' && npm dist-tag add canvas-gauges@' + v + ' ' +
                        type;
            });

            console.log(chalk.grey(cmd));

            let dst = '../canvas-gauges-pages/download';

            fsc.rm(dst + '/' + version);
            fsc.cp('dist', dst + '/' + version, true);
            fsc.rm(dst + '/latest');

            let releases = fsc.ls(dst);
            let latest = semver.maxSatisfying(releases, '*');

            fsc.cp(dst + '/' + latest, dst + '/latest');<commit_msg>build process update<commit_after>/**
 * Canv-Gauge Dev Tasks Runner
 *
 * @author <NAME> <<EMAIL>>
 */
const gulp = require('gulp');
const usage = require('gulp-help-doc');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const rename = require('gulp-rename');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const rimraf = require('rimraf');
const esdoc = require('gulp-esdoc');
const eslint = require('gulp-eslint');
const gzip = require('gulp-gzip');
const KarmaServer = require('karma').Server;
const gutil = require('gulp-util');
const chalk = require('chalk');
const http = require('https');
const fs = require('fs');
const selenium = require('selenium-standalone');
const mocha = require('gulp-mocha');
const cp = require('child_process');
const concat = require('gulp-concat');
const yargs = require('yargs');
const replace = require('gulp-replace');
const babel = require('gulp-babel');
const fsc = require('fs-cli');
const semver = require('semver');

/**
 * @typedef {{argv: object}} yargs
 * @typedef {{parse:function, stringify:function}} JSON
 */

let types = ['all', 'radial', 'linear'];

function es6concat(type = 'all') {
    let bundle = [
        'lib/polyfill.js',
        'lib/vendorize.js',
        'lib/Animation.js',
        'lib/DomObserver.js',
        'lib/SmartCanvas.js',
        'lib/GenericOptions.js',
        'lib/Collection.js',
        'lib/BaseGauge.js',
        'lib/drawings.js'
    ];

    switch (type.toLowerCase()) {
        case 'radial':
        case 'radial-gauge':
        case 'radialgauge':
            bundle.push('lib/RadialGauge.js');
            break;
        case 'linear':
        case 'linear-gauge':
        case 'lineargauge':
            bundle.push('lib/LinearGauge.js');
            break;
        default:
            bundle.push('lib/RadialGauge.js', 'lib/LinearGauge.js');
    }

    return gulp.src(bundle)
        .pipe(concat('gauge.es6.js'))
        .pipe(replace(/((var|const|let)\s+.*?=\s*)?require\(.*?\);?/g, ''))
        .pipe(replace(/(module\.)?exports(.default)?\s+=\s*.*?\r?\n/g, ''))
        .pipe(replace(/export\s+(default\s+)?(GenericOptions;)?/g, ''));
}

/**
 * Displays this usage information.
 *
 * @task {help}
 */
gulp.task('help', () => usage(gulp));

/**
 * Builds production packages
 *
 * @task {build:prod}
 */
gulp.task('build:prod', done => {
    rimraf('dist', () => {
        Promise.all(types.map(type => {
            return new Promise(resolve => {
                es6concat(type)
                    .pipe(rename('gauge.es5.js'))
                    .pipe(babel({
                        presets: ['es2015'],
                        compact: false
                    }))
                    .on('error', function(err) {
                        gutil.log(err);
                        this.emit('end');
                        resolve();
                    })
                    .pipe(rename('gauge.min.js'))
                    .pipe(replace(/^/, '(function() {'))
                    .pipe(replace(/$/, '}());'))
                    .pipe(uglify())
                    .pipe(gulp.dest('dist/' + type))
                    .on('end', () => {
                        let pkg = JSON.parse(fs.readFileSync('./package.json'));

                        delete pkg.devDependencies;
                        delete pkg.scripts;
                        delete pkg.directories;

                        if (type !== 'all') {
                            pkg.version += '-' + type;
                            pkg.keywords.push(type + '-gauge');
                        }

                        else {
                            for (let i = 1; i < types.length; i++) {
                                pkg.keywords.push(types[i] + '-gauge');
                            }
                        }

                        fs.writeFileSync('dist/' + type + '/package.json',
                            JSON.stringify(pkg, null, 2));

                        fs.writeFileSync('dist/' + type + '/README.md',
                            fs.readFileSync('README.md'));

                        fs.writeFileSync('dist/' + type + '/LICENSE',
                            fs.readFileSync('LICENSE'));

                        resolve();
                    });
            });
        })).then(() => {
            let version = require('./package.json').version;
            let cmd = '';

            console.log(chalk.bold.green('Production packages are now ready!'));
            console.log('To publish each production package, please run the ' +
                'following command:');

            types.reverse().forEach(type => {
                let v = version;
                let entry = type === 'linear' ? './' : '../../';

                if (cmd) cmd += ' && ';

                cmd += 'cd ' + entry + 'dist/' + type;

                if (type === 'all') type = 'latest';
                else v += '-' + type;

                cmd += ' && npm publish';

                if (type !== 'latest')
                    cmd += ' && npm dist-tag add canvas-gauges@' + v + ' ' +
                        type;
            });

            console.log(chalk.grey(cmd));

            let dst = '../canvas-gauges-pages/download';

            fsc.rm(dst + '/' + version);
            fsc.cp('dist', dst + '/' + version, true);
            fsc.rm(dst + '/latest');

            let releases = fsc.ls(dst);
            let latest = semver.maxSatisfying(releases, '*');

            fsc.cp(dst + '/' + latest, dst + '/latest');
{'fraction_non_alphanumeric': 0.17327172560867246, 'fraction_numerical': 0.001777145903678692, 'mean_word_length': 1.5343391128124297, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '2424529', 'n_tokens_mistral': 3323, 'n_tokens_neox': 3106, 'n_words': 603}