joshuaalpuerto / node-ddd-boilerplate

Node DDD Boilerplate
https://joshuaalpuerto.github.io/node-ddd-boilerplate/#/
Other
724 stars 147 forks source link

Generate template via command line #22

Open joshuaalpuerto opened 6 years ago

jlcastrillon91 commented 5 years ago

It would be really nice to have this working, I guess using commander.js as interface might work

joshuaalpuerto commented 5 years ago

@jlcastrillon91 Yes I was so busy at work and don't have enough time to implement this. Before I was going to implement it with plopjs because of the code template and generators. I've heard commanderjs and the documentation looks good.

One thing though, I don't think they have code generator from a template w/c is what I need for this.

Thoughts?

rhm-fyayc commented 5 years ago

https://cookiecutter.readthedocs.io/en/latest/ can be useful to you. I am giving in a try

An example https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs

joshuaalpuerto commented 5 years ago

Hey @rhm-fyayc this looks good. However, This adds dependency(python). W/c I think is a big overhead since this is running with node. What do you think?

rhm-fyayc commented 5 years ago

I don't see as a dependency @joshuaalpuerto, because it is not packaged together with your project. It is a tool, such as brew, visual studio code or pip (which is also in python)

What you need it is a project that is going to work as your project structure, your baseline. Then, every time you need to start a new project you ask to create the new project based on that template.

I have forked your project to show you, check it here

https://github.com/rhm-fyayc/node-ddd-boilerplate

you can try like this

cookiecutter gh:rhm-fyayc/node-ddd-boilerplate

joshuaalpuerto commented 5 years ago

Oh I see now what you mean. I have a different goal in mind. What I want is to generate a module inside this boilerplate. Like how react-boilerplate is doing.

screen shot 2019-02-15 at 9 41 05 pm

Since staring a new module is boilerplaty and requires you to create this files.

├── app/
├── domain/
├── infra/
|   ├── database
|   |   └── models
|   ├── sequelize
|   |   └── migrations
|   ├── sequelize
|   |   └── migrations
|   ├── repo
├── interfaces/  

I can create and connect my module real fast by creating templates from those files and generate them when developer opt-in.

rhm-fyayc commented 5 years ago

I got your point.

If what the developer chooses has the output in the same file, you can achieve that with cookiecutter.

Example: if the developer opt-in to have a container component means to change the content of some files, that is possible. However, if this requires to create a different set of files, I think it is then not the best tool.

I don't use react framework, so I don't know the impact. But as amentioned, if it just modifies the content of some files in the basic structure, you can achieve that in some minutes with cookiecuter.

joshuaalpuerto commented 5 years ago

The thing about this issue is that the developer already have this boilerplate and want to generate a new module like roles

├── interfaces/
|   ├── modules
|   |   └── user
|   |   └── company
|   |   └── roles // <-- new module

The way I understand cookiecutter is that it will generate this boilerplate instead of the module inside it. So thats different use-case (Please correct me).

it is not packaged together with your project.

Again my use-case is to generate module inside this boilerplate. So I want my dependencies to be the same. Am looking to implement plopjs w/c I really think the best for this. However I just don't have time yet.

rhm-fyayc commented 5 years ago

I didn't know plopjs, but it seems to cover a broader and complex range of scenarios than cookiecutter.

If I understood it correctly, to achieve your use case with cookiecutter, each module (considering that can be seen as a template) would require a new repo for the template, not your project, meaning doesn't look the best tool for the job :-)

Sofyrus commented 3 years ago

Tried to have this feature now , please checkout the PR here https://github.com/joshuaalpuerto/node-ddd-boilerplate/pull/67