Skip to content

Commit

Permalink
✨ Add prerequisites badges (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbertrand authored and kefranabg committed Jun 15, 2019
1 parent 094f9fb commit e7e3590
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 81 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<h1 align="center">Welcome to readme-md-generator 👋</h1>
<p align="center">
<img src="https://img.shields.io/badge/version-0.2.1-blue.svg?cacheSeconds=2592000" />
<img src="https://img.shields.io/badge/npm-%3E%3D5.5.0-brightgreen.svg" />
<img src="https://img.shields.io/badge/node-%3E%3D9.3.0-brightgreen.svg" />
<!-- <img src="https://img.shields.io/jsdelivr/npm/hm/readme-md-generator.svg"> -->
<a href="https://codecov.io/gh/kefranabg/readme-md-generator">
<img src="https://codecov.io/gh/kefranabg/readme-md-generator/branch/master/graph/badge.svg" />
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"jest": "^24.8.0"
},
"scripts": {
"lint": "eslint src/**",
"lint": "eslint src",
"prettier:check": "prettier \"**/*.{js,md,json}\" --list-different",
"test": "jest",
"test:ci": "jest --coverage && codecov"
Expand Down
72 changes: 72 additions & 0 deletions src/__snapshots__/readme.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`readme buildReadmeContent should return readme template content 1`] = `
"<h1 align=\\"center\\">Welcome to readme-md-generator 👋</h1>
<p>
<img src=\\"https://img.shields.io/badge/version-0.1.3-blue.svg?cacheSeconds=2592000\\" />
<img src=\\"https://img.shields.io/badge/npm-%3E%3D5.5.0-brightgreen.svg\\" />
<img src=\\"https://img.shields.io/badge/node-%3E%3D%209.3.0-brightgreen.svg\\" />
<a href=\\"https://github.com/kefranabg/readme-md-generator#readme\\">
<img alt=\\"Documentation\\" src=\\"https://img.shields.io/badge/documentation-yes-brightgreen.svg\\" target=\\"_blank\\" />
</a>
<a href=\\"https://github.com/kefranabg/readme-md-generator/graphs/commit-activity\\">
<img alt=\\"Maintenance\\" src=\\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\\" target=\\"_blank\\" />
</a>
<a href=\\"https://github.com/kefranabg/readme-md-generator/blob/master/LICENSE\\">
<img alt=\\"License: MIT\\" src=\\"https://img.shields.io/badge/License-MIT-yellow.svg\\" target=\\"_blank\\" />
</a>
<a href=\\"https://twitter.com/FranckAbgrall\\">
<img alt=\\"Twitter: FranckAbgrall\\" src=\\"https://img.shields.io/twitter/follow/FranckAbgrall.svg?style=social\\" target=\\"_blank\\" />
</a>
</p>
> Generates beautiful README files from git config &amp; package.json infos
### 🏠 [Homepage](https://github.com/kefranabg/readme-md-generator#readme)
## Prerequisites
- npm &gt;=5.5.0
- node &gt;= 9.3.0
## Install
\`\`\`sh
npm install
\`\`\`
## Usage
\`\`\`sh
npm start
\`\`\`
## Run tests
\`\`\`sh
npm run test
\`\`\`
## Author
👤 **Franck Abgrall**
* Twitter: [@FranckAbgrall](https://twitter.com/FranckAbgrall)
* Github: [@kefranabg](https://github.com/kefranabg)
## 🤝 Contributing
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/kefranabg/readme-md-generator/issues).
## Show your support
Give a ⭐️ if this project helped you!
## 📝 License
Copyright © 2019 [Franck Abgrall](https://github.com/kefranabg).<br />
This project is [MIT](https://github.com/kefranabg/readme-md-generator/blob/master/LICENSE) licensed.
***
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_"
`;
15 changes: 8 additions & 7 deletions src/questions/project-prerequisites.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ const isNil = require('lodash/isNil')
* @param {Object} engines
*/
const buildFormattedChoices = engines =>
Object.keys(engines)
.map(key => `${key} ${engines[key]}`)
.map(value => ({
name: value,
value,
checked: true
}))
Object.keys(engines).map(key => ({
name: `${key} ${engines[key]}`,
value: {
name: key,
value: engines[key]
},
checked: true
}))

/**
* Check if projectInfos has engines properties
Expand Down
8 changes: 4 additions & 4 deletions src/questions/project-prerequisites.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('askProjectPrerequisites', () => {
it('should return correct question format', () => {
const engines = {
npm: '>=5.5.0',
node: '>=9.3.0'
node: '>= 9.3.0'
}
const projectInfos = { engines }

Expand All @@ -18,12 +18,12 @@ describe('askProjectPrerequisites', () => {
{
checked: true,
name: 'npm >=5.5.0',
value: 'npm >=5.5.0'
value: { name: 'npm', value: '>=5.5.0' }
},
{
checked: true,
name: 'node >=9.3.0',
value: 'node >=9.3.0'
name: 'node >= 9.3.0',
value: { name: 'node', value: '>= 9.3.0' }
}
]
})
Expand Down
73 changes: 5 additions & 68 deletions src/readme.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ describe('readme', () => {
const context = {
isGithubRepos: true,
repositoryUrl: 'https://github.com/kefranabg/readme-md-generator',
projectPrerequisites: ['npm >=5.5.0', 'node >=9.3.0'],
projectPrerequisites: [
{ name: 'npm', value: '>=5.5.0' },
{ name: 'node', value: '>= 9.3.0' }
],
projectName: 'readme-md-generator',
projectVersion: '0.1.3',
projectDescription:
Expand Down Expand Up @@ -105,73 +108,7 @@ describe('readme', () => {
it('should return readme template content', async () => {
const result = await buildReadmeContent(context, templateName)

expect(result)
.toEqual(`<h1 align="center">Welcome to readme-md-generator 👋</h1>
<p>
<img src="https://img.shields.io/badge/version-0.1.3-blue.svg?cacheSeconds=2592000" />
<a href="https://github.com/kefranabg/readme-md-generator#readme">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" target="_blank" />
</a>
<a href="https://github.com/kefranabg/readme-md-generator/graphs/commit-activity">
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" target="_blank" />
</a>
<a href="https://github.com/kefranabg/readme-md-generator/blob/master/LICENSE">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" target="_blank" />
</a>
<a href="https://twitter.com/FranckAbgrall">
<img alt="Twitter: FranckAbgrall" src="https://img.shields.io/twitter/follow/FranckAbgrall.svg?style=social" target="_blank" />
</a>
</p>
> Generates beautiful README files from git config &amp; package.json infos
### 🏠 [Homepage](https://github.com/kefranabg/readme-md-generator#readme)
## Prerequisites
- npm &gt;=5.5.0
- node &gt;=9.3.0
## Install
\`\`\`sh
npm install
\`\`\`
## Usage
\`\`\`sh
npm start
\`\`\`
## Run tests
\`\`\`sh
npm run test
\`\`\`
## Author
👤 **Franck Abgrall**
* Twitter: [@FranckAbgrall](https://twitter.com/FranckAbgrall)
* Github: [@kefranabg](https://github.com/kefranabg)
## 🤝 Contributing
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/kefranabg/readme-md-generator/issues).
## Show your support
Give a ⭐️ if this project helped you!
## 📝 License
Copyright © 2019 [Franck Abgrall](https://github.com/kefranabg).<br />
This project is [MIT](https://github.com/kefranabg/readme-md-generator/blob/master/LICENSE) licensed.
***
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_`)
expect(result).toMatchSnapshot()
})

it('should call ora with correct parameters in fail case', async () => {
Expand Down
9 changes: 8 additions & 1 deletion templates/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<% if (projectVersion) { -%>
<img src="https://img.shields.io/badge/version-<%= projectVersion %>-blue.svg?cacheSeconds=2592000" />
<% } -%>
<% if (projectPrerequisites) { -%>
<% projectPrerequisites.map(({ name, value }) => { -%>
<img src="https://img.shields.io/badge/<%= name %>-<%= encodeURIComponent(value) %>-brightgreen.svg" />
<% }) -%>
<% } -%>
<% if (projectDocumentationUrl) { -%>
<a href="<%= projectDocumentationUrl %>">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" target="_blank" />
Expand Down Expand Up @@ -36,7 +41,9 @@

## Prerequisites

- <%= projectPrerequisites.join("\n- "); %>
<% projectPrerequisites.map(({ name, value }) => { -%>
- <%= name %> <%= value %>
<% }) -%>
<% } -%>
<% if (installCommand) { -%>

Expand Down

0 comments on commit e7e3590

Please sign in to comment.