node-gradle / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
599 stars 117 forks source link

My Whole UI project got deleted 😩🤦‍♂️ #297

Closed anandchakru closed 6 months ago

anandchakru commented 7 months ago

Please DO NOT DELETE everything in any directory, no matter what configuration/misconfiguration is in build.gradle file. Here is what I had in my build.gradle when this DISASTER happened 😩.

node {
    version = '20.10.0'
    download = true
    workDir = file("${project.projectDir}/my-ui") # should have been nodeProjectDir (instead of workDir)
}

task installNpm(type: NodeTask) {
    dependsOn npmInstall
    script = file("${project.projectDir}/my-ui/build.js")
}

task buildReactUI(type: NodeTask) {
    script = file("${project.projectDir}/my-ui/build.js")
    args = ["run", "build"]
}

task copyReactUI(type: Copy) {
    dependsOn buildReactUI
    from "${project.projectDir}/my-ui/build"
    into "${project.projectDir}/src/main/resources/static/public"
}

processResources {
    dependsOn copyReactUI
}

After I ran gradle clean build, this is what I have in my-ui directory drwxr-xr-x@ 9 loki staff 288 Dec 24 22:24 node-v20.10.0-darwin-x64

deepy commented 6 months ago

I'm so sorry that this happened, this is a decision that was made before the project was forked and something we probably should have scrutinized much earlier The reason this cleanup is in place is to prevent node installations from accumulating and filling up the disk, so while the functionality is probably not going away we absolutely should check that we're only deleting node

deepy commented 6 months ago

This has been fixed in 7.0.2, we now only delete files that either start with node-v or are in a folder starting with node-v It's not foolproof but should help prevent worst-case scenarios