Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 32 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div align="center">
<h1>create-service</h1>
<p>Boring Express Microservice Generator</p>
<div>

<p>
<a href="https://github.com/boringcodes/create-service/commits" aria-label="Commitizen Friendly">
<img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square">
</a>
Expand All @@ -12,24 +12,26 @@
<a href="https://david-dm.org/boringcodes/create-service" aria-label="Dependencies Status">
<img src="https://img.shields.io/david/boringcodes/create-service?style=flat-square">
</a>
<a href="https://www.npmjs.com/package/@boringcodes/create-service" aria-label="NPM Version">
<img src="https://img.shields.io/npm/v/@boringcodes/create-service?color=brightgreen&style=flat-square">
<a href="https://www.npmjs.com/package/generator-create-service" aria-label="NPM Version">
<img src="https://img.shields.io/npm/v/generator-create-service?color=brightgreen&style=flat-square">
</a>
<a href="https://www.npmjs.com/package/@boringcodes/create-service" aria-label="NPM Downloads">
<img src="https://img.shields.io/npm/dm/@boringcodes/create-service?style=flat-square">
<a href="https://www.npmjs.com/package/generator-create-service" aria-label="NPM Downloads">
<img src="https://img.shields.io/npm/dm/generator-create-service?style=flat-square">
</a>
<a href="https://github.com/boringcodes/create-service/blob/master/LICENSE" aria-label="MIT License">
<img src="https://img.shields.io/github/license/boringcodes/create-service?color=brightgreen&style=flat-square">
</a>
<a href="https://github.com/boringcodes" aria-label="BoringCodes Verified">
<img src="https://img.shields.io/badge/boringcodes-verified-brightgreen?style=flat-square">
</a>
</div>
</p>

<img src="banner.png">
</div>

## Install

Make sure `yeoman` is installed:
Make sure `yeoman` is installed

```sh
$ yarn global add yo
Expand All @@ -38,36 +40,40 @@ $ yarn global add yo
Then install the generator

```sh
$ yarn global add @boringcodes/create-service
$ yarn global add generator-create-service
```

## Usage

With [yo](https://github.com/yeoman/yo):
Create a new directory

```sh
$ mkdir service-name
```

Then navigate to the created directory and run the following command to generate source

```sh
$ yo create-service
```

This scaffolds out:

```
├── Dockerfile
├── README.md
├── src
│ ├── components
│ │   ├── things
│ │   │   ├── constants.ts
│ │   │   ├── controller.ts
│ │   │   ├── index.ts
│ │   └── types.ts
│ ├── app.ts
│ ├── index.ts
│ └── routes.ts
├── .env.example
├── .huskyrc
├── package.json
└── src
├── app.ts
├── components
│   ├── things
│   │   ├── constants.ts
│   │   ├── controller.ts
│   │   ├── index.ts
│   │   ├── middleware.ts
│   │   ├── model.ts
│   │   ├── repository.ts
│   │   └── type.ts
│   └── types.ts
├── index.ts
└── routes.ts
└── tslint.json
```

## Contributing
Expand Down
Binary file added banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 36 additions & 12 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,53 @@ module.exports = class extends Generator {
yosay(`Welcome to the astounding ${chalk.red(pkg.name)} generator!`),
);

const gitName = this.user.git.name() || 'organization';
const gitEmail = this.user.git.email() || 'hi@domain.com';
const githubUsername = await (async () => {
try {
const username = await this.user.github.username();

return username;
} catch (err) {
return 'organization';
}
})();
const prompts = [
{
type: 'input',
name: 'elementName',
message: 'What is the name of your service?',
default: 'my-awesome-service',
default: this.appname,
},
{
type: 'input',
name: 'elementDescription',
message: 'Give us some small description of your service',
default: '',
message: 'Description of your service?',
default: 'My awesome service',
},
{
type: 'input',
name: 'elementHomepageUrl',
message: 'Homepage URL?',
default: `https://github.com/${githubUsername}/${this.appname}`,
},
{
type: 'input',
name: 'elementBugsUrl',
message: 'Bugs tracking URL?',
default: `https://github.com/${githubUsername}/${this.appname}/issues`,
},
{
type: 'input',
name: 'elementAuthor',
message: 'Who is the author of this service?',
default: '',
message: 'Author of this service?',
default: `${gitName} \<${gitEmail}\>`,
},
{
type: 'input',
name: 'elementRepositoryUrl',
message: 'Repository URL?',
default: `https://github.com/${githubUsername}/${this.appname}.git`,
},
];

Expand All @@ -39,18 +68,13 @@ module.exports = class extends Generator {

writing() {
this.fs.copyTpl(
[this.templatePath('**')],
[this.templatePath('**/*'), this.templatePath('**/.*')],
this.destinationPath(),
this.props,
);

this.fs.copyTpl(
this.templatePath('.env.example'),
this.destinationPath('.env.example'),
);
}

install() {
this.installDependencies();
this.yarnInstall();
}
};
25 changes: 0 additions & 25 deletions generators/app/templates/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions generators/app/templates/README.md

This file was deleted.

12 changes: 5 additions & 7 deletions generators/app/templates/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "<%= elementName %>",
"description": "<%= elementDescription %>",
"version": "0.0.0",
"private": true,
"license": "MIT",
"author": "<%= elementAuthor %>",
"repository": "",
"bugs": "",
"description": "<%= elementDescription %>",
"homepage": "<%= elementHomepageUrl %>",
"bugs": "<%= elementBugsUrl %>",
"author": "<%- elementAuthor %>",
"repository": "<%= elementRepositoryUrl %>",
"scripts": {
"clean": "rm -rf build",
"purge": "rm -rf node_modules",
Expand All @@ -31,7 +30,6 @@
"devDependencies": {
"@types/express": "^4.16.0",
"@types/morgan": "^1.7.35",
"@types/qs": "^6.5.1",
"@types/yup": "^0.26.3",
"husky": "^1.2.1",
"standard-version": "^4.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { NAME } from './constants';

interface Request extends ExpressRequest {
readonly [NAME]: any;
};
}

const list = async (_: Request, res: Response, next: NextFunction) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@boringcodes/create-service",
"name": "generator-create-service",
"version": "0.1.1",
"description": "Boring Express Microservice Generator",
"homepage": "https://github.com/boringcodes/create-service",
Expand Down