Skip to content

Commit

Permalink
✨ Add npm version infos
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck committed Jun 7, 2019
1 parent 6fadc05 commit 9ce8bb6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[![Greenkeeper badge](https://badges.greenkeeper.io/kefranabg/readme-cli.svg)](https://greenkeeper.io/)

<h1 align="center">Welcome to readme-cli 👋</h1>

<p>
<img src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
<img src="https://badges.greenkeeper.io/kefranabg/readme-cli.svg" />
</p>
> Generates beautiful README files from git config & package.json infos
## Install
Expand Down
4 changes: 3 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const {
askAuthorGithub,
askAuthorTwitter,
askLicenseUrl,
askContributing
askContributing,
askProjectVersion
} = require('./questions')

/**
Expand All @@ -23,6 +24,7 @@ const askQuestions = async () => {

const questions = [
askProjectName(projectInfos),
askProjectVersion(projectInfos),
askProjectDescription(projectInfos),
askAuhtorName(projectInfos),
askAuthorGithub(projectInfos),
Expand Down
4 changes: 3 additions & 1 deletion src/questions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const askAuthorGithub = require('./author-github')
const askAuthorTwitter = require('./author-twitter')
const askLicenseUrl = require('./license-url')
const askContributing = require('./contributing')
const askProjectVersion = require('./project-version')

module.exports = {
askProjectName,
Expand All @@ -13,5 +14,6 @@ module.exports = {
askAuthorGithub,
askAuthorTwitter,
askLicenseUrl,
askContributing
askContributing,
askProjectVersion
}
6 changes: 6 additions & 0 deletions src/questions/project-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = projectInfos => ({
type: 'input',
message: 'ℹ️ Project version (use empty value to skip)',
name: 'projectVersion',
default: projectInfos.version
})
2 changes: 2 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const getProjectInfos = async () => {
const name = getProjectName() || undefined
const description = get(packageJson, 'description', undefined)
const author = get(packageJson, 'author', undefined)
const version = get(packageJson, 'version', undefined)
const repositoryUrl = await getReposUrl(packageJson)
const contributingUrl = await getReposIssuesUrl(packageJson)
let githubUsername = undefined
Expand All @@ -130,6 +131,7 @@ const getProjectInfos = async () => {
return {
name,
description,
version,
author,
repositoryUrl,
contributingUrl,
Expand Down
5 changes: 5 additions & 0 deletions templates/default.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<h1 align="center">Welcome to <%= projectName %> 👋</h1>
<p>
<% if (projectVersion) { -%>
<img src="https://img.shields.io/badge/version-<%= projectVersion %>-blue.svg?cacheSeconds=2592000" />
<% } -%>
</p>
<% if (projectDescription) { -%>

> <%= projectDescription %>
Expand Down

0 comments on commit 9ce8bb6

Please sign in to comment.