Skip to content

add plop based boilerplate generator#67

Open
Sofyrus wants to merge 9 commits intojoshuaalpuerto:masterfrom
SofyrusTechnologies:master
Open

add plop based boilerplate generator#67
Sofyrus wants to merge 9 commits intojoshuaalpuerto:masterfrom
SofyrusTechnologies:master

Conversation

@Sofyrus
Copy link
Copy Markdown

@Sofyrus Sofyrus commented Nov 14, 2020

This PR will add to boilerplate the capability to quickly generate the files for app and routes and will also update router.js inside modules/http to have an entry for the newly created route.
This is the first draft and the generator can be improved with time

Note: Since we are actively working using this and one of the team members added event based pub sub skeleton that is now also the part of this PR @joshuaalpuerto

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 14, 2020

This pull request introduces 1 alert when merging d9e4179 into 79d2bca - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@joshuaalpuerto
Copy link
Copy Markdown
Owner

Wow!! I will look into these as soon as I could! Thanks @Sofyrus

Copy link
Copy Markdown
Owner

@joshuaalpuerto joshuaalpuerto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all I appreciate for making this contribution: 🎉

I found some couple of issues when running repository, routes and domain.

Screen Shot 2020-11-15 at 4 41 52 PM

Right now as I understand the developers need to do yarn generate or npm generate 4 times. It would be great if it's just 1 selection and base on their answers it will generate the necessary files domain, routes and repository.

Screen Shot 2020-11-15 at 4 44 34 PM

So far it's looking good, I have some small comments and suggestion, I will contribute as-well when I can.

// Generate index.js and index.test.js

let appRelativePath = "src/app/{{camelCase name}}/";
let routeRelativePath = "src/interfaces/http/modules/{{camelCase name}}/";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filename convention - camelCase should never be used. This leaves snake_case and kebab-case, I prefer snake_case for file.

No worries if you cannot edit it man I will do it within this week 👀

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question do we need to generate the domain object as well ? that would imply asking for some initial properties like sequelize does for it's models?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, we can just have the domain object without properties for now (probably add some dummy property).

Anyway, our goal is to remove some boilerplate from their end so I think this is enough.

const getUseCase = get({ {{#if InjectRepository}} {{camelCase repositoryName}},{{/if}} logger})
const postUseCase = post({ {{#if InjectRepository}} {{camelCase repositoryName}},{{/if}} logger})
const putUseCase = put({ {{#if InjectRepository}} {{camelCase repositoryName}},{{/if}} logger })
const deleteUseCase = remove({ {{#if InjectRepository}} {{camelCase repositoryName}},{{/if}} logger })
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to include logger here by default.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have found myself injecting logger in app layer in multiple scenarios. Can you expand/elaborate the reasoning for not having logger here

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I don't have hard reason. We can import it just add logger from container.cradle as well.

return router
}
return router;
};
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have used prettier here instead of standard?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's the default throughout our VS Code setup

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually planning to move this also to prettier because most of developers are working with that in their frontend code.

Created an issue here. Let have that in separate PR.

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 16, 2020

This pull request introduces 14 alerts when merging 69a8b2c into 79d2bca - view on LGTM.com

new alerts:

  • 14 for Unused variable, import, function or class

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 17, 2020

This pull request introduces 14 alerts when merging 90b7892 into 79d2bca - view on LGTM.com

new alerts:

  • 14 for Unused variable, import, function or class

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 18, 2020

This pull request introduces 14 alerts when merging d39fc6f into 79d2bca - view on LGTM.com

new alerts:

  • 14 for Unused variable, import, function or class

Copy link
Copy Markdown
Owner

@joshuaalpuerto joshuaalpuerto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job man. I added some additional small comments.

Also, I see you have some changes related to this issue. Let's put that in different PR since that is a different concern.

type: "input",
name: "repositoryName",
message: "Name of existing repository.",
description: "Only needed if previous answer was in affirmitive?",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use this plugin, so we don't have to show the next question if it depends on the previous one.

"bcrypt": "3.0.8",
"body-parser": "1.18.3",
"bull": "^3.18.1",
"bull-board": "^0.10.0",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for contributing man, but let's put this to separate PR.

const date = require('./infra/support/date')
const repository = require('./infra/repositories')
const eventPublisher = require('./infra/eventPublisher/publisher')
const scheduler = require('./infra/bull')
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a different concern so let's put it to a different PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants