pledbrook / lazybones

A simple project creation tool that uses packaged project templates.
Apache License 2.0
614 stars 102 forks source link

Dangerous behaivor when removing all content in the target directory #153

Closed maol74 closed 9 years ago

maol74 commented 9 years ago

When running

lazybones create

it removes all content in target directory which is really dangerous (if you by accident run it again when you have added a lot of more code to the project). Would be nice, and less error prone, to just overwrite or even better get a confirm prompt for each overwrite.

pledbrook commented 9 years ago

Thanks for the report, although I can't immediately see from the code where this is happening. The unzipping certainly does overwrite any files that already exist, basically on the assumption that you're always creating a new project from a template. Is that the specific issue you're seeing? Or does lazybones create ... actually delete all content from the target directory?

maol74 commented 9 years ago

Thanks for the answer: It removed all directories, or as it seems, only if there are any directories that the new templates doesn´t also have. You can easy reproduce this by running:

  1. Run: lazybones create afterburnerfx afp
  2. Hit return on all default values
  3. Run: ls afp/src/main/java/org/example/ # shows all the newly created content
  4. Run: touch afp/src/main/java/org/example/MyClass.java # to create a new content
  5. Run: lazybones create afterburnerfx afp
  6. Hit return on all EXCEPT package, enter for example short package 'examples'
  7. Then, everything under afp/src/main/java/org/\ is wiped
pledbrook commented 9 years ago

I followed these instructions but couldn't reproduce the issue with either v0.7 or 0.8.1. What version are you using? And which platform? Perhaps it's platform-specific for some reason.

ancho commented 9 years ago

It's is not a problem with lazybones. But the afterburnfx template moves everything under src/main/java to the specified package appending the projectname to each file. Including the old package from the previous create.

Before:

└✪ tree afp/
afp/
├── build.gradle
├── gradle
│   ├── javafx.gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── pom.xml
├── README.md
└── src
    └── main
        ├── java
        │   └── org
        │       └── example
        │           ├── AfpMain.java
        │           ├── AfpPresenter.java
        │           ├── AfpService.java
        │           ├── AfpView.java
        │           └── MyClass.java
        └── resources
            └── org
                └── example
                    └── afp.fxml

After the second create with example as package:

└✪ tree afp/
afp/
├── build.gradle
├── gradle
│   ├── javafx.gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── pom.xml
├── README.md
└── src
    └── main
        ├── java
        │   └── example
        │       ├── AfpMain.java
        │       ├── Afporg
        │       │   └── example
        │       │       ├── AfpMain.java
        │       │       ├── AfpPresenter.java
        │       │       ├── AfpService.java
        │       │       ├── AfpView.java
        │       │       └── MyClass.java
        │       ├── AfpPresenter.java
        │       ├── AfpService.java
        │       └── AfpView.java
        └── resources
            ├── example
            │   └── afp.fxml
            └── org
                └── example
                    └── afp.fxml
maol74 commented 9 years ago

Alright, it's the afterburnfx doing this then, sorry pledbrook for wasting your time and thanks ancho!