Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I undo mix phoenix.gen.html?

mix phoenix.gen.html generates a bunch of files. How do I do undo this generation? or do i have to do it by hand?

like image 945
Emad Avatar asked Jan 18 '16 18:01

Emad


2 Answers

I believe there to be no option to 'undo' from the source code or the mix help command. This mix command phoenix.gen.html however does show what files were generated like below:

$ mix phoenix.gen.html Tweet tweets tweet:string

* creating web/controllers/tweet_controller.ex
* creating web/templates/tweet/edit.html.eex
* creating web/templates/tweet/form.html.eex
* creating web/templates/tweet/index.html.eex
* creating web/templates/tweet/new.html.eex
* creating web/templates/tweet/show.html.eex
* creating web/views/tweet_view.ex
* creating test/controllers/tweet_controller_test.exs
* creating priv/repo/migrations/20160118194027_create_tweet.exs
* creating web/models/tweet.ex
* creating test/models/tweet_test.exs

From this you know what files to delete.

like image 160
ham-sandwich Avatar answered Oct 18 '22 05:10

ham-sandwich


I do not think it is particularly good idea for a code generation tool to be able to undo any changes it did; this is just too complicated and error prone and version control systems are made for this purpose (tracking and managing changes).

So, to begin with, I strongly recommend using a version control system, like for example git. Before generating code using mix phx.gen.html or any other way, make sure you are have committed all your changes to the version control system. Then it is easy to rollback all the changes by restoring the work tree state from the repository (and maybe retry as many times until you have the right stuff generated). Even if new files are generated, using a version control system allows you to see what files were added to the work tree, so you do not need to copy the output from the mix phx.gen.html for possible later reference. A version control system also allows comparing the modified files to understand the changes made.

like image 27
FooF Avatar answered Oct 18 '22 06:10

FooF