laravel-shift / blueprint

A code generation tool for Laravel developers.
MIT License
2.89k stars 275 forks source link

Allowing the build command to try to auto-skip #697

Open wotta opened 1 month ago

wotta commented 1 month ago

Synopsis:

At this moment when we run the build command we do have an option to pass a list of file classes, but this somewhat unnatural to me. When I am adding models and other stuff as POC real quick I usually forget to delete the old stuff.

Imagine I generated a draft.yaml with the following content:

models:
  Timesheet:
    postal_from: string:6
    house_number_from: string:4
    city_from: string
    postal_to: string:6
    house_number_to: string:4
    city_to: string

seeders: Timesheet

Now when quickly used filament and api platform to generate my resources for both the admin and api and I want to add an additional model I usually add it below the existing information. Like below.

models:
  Timesheet:
    postal_from: string:6
    house_number_from: string:4
    city_from: string
    postal_to: string:6
    house_number_to: string:4
    city_to: string
  Setting: // This is new
    name: string
    value: text
    model: string
    softDeletes

seeders: Timesheet

Proposed Syntax:

Nothing changes here.

Expected Behavior:

It would be amazing if I could run for example php artisan blueprint:build --auto-skip which would use the .blueprint file to automatically add the files generated to the skip option to achieve this behavior.

Let me know if you don't mind this being an additional option to use. I'm also open to hop on a call to talk about this if needed 🙂

jasonmccreary commented 1 month ago

Blueprint is a passive code generator. So the draft files are meant to be "scratch pads" and throw away. Not cumulative representations of the entire system.

With that said, I understand what you are trying to do. I wonder if a --force option provides more optionality - where any other component which exists in the draft file gets overwritten.

I guess it's all perspective, as --skip would do the opposite. Anyway, not something I will add. But I am open to a PR.

wotta commented 1 month ago

Cool thanks for at least taking the time reading over this. I will try to make an example tonight, and then it is still up to you of course to see if you want to add it at all. For my use-case it seems helpful because I am only building an x amounts of cruds in the end, so for those instances it would be nice to have something which I can extend instead of throwing away. Mainly for future references, but that might just be my weird thing😂

Thanks either way and I wish you an amazing day!