<commit_before>package com.github.ksoichiro.web.resource

import com.moowork.gradle.node.task.NpmSetupTask
import com.moowork.gradle.node.task.NpmTask
import groovy.json.JsonOutput

class WebResourceInstallDependenciesTask extends NpmTask {
    static final String NAME = 'webResourceInstallDependencies'

    WebResourceInstallDependenciesTask() {
        setNpmCommand('install')
        dependsOn([NpmSetupTask.NAME])

        this.project.afterEvaluate {
            def extension = project.webResource as WebResourceExtension
            getInputs()
                    .property('npm', extension.npm)
                    .property('version', WebResourceExtension.VERSION)
            getOutputs().files(new File(extension.workDir, 'package.json'), new File(extension.workDir, 'node_modules'))
            setWorkingDir(extension.workDir)
        }
    }

    @Override
    void exec() {
        def extension = project.webResource as WebResourceExtension
        def workDir = new File(extension.workDir.toURI())
        if (!workDir.exists()) {
            workDir.mkdirs()
        }
        def npmConfig = extension.npm ? extension.npm.clone() as Map : [:]
        if (!npmConfig.containsKey('devDependencies')) {
            npmConfig['devDependencies'] = [:] as Map
        }
        // Suppress warning: npm WARN package.json @ No description
        if (!npmConfig.containsKey('description')) {
            npmConfig['description'] = "Auto-configured dependencies with gradle-web-resource plugin"
        }
        // Suppress warning: npm WARN package.json @ No repository field.
        if (!npmConfig.containsKey('repository')) {
            npmConfig['repository'] = [type: "git", url: "https://github.com/ksoichiro/gradle-web-resource-plugin"]
        }

        [
                "bower"           : "1.3.12",
                "gulp"            : "3.8.11",
                "coffee-script"   : "1.9.1",
                "main-bower-files": "2.7.0",
                "gulp-less"       : "3.0.2",
                "gulp-minify-css" : "1.0.0",
                "gulp-coffee"     : "2.3.1",
                "gulp-filter"     : "2.0.2",
                "gulp-uglify"     : "0.2.1",
                "gulp-include"    : "2.0.1",
                "fs-extra"        : "0.21.0"
        ].each { name, version ->
            if (!npmConfig.devDependencies.containsKey(name)) {
                npmConfig.devDependencies[name] = version
            }
        }

        new File(extension.workDir, 'package.json').text = JsonOutput.prettyPrint(JsonOutput.toJson(npmConfig))
        // Suppress warning: npm WARN package.json @ No README data
        new File(extension.workDir, 'README.md').text = "WebResource npm packages"
        super.exec()
    }
}<commit_msg>Updated npm dependencies.<commit_after>package com.github.ksoichiro.web.resource

import com.moowork.gradle.node.task.NpmSetupTask
import com.moowork.gradle.node.task.NpmTask
import groovy.json.JsonOutput

class WebResourceInstallDependenciesTask extends NpmTask {
    static final String NAME = 'webResourceInstallDependencies'

    WebResourceInstallDependenciesTask() {
        setNpmCommand('install')
        dependsOn([NpmSetupTask.NAME])

        this.project.afterEvaluate {
            def extension = project.webResource as WebResourceExtension
            getInputs()
                    .property('npm', extension.npm)
                    .property('version', WebResourceExtension.VERSION)
            getOutputs().files(new File(extension.workDir, 'package.json'), new File(extension.workDir, 'node_modules'))
            setWorkingDir(extension.workDir)
        }
    }

    @Override
    void exec() {
        def extension = project.webResource as WebResourceExtension
        def workDir = new File(extension.workDir.toURI())
        if (!workDir.exists()) {
            workDir.mkdirs()
        }
        def npmConfig = extension.npm ? extension.npm.clone() as Map : [:]
        if (!npmConfig.containsKey('devDependencies')) {
            npmConfig['devDependencies'] = [:] as Map
        }
        // Suppress warning: npm WARN package.json @ No description
        if (!npmConfig.containsKey('description')) {
            npmConfig['description'] = "Auto-configured dependencies with gradle-web-resource plugin"
        }
        // Suppress warning: npm WARN package.json @ No repository field.
        if (!npmConfig.containsKey('repository')) {
            npmConfig['repository'] = [type: "git", url: "https://github.com/ksoichiro/gradle-web-resource-plugin"]
        }

        [
                "gulp"            : "3.9.0",
                "bower"           : "1.4.1",
                "main-bower-files": "2.9.0",
                "gulp-less"       : "3.0.3",
                "gulp-minify-css" : "1.2.0",
                "gulp-coffee"     : "2.3.1",
                "gulp-filter"     : "2.0.2",
                "gulp-uglify"     : "1.2.0",
                "gulp-include"    : "2.0.2",
                "fs-extra"        : "0.22.1"
        ].each { name, version ->
            if (!npmConfig.devDependencies.containsKey(name)) {
                npmConfig.devDependencies[name] = version
            }
        }

        new File(extension.workDir, 'package.json').text = JsonOutput.prettyPrint(JsonOutput.toJson(npmConfig))
        // Suppress warning: npm WARN package.json @ No README data
        new File(extension.workDir, 'README.md').text = "WebResource npm packages"
        super.exec()
    }
}
{'fraction_non_alphanumeric': 0.12670671764063354, 'fraction_numerical': 0.012197342071727653, 'mean_word_length': 1.9923747276688453, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3962149', 'n_tokens_mistral': 1661, 'n_tokens_neox': 1540, 'n_words': 284}