<commit_before>// third party imports
import gulp from 'gulp'
import del from 'del'
import webpack from 'webpack-stream'
import named from 'vinyl-named'
import minifyCSS from 'gulp-minify-css'
import concat from 'gulp-concat'
import karma from 'karma'
import autoprefixer from 'autoprefixer'
import postcss from 'gulp-postcss'
import nodemon from 'gulp-nodemon'
import shell from 'gulp-shell'
// local imports
import {
    buildDir,
    serverBuild,
    clientBuildGlob,
    serverBuildGlob,
    clientEntry,
    serverEntry,
    cssGlob,
    webpackClientConfig as webpackClientConfigPath,
    webpackServerConfig as webpackServerConfigPath,
    karmaConfig as karmaConfigPath,
} from './config/projectPaths'


/**
 * Default to watching client and server, and runing server.
 */
gulp.task('default', ['watch-server', 'watch-client', 'watch-styles', 'runserver'])


/**
 * Run the development server.
 */
gulp.task('runserver', () => {
    nodemon({
        script: serverBuild,
        watch: serverBuild,
        args: ['8000'],
    })
})


/**
 * Watch client entry point.
 */
gulp.task('watch-client', ['clean-client'], () => {
    const config = {
        ...require(webpackClientConfigPath),
        watch: true,
    }

    return gulp.src(clientEntry)
        .pipe(named())
        .pipe(webpack(config))
        .pipe(gulp.dest(buildDir))
})


/**
 * Watch server entry point.
 */
gulp.task('watch-server', ['clean-server'], () => {
    const config = {
        ...require(webpackServerConfigPath),
        watch: true,
    }

    return gulp.src(serverEntry)
        .pipe(named())
        .pipe(webpack(config))
        .pipe(gulp.dest(buildDir))
})


/**
 * Watch styles only. Rebuild on change.
 */
gulp.task('watch-styles', ['build-styles'], () => {
    gulp.watch(cssGlob, ['build-styles'])
})


/**
 * Build styles only.
 */
gulp.task('build-styles', () => {
    return gulp.src(cssGlob)
        .pipe(postcss([
            autoprefixer({
                browsers: ['last 2 versions'],
            }),
        ]))
        .pipe(concat('styles.css'))
        .pipe(minifyCSS())
        .pipe(gulp.dest(buildDir))
})


/**
 * Run the test suite once.
 */
gulp.task('test', (cb) => {
    const server = new karma.Server({
        configFile: karmaConfigPath,
        singleRun: true
    }, () => cb())

    server.start()
})


/**
 * Watch source and tests for changes, run tests on change.
 */
gulp.task('tdd', () => {
    const server = new karma.Server({
        configFile: karmaConfigPath,
    })

    server.start()
})


/**
 * Build into a docker container
 */
gulp.task('containerize',
    ['clean-build', 'build-styles', 'build-client-production', 'build-server-production'],
    shell.task('docker build -t mishkin .')
)


/**
 * Build client entry point for production.
 */
gulp.task('build-client-production', ['clean-client'], () => {
    process.env.NODE_ENV = 'production'

    // build client
    return gulp.src(clientEntry)
        .pipe(named())
        .pipe(webpack(require(webpackClientConfigPath)))
        .pipe(gulp.dest(buildDir))<commit_msg>added gulp task for full production build<commit_after>// third party imports
import gulp from 'gulp'
import del from 'del'
import webpack from 'webpack-stream'
import named from 'vinyl-named'
import minifyCSS from 'gulp-minify-css'
import concat from 'gulp-concat'
import karma from 'karma'
import autoprefixer from 'autoprefixer'
import postcss from 'gulp-postcss'
import nodemon from 'gulp-nodemon'
import shell from 'gulp-shell'
// local imports
import {
    buildDir,
    serverBuild,
    clientBuildGlob,
    serverBuildGlob,
    clientEntry,
    serverEntry,
    cssGlob,
    webpackClientConfig as webpackClientConfigPath,
    webpackServerConfig as webpackServerConfigPath,
    karmaConfig as karmaConfigPath,
} from './config/projectPaths'


/**
 * Default to watching client and server, and runing server.
 */
gulp.task('default', ['watch-server', 'watch-client', 'watch-styles', 'runserver'])


/**
 * Run the development server.
 */
gulp.task('runserver', () => {
    nodemon({
        script: serverBuild,
        watch: serverBuild,
        args: ['8000'],
    })
})


/**
 * Watch client entry point.
 */
gulp.task('watch-client', ['clean-client'], () => {
    const config = {
        ...require(webpackClientConfigPath),
        watch: true,
    }

    return gulp.src(clientEntry)
        .pipe(named())
        .pipe(webpack(config))
        .pipe(gulp.dest(buildDir))
})


/**
 * Watch server entry point.
 */
gulp.task('watch-server', ['clean-server'], () => {
    const config = {
        ...require(webpackServerConfigPath),
        watch: true,
    }

    return gulp.src(serverEntry)
        .pipe(named())
        .pipe(webpack(config))
        .pipe(gulp.dest(buildDir))
})


/**
 * Watch styles only. Rebuild on change.
 */
gulp.task('watch-styles', ['build-styles'], () => {
    gulp.watch(cssGlob, ['build-styles'])
})


/**
 * Build styles only.
 */
gulp.task('build-styles', () => {
    return gulp.src(cssGlob)
        .pipe(postcss([
            autoprefixer({
                browsers: ['last 2 versions'],
            }),
        ]))
        .pipe(concat('styles.css'))
        .pipe(minifyCSS())
        .pipe(gulp.dest(buildDir))
})


/**
 * Run the test suite once.
 */
gulp.task('test', (cb) => {
    const server = new karma.Server({
        configFile: karmaConfigPath,
        singleRun: true
    }, () => cb())

    server.start()
})


/**
 * Watch source and tests for changes, run tests on change.
 */
gulp.task('tdd', () => {
    const server = new karma.Server({
        configFile: karmaConfigPath,
    })

    server.start()
})


/**
 * Build into a docker container
 */
gulp.task('containerize', ['build-production'],
    shell.task('docker build -t mishkin .')
)


/**
 * Build everything needed for production.
 */
gulp.task('build-production', [
    'clean-build',
    'build-styles',
    'build-client-production',
    'build-server-production'
])


/**
 * Build client entry point for production.
 */
gulp.task('build-client-production', ['clean-client'], () => {
    process.env.NODE_ENV = 'production'

    // build client
    return gulp.src(clientEntry)
        .pipe(named())
        .pipe(webpack(require(webpackClientConfigPath)))
        .pipe(gulp.dest(buildDir))
{'fraction_non_alphanumeric': 0.15702741245444463, 'fraction_numerical': 0.001584534938995405, 'mean_word_length': 2.77737881508079, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '2437344', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1972, 'n_words': 448}