Open AlMcKinlay opened 8 years ago
Love the idea 👍
Sound great ! generator-trails
can allow multiple pattern, by default yo trails
generate a MVC structure but if we add a yo trails --hmvc
the generator can generate a HMVC structure. To do that I think trails/archetype
need to change to trails/archetype/mvc
and add trails/archetype/hmvc
.
The generator will choose the right archetype with user option.
When you have a working POC I can help if you want to include this into this generator.
@tjwebb are you agree with to modify trails/archetype
structure ?
Brilliant, thanks for the support. So I've got the POC mostly finished on my fork of the sample app.
The only 2 things that are missing from the ideal HMVC layout would be to have config/policies.js and config/routes.js generated from files in the feature folders as well, but that involves changing the validation in trails core.
Now I guess I need to look into how this generator works.
Ho yes trailpack:core
validator (joi) doesn't allow anything except controllers, models, policies, and services
so it's not possible to add routes
under api/index
, maybe trailpack:core
can be modified to allow a config
field under api/index
. Like this we can add config.routes
and config.policies
under ./api
and then when trails start it can merge it with ./config
.
For the generator it's a bit more complicated I think, cause I look your POC and generator can generate models, services, controllers, policies and hmvc it's really different structure, also the index have to be generated differently. We have to save
project state to know if it's an hmvc or mvc and generate files according the chosen pattern.
Could we not have the J initial yo trails --hmvc create a config somewhere that we can use in future generators? I've never used yeoman, so I'm not sure.
On Tue, 22 Dec 2015, 17:52 Jaumard notifications@github.com wrote:
Ho yes trailpack:core validator (joi) doesn't allow anything except controllers, models, policies, and services so it's not possible to add routes under api/index, maybe trailpack:core can be modified to allow a config field under api/index. Like this we can add config.routes and config.policies under ./api and then when trails start it can merge it with ./config.
For the generator it's a bit more complicated I think, cause I look your POC and generator can generate models, services, controllers, policies and hmvc it's really different structure, also the index have to be generated differently. We have to save project state to know if it's an hmvc or mvc and generate files according the chosen pattern.
— Reply to this email directly or view it on GitHub https://github.com/trailsjs/generator-trails/issues/12#issuecomment-166689645 .
I'm new to yeoman too :D but I see this http://yeoman.io/authoring/storage.html maybe we can use this to know if project are hmvc. Need some tests :)
Confirmed that the config storage will work for this purpose, so that every other sub-generator can check that config.
However, after looking through how the yeoman generator works, it looks like it grabs the base app from the trails project, (from the archetype folder), so it becomes a bit more complicated than just modifying the generator, because of that.
If we were going to do this, I'd need to add the feature folders to the archetype and selectively choose them. But at that point, it's becoming less of an archetype.
Yes that what I said on my first post we can change archetype folder (if @tjwebb agrees with this) to have an mvc
folder and a hmvc
folder. Like this yeoman generator can also support other pattern in the future :)
Ah yes, sorry, I missed you saying that. Alright, well that would work. I've managed to implement a pattern question that will allow them to choose hmvc, so that would work well for choosing that.
I will get a PR for the archetype changes (plus the config change for the validator) and we can see how things go after that?
No problem :) Don't hesitate if you need help ;)
By the way, is there a trails irc channel? I can't see anything about it anywhere. Might be a handy thing to have.
You have a gitter channel but I'm not aware of an irc channel.
@YaManicKill we have a gitter channel here: https://gitter.im/trailsjs/trails.
@jaumard
we can change archetype folder (if @tjwebb agrees with this) to have an mvc folder and a hmvc folder.
After discussing this with @konstantinzolotarev about the current setup with supporting multiple web servers (https://github.com/trailsjs/trails/tree/master/archetype/api/controllers) I think we want the core Trails repo to define only the simplest archetype, and let the trailpacks define their own. That way we don't have to add more stuff to the main archetype every time a new trailpack is created or updated
I think we want the core Trails repo to define only the simplest archetype, and let the trailpacks define their own.
That makes sense, however for this specifically, would we want to create a trailpack purely for an archetype for the generator? Or would the trailpack include a generator for the hmvc version. I would imagine not.
So, the question is where do I go from here? I guess, someone will need to create a trailpack for the hmvc archetype, and then the generator can just rely on that for the hmvc generation?
Requested to open a ticket here, from trailsjs/trails#28.
This is regarding creating a generator for HMVC version of trails.
I currently have a POC of how this could be organised here.