luckyframework / lucky

A full-featured Crystal web framework that catches bugs for you, runs incredibly fast, and helps you write code that lasts.
https://luckyframework.org
MIT License
2.57k stars 156 forks source link

Add a `--with-page` flag to gen.action.browser task #1795

Closed jwoertink closed 10 months ago

jwoertink commented 1 year ago

Ref: https://github.com/luckyframework/lucky/discussions/1794

This would be lucky gen.action.browser Posts::Index --with-page which would generate

src/actions/posts/index.cr
src/pages/posts/index_page.cr

Maybe the lucky gen.page task could also have a --with-action just for the inverse consistency too....

robacarp commented 1 year ago

Yeah, it's always been weird to me that those two generators are separate. The landslide majority of the time I'm adding an action, I want a page too.

Is there room for a combo-blaster generator instead of tying these two generators together? lucky gen.actionpage or something?

jwoertink commented 1 year ago

Is there room for a combo-blaster generator

I'm open to one. It would need to be named something clear with the understanding that it's a BrowserAction being generated. I don't think you'd generate an ApiAction with a page since you'll usually just return JSON...

The other option suggested was using lucky gen.resource without the model, migration, operations, queries....

zw963 commented 1 year ago

I consider only lucky gen.action.browser Posts::Index --with-page is enough, inverse no need. it rarely happens there exists page but no action?

zw963 commented 1 year ago

I created two bash script for make create CRUD only(no db) and Action + Page more easier.

The good part is, no need wait compile, and support create namespaced CRUD. bad part is, the db column never be checked, so, new generated file probably exists error, need adjust.

luckygen.tar.gz

I do create a https://github.com/luckyframework/avram/pull/935 for refine the CRUD templates make it more consistent.

  1. links use non keyword argument form.
  2. Remove unnecessary namespaces.