amber icon indicating copy to clipboard operation
amber copied to clipboard

[CLI] Add destroy compliment to generator commands

Open drujensen opened this issue 6 years ago • 13 comments

amber g controller Post will create src/controllers/post.cr amber d controller Post should delete src/controllers/post.cr

Do the same for scaffolding and the rest of the generators.

drujensen avatar Aug 25 '17 17:08 drujensen

Was this already address?

eliasjpr avatar Aug 31 '17 00:08 eliasjpr

No but @drujensen believes and mostly convinced me that we'll be ok with out it for now as long as we commit to git before generating things.

elorest avatar Aug 31 '17 17:08 elorest

I think this could and should be done in teeplate. I believe the relevant starting points are: here: https://github.com/mosop/teeplate/blob/master/src/lib/renderer.cr#L47 and here: https://github.com/mosop/teeplate/blob/master/src/lib/rendering_entry.cr#L57

I've opened an issue here: https://github.com/mosop/teeplate/issues/8

marksiemers avatar Nov 12 '17 16:11 marksiemers

We decided a couple months ago that this isn't a priority. Seems like I was the only one who actually uses the destroy option in the rails

On Nov 12, 2017 9:45 AM, "Mark" [email protected] wrote:

I think this could and should be done in teeplate. I believe the relevant starting points are: here: https://github.com/mosop/teeplate/blob/master/src/lib/ renderer.cr#L47 and here: https://github.com/mosop/teeplate/blob/master/src/lib/ rendering_entry.cr#L57

I've opened an issue here: mosop/teeplate#8 https://github.com/mosop/teeplate/issues/8

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/amberframework/amber/issues/188#issuecomment-343750126, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHmpM5nn3FHH0JzVy4GArcTfHeihilAks5s1yCrgaJpZM4PC9D9 .

elorest avatar Nov 12 '17 17:11 elorest

Not a priority, but still a good feature. I love the destroy functionality.

One typo with a scaffold and you're spending 10 minutes deleting files (or worse, NOT deleting them at all).

I usually run a scaffold about 3 times before I have it right.

If the Teeplate maintainer puts it in, then it should be an easy add for us at that point.

marksiemers avatar Nov 12 '17 18:11 marksiemers

@amberframework/core-team - There is a fix for this in teeplate, but mosop isn't maintaining it anymore.

If we switch to the amberframework fork of this, we can incorporate the work that @aaronstillwell has done.

marksiemers avatar Feb 01 '18 22:02 marksiemers

Whats the status of this? Has this been resolved by pointing to Amber Fork?

eliasjpr avatar Feb 10 '18 16:02 eliasjpr

@eliasjpr the fork of teeplate is now at https://github.com/amberframework/teeplate, so we'll get the necessary changes up and running there asap. See https://github.com/amberframework/teeplate/pull/2 for the discussion specific to the necessary behaviour for a destroy command.

aaronstillwell avatar Feb 10 '18 16:02 aaronstillwell

@eliasjpr - I think amber will require a change to get this functionality complete in amber.

For files like:

...
07:30:59 Generate   | (INFO) skipped   spec/models/spec_helper.cr
...
07:30:59 Generate   | (INFO) skipped   spec/controllers/spec_helper.cr
...

There needs to be logic that does not destroy those files (in this example for destroying a scaffold).

marksiemers avatar Feb 10 '18 18:02 marksiemers

Agree, I think we can skip those files, after all there are just there to shorten the require. I don't think that we should delete or modify these files contents

eliasjpr avatar Feb 12 '18 20:02 eliasjpr

In order to support a delete option we really need to roll back to previous versions of any files that were modified during the generate stage. If this functionality is to reduce the effort to remove a set of files that were created with the scaffold generator then there is an easier way. I don't have this problem because I order my code in modules using damianham/amber_render_module so to rollback for example:

amber g scaffold Post tutle:string body:text

because I misspelt title I simple type

rm -rf src/modules/post spec/modules/post db/migrations/*create_post.sql

and remove the 2 lines from src/views/layouts/_nav.slang.

damianham avatar Mar 30 '18 05:03 damianham

Some update on this?, looks like https://github.com/amberframework/teeplate/pull/2 is already accepted, not merged, though.

faustinoaq avatar Apr 16 '18 19:04 faustinoaq

One option is to leverage git and rollback to the previous sha.

drujensen avatar Dec 30 '18 04:12 drujensen