node-ddd-boilerplate icon indicating copy to clipboard operation
node-ddd-boilerplate copied to clipboard

Generate template via command line

Open joshuaalpuerto opened this issue 6 years ago • 10 comments

joshuaalpuerto avatar Jun 11 '18 05:06 joshuaalpuerto

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

jlcastrillon91 avatar Nov 16 '18 20:11 jlcastrillon91

@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?

joshuaalpuerto avatar Nov 17 '18 01:11 joshuaalpuerto

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

rhm-fyayc avatar Feb 12 '19 09:02 rhm-fyayc

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?

joshuaalpuerto avatar Feb 15 '19 01:02 joshuaalpuerto

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

rhm-fyayc avatar Feb 15 '19 13:02 rhm-fyayc

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.

joshuaalpuerto avatar Feb 15 '19 13:02 joshuaalpuerto

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.

rhm-fyayc avatar Feb 15 '19 14:02 rhm-fyayc

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.

joshuaalpuerto avatar Feb 16 '19 00:02 joshuaalpuerto

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

rhm-fyayc avatar Feb 16 '19 11:02 rhm-fyayc

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

Sofyrus avatar Nov 14 '20 08:11 Sofyrus