From 9ce8bb64924404f01f2e5a0105b3241b15be1d65 Mon Sep 17 00:00:00 2001 From: Franck Date: Fri, 7 Jun 2019 20:06:15 +0200 Subject: [PATCH] :sparkles: Add npm version infos --- README.md | 7 ++++--- src/cli.js | 4 +++- src/questions/index.js | 4 +++- src/questions/project-version.js | 6 ++++++ src/utils/index.js | 2 ++ templates/default.md | 5 +++++ 6 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 src/questions/project-version.js diff --git a/README.md b/README.md index 308415d..d8f5e3a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ -[![Greenkeeper badge](https://badges.greenkeeper.io/kefranabg/readme-cli.svg)](https://greenkeeper.io/) -

Welcome to readme-cli 👋

- +

+ + +

> Generates beautiful README files from git config & package.json infos ## Install diff --git a/src/cli.js b/src/cli.js index 2a5913f..1618220 100644 --- a/src/cli.js +++ b/src/cli.js @@ -12,7 +12,8 @@ const { askAuthorGithub, askAuthorTwitter, askLicenseUrl, - askContributing + askContributing, + askProjectVersion } = require('./questions') /** @@ -23,6 +24,7 @@ const askQuestions = async () => { const questions = [ askProjectName(projectInfos), + askProjectVersion(projectInfos), askProjectDescription(projectInfos), askAuhtorName(projectInfos), askAuthorGithub(projectInfos), diff --git a/src/questions/index.js b/src/questions/index.js index c8a1274..028a1f4 100644 --- a/src/questions/index.js +++ b/src/questions/index.js @@ -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, @@ -13,5 +14,6 @@ module.exports = { askAuthorGithub, askAuthorTwitter, askLicenseUrl, - askContributing + askContributing, + askProjectVersion } diff --git a/src/questions/project-version.js b/src/questions/project-version.js new file mode 100644 index 0000000..15182bf --- /dev/null +++ b/src/questions/project-version.js @@ -0,0 +1,6 @@ +module.exports = projectInfos => ({ + type: 'input', + message: 'ℹī¸ Project version (use empty value to skip)', + name: 'projectVersion', + default: projectInfos.version +}) diff --git a/src/utils/index.js b/src/utils/index.js index 602597e..72b7491 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -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 @@ -130,6 +131,7 @@ const getProjectInfos = async () => { return { name, description, + version, author, repositoryUrl, contributingUrl, diff --git a/templates/default.md b/templates/default.md index 5166d70..9901f48 100644 --- a/templates/default.md +++ b/templates/default.md @@ -1,4 +1,9 @@

Welcome to <%= projectName %> 👋

+

+<% if (projectVersion) { -%> + +<% } -%> +

<% if (projectDescription) { -%> > <%= projectDescription %>