zilverline / sequent

CQRS & event sourcing framework for Ruby
https://sequent.io
MIT License
542 stars 58 forks source link

Generators are using hard-coded paths #369

Closed MyklClason closed 1 year ago

MyklClason commented 1 year ago

Generators should be reasonably flexible in how they are used. However, the three main generators here all hard-code the path as lib. This is especially since the documentation suggests using app/domain for rails.

https://github.com/zilverline/sequent/blob/master/lib/sequent/generator/aggregate.rb#L59 https://github.com/zilverline/sequent/blob/master/lib/sequent/generator/command.rb#L68 https://github.com/zilverline/sequent/blob/master/lib/sequent/generator/event.rb#L66

It seems like this could be quickly handled via:

  1. Adding a domain_path config with a default value of File.expand_path('lib').
  2. Using @path ||= Sequent.configuration.domain_path instead of @path ||= File.expand_path('lib') in those 3 lines.

Edit: Actually looks like the generators aren't really designed to be used with rails to begin with, which might be the real issue.

coalest commented 1 year ago

+1. We also don't use a lib folder, but instead a bounded_contexts folder. Adding the path as a configuration option for the generators would be helpful.

Edit: Are y'all open to a PR for this either from @MyklClason or myself?

lvonk commented 1 year ago

Are y'all open to a PR for this either from @MyklClason or myself?

That would be great. It should support both Rails and non Rails environments 🙏🏼

Actually looks like the generators aren't really designed to be used with rails to begin with, which might be the real issue.

Yes this is correct. We started working on better Rails integration a few months back. These generators were not created with Rails in mind back then....

PS. We have a full integration test spec/lib/sequent/generator/project_spec.rb which we never got consistently working. So we disabled it. If I remember correctly it was a bit flaky, perhaps because of github action and exit code's when running bash. But that was a while back, so perhaps it works better nowadays. If you need any help please let us know.

lvonk commented 1 year ago

Closing due to inactivity. Feel free to re-open.