johnagan / clean-webpack-plugin

A webpack plugin to remove your build folder(s) before building
MIT License
1.96k stars 135 forks source link

how to get files back? #110

Closed jadertao closed 5 years ago

jadertao commented 5 years ago

it remove all my code from root dir. please help me.

unguul commented 5 years ago

@JadeTao I don't think this plugin has a mechanism for restoring deleted files However, I'm not familiar enough with this plugin to be a source of truth. Perhaps @chrisblossom knows more.

Alternatively, your code should have been in version control which gives you the ability to revert changes. General backups of your system could also have your missing files.

@JadeTao Did it delete the webpack config file too?

@chrisblossom Maybe the plugin could prevent this by checking if the folder to be deleted is not the current one or called src ?

P.S. Thanks for #106

johnagan commented 5 years ago

@JadeTao sorry to hear. @unguul is correct - there is no getting your files back. 😢

chrisblossom commented 5 years ago

@JadeTao The only other thing I can think of is if you are using a Jetbrain's editior such as webstorm, you probably can restore your files using their local history feature.

Maybe the plugin could prevent this by checking if the folder to be deleted is not the current one or called src ?

@unguul This plugin already protects removing process.cwd() via del without using dangerouslyAllowCleanPatternsOutsideProject: true in combination with dry: false.

The readme already already warns the user to use dry: true before using cleanOnceBeforeBuildPatterns and/or cleanAfterEveryBuildPatterns so this does not happen.

kilinkis commented 4 years ago

lol, it happened to me as well, luckily had my code synced shortly before.

cosminoance commented 3 years ago

for me, it 'cleaned' everything BUT the output folder, including the git file. IntelliJ has the local history, but otherwise I would have to re-clone, redo anything that was not pushed already.

abdullah1116 commented 3 years ago

it remove all my code from root dir. please help me.

MINE TOOOOOO! 😭 WEEE WEEE WEEEE

antonkulaga commented 3 years ago

This plugin really sucks, in some cases, it deletes everything, including idea and .git folder.

chavlji commented 2 years ago

This worthless piece of junk just erased some 30 hours of my work. Silly of me that I haven't pushed to git, but still...

AVOID THIS TRASH AS FAR AS YOU CAN!

unguul commented 2 years ago

@chavlji I understand your frustration and can relate to your situation as I've experienced similar things myself. However, please be mindful of the lack of warranty that software usually comes with(out?). This is especially true for open source software that is offered to the world for free(as in free beer).

This is a tool for deleting things. Similarly to rm or a gun, it is as dangerous as the user allows it to be. You are responsible for putting that -rf in the command just as much as you are for not using dry run feature.

LarryZhao0616 commented 2 years ago

my teammate just met the same frustrated thing like @chavlji . Lost 3 days works that cannot recover anymore.

I like the opinion about rm or gun. Obviously, clean-webpack-plugin is a powerful weapon which is very impressive.

But, can we try to add some safety lock or first-time warning for those who had never used your useful plugin.

Or, can we try to change the default feature of not delete .git file at least?

With great power comes with great responsibility to make more people happy:)

MrBenHacker commented 2 years ago

Yup, please add a feature to not delete .git by default! That should really be a thing as it's a "hidden" folder.

Also for people that had this problem, the only way to recover is from a git push on the remote OR VSCode local timeline backups /home/dev/.config/Code/User/History and search by modified date. This saved my day :smile:

lukasz-zaroda commented 2 years ago

Just had the same situation. And it would be SO easy to avoid, just make user put an empty file .clean in the directory that's supposed to be cleaned. If file will be there, every other file will be cleaned. If no such file has been found, it should throw an error. It's that simple.

lukasz-zaroda commented 2 years ago

Also, I just realized: If you are using Intellij IDEA it's POSSIBLE to recover the lost files! IDEA stores history of changes outside the project's root, so the deleted files are not lost! What you need to do is:

  1. Create the src directory, or whatever name your directory with sources had.
  2. Now you can right click this src directory, and then click Local History > See History to see the local changes from before the cleaning. From this screen you can restore the whole directory! Just right click the previous version of this directory and revert it.
  3. The same can be done with webpack.config.js and other files in root. Just create an empty file, and look up its history to restore the content.

It just saved my ass and I hope it'll help someone :) .

Added: Actually there might be even a better way:

  1. Create new project in place of the old one, with the same name.
  2. Then you can right click the project name in the left directory listing and use Local History > See History to revert the whole project :) .
devthiagocaetano commented 1 year ago

Just lost houndreds hours with this same problem... my hole folder got just empty right in the middle of bug correction (wich means the production version is broken too)...

Cliche tip: KEEP YOUR WORK ON GIT, every little change...

OscarJVD commented 5 months ago

jajaja, a mí también me pasó, afortunadamente mi código se sincronizó poco antes.

cómo lo sincronizaste antes?

OscarJVD commented 5 months ago

PERDI TODO

mentalitet commented 3 months ago

Also, I just realized: If you are using Intellij IDEA it's POSSIBLE to recover the lost files! IDEA stores history of changes outside the project's root, so the deleted files are not lost! What you need to do is:

  1. Create the src directory, or whatever name your directory with sources had.
  2. Now you can right click this src directory, and then click Local History > See History to see the local changes from before the cleaning. From this screen you can restore the whole directory! Just right click the previous version of this directory and revert it.
  3. The same can be done with webpack.config.js and other files in root. Just create an empty file, and look up its history to restore the content.

It just saved my ass and I hope it'll help someone :) .

Added: Actually there might be even a better way:

  1. Create new project in place of the old one, with the same name.
  2. Then you can right click the project name in the left directory listing and use Local History > See History to revert the whole project :) .

You've made my day! Thank you so much!