-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add license and readme support
- Loading branch information
1 parent
ecc3070
commit 22084bb
Showing
12 changed files
with
179 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Node Starter | ||
|
||
## Getting Started | ||
|
||
Run your app in development mode | ||
```bash | ||
npm run start:dev | ||
``` | ||
|
||
Build your app | ||
```bash | ||
npm run build | ||
``` | ||
|
||
### Jest | ||
|
||
Jest enables you to unittest your code and generate coverage files | ||
|
||
To test your files run | ||
```bash | ||
npm run test | ||
npm run test:cov # also creates coverage files to report to sonarqube | ||
``` | ||
|
||
### Husky and Lint-Staged | ||
[husky](https://www.npmjs.com/package/husky) and [lint-staged](https://www.npmjs.com/package/lint-staged) will lint and format your files while committing. It will abort if there are remaining linting errors. This keeps your git clean from malformed code. | ||
|
||
|
||
|
||
### Sonarqube | ||
With [sonarqube](https://www.sonarqube.org/) you get some metrics about your code. | ||
For example the code coverage, the technical debt, best practises and many more | ||
|
||
To start sonarqube run | ||
```bash | ||
npm run sonarqube:start | ||
``` | ||
and visit [the local server](http://localhost:9000/). | ||
The default credentials are `admin:admin`. | ||
|
||
To stop sonarqube run | ||
```bash | ||
npm run sonarqube:stop | ||
``` | ||
|
||
To report your testcoverage just run | ||
```bash | ||
npm run sonarqube:report YOUR_KEY | ||
``` | ||
or | ||
```bash | ||
sh ./scripts/report_sonarqube.sh -k YOUR_KEY | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
export enum Messages { | ||
PROJECT_NAME = 'Your project name', | ||
PROJECT_NAME = 'Your project name (only lowercase)', | ||
AUTHOR = 'Your name', | ||
FEATURES = 'Which features you want to enable?', | ||
SONARQUBE = 'Would you like to enable sonarqube?', | ||
SONARQUBE_TOKEN = 'Enter your sonarqube token here (leave empty to configurate later).', | ||
LINT_STAGED = 'Would you like to lint your staged files before commiting?', | ||
WITH_LICENSE = "Do you want to generate a license (chose one in the next step)?", | ||
LICENSE = "Which license?" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
import axios from 'axios'; | ||
|
||
import { Features } from '../enums/features'; | ||
|
||
export const withFeature = (answers: any, feature: Features): boolean => { | ||
return answers.features.some((_feature: Features) => _feature === feature); | ||
}; | ||
|
||
export const getLicenses = async () => { | ||
const { data } = await axios.get('https://api.github.com/licenses'); | ||
return data; | ||
}; | ||
|
||
export const getLicense = async (key: string) => { | ||
const { data } = await axios.get(`https://api.github.com/licenses/${key}`); | ||
return data.body; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const rootPkg = require('../../package.json'); | ||
const rootPkg = require('../../../package.json'); | ||
|
||
export default rootPkg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Generator from 'yeoman-generator'; | ||
|
||
import { Filenames } from '../lib/enums/filenames'; | ||
import { getLicense } from '../lib/helpers'; | ||
|
||
module.exports = class extends Generator { | ||
license: string; | ||
constructor(args: string | string[], config: any) { | ||
super(args, config); | ||
this.license = config.license; | ||
} | ||
|
||
async writing() { | ||
const licenseContent = await getLicense(this.license); | ||
this.fs.copyTpl( | ||
this.templatePath(Filenames.LICENSE), | ||
this.destinationPath(Filenames.LICENSE), | ||
{ license: licenseContent } | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%- license %> |