Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HMVC #12

Open
AlMcKinlay opened this issue Dec 22, 2015 · 15 comments
Open

HMVC #12

AlMcKinlay opened this issue Dec 22, 2015 · 15 comments
Labels

Comments

@AlMcKinlay
Copy link

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.

@yannbertrand
Copy link
Member

Love the idea 👍

@tjwebb tjwebb added the feature label Dec 22, 2015
@jaumard
Copy link

jaumard commented Dec 22, 2015

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 ?

@AlMcKinlay
Copy link
Author

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.

@jaumard
Copy link

jaumard commented Dec 22, 2015

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.

@AlMcKinlay
Copy link
Author

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 [email protected] 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
.

@jaumard
Copy link

jaumard commented Dec 22, 2015

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 :)

@AlMcKinlay
Copy link
Author

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.

@jaumard
Copy link

jaumard commented Dec 24, 2015

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 :)

@AlMcKinlay
Copy link
Author

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?

@jaumard
Copy link

jaumard commented Dec 24, 2015

No problem :) Don't hesitate if you need help ;)

@AlMcKinlay
Copy link
Author

By the way, is there a trails irc channel? I can't see anything about it anywhere. Might be a handy thing to have.

@jaumard
Copy link

jaumard commented Dec 24, 2015

You have a gitter channel but I'm not aware of an irc channel.

@tjwebb
Copy link
Member

tjwebb commented Dec 27, 2015

@YaManicKill we have a gitter channel here: https://gitter.im/trailsjs/trails.

@tjwebb
Copy link
Member

tjwebb commented Dec 27, 2015

@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

@AlMcKinlay
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants