Skip to content

Commit

Permalink
✨ Add homepage link if exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck committed Jun 11, 2019
1 parent 62109c4 commit 1c1bf08
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/project-infos.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const getProjectInfos = async () => {
const author = get(packageJson, 'author', undefined)
const version = get(packageJson, 'version', undefined)
const licenseName = get(packageJson, 'license', undefined)
const homepage = get(packageJson, 'homepage', undefined)
const repositoryUrl = await getReposUrl(packageJson)
const contributingUrl = await getReposIssuesUrl(packageJson)
const isGithubRepos = isGithubRepository(repositoryUrl)
Expand All @@ -128,6 +129,7 @@ const getProjectInfos = async () => {
description,
version,
author,
homepage,
repositoryUrl,
contributingUrl,
githubUsername,
Expand Down
6 changes: 6 additions & 0 deletions src/project-infos.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('projectInfos', () => {
version: '0.1.3',
author: 'Franck Abgrall',
repositoryUrl: 'https://github.com/kefranabg/readme-md-generator',
homepage: 'https://github.com/kefranabg/readme-md-generator',
contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
githubUsername: 'kefranabg',
Expand Down Expand Up @@ -117,6 +118,7 @@ describe('projectInfos', () => {
repositoryUrl: 'https://gitlab.com/kefranabg/readme-md-generator',
contributingUrl:
'https://gitlab.com/kefranabg/readme-md-generator/issues',
homepage: 'https://gitlab.com/kefranabg/readme-md-generator',
githubUsername: undefined,
engines: {
npm: '>=5.5.0',
Expand Down Expand Up @@ -145,6 +147,7 @@ describe('projectInfos', () => {
repositoryUrl: 'https://github.com/kefranabg/readme-md-generator',
contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
homepage: undefined,
githubUsername: 'kefranabg',
engines: undefined,
licenseName: undefined,
Expand Down Expand Up @@ -172,6 +175,7 @@ describe('projectInfos', () => {
repositoryUrl: 'https://gitlab.com/kefranabg/readme-md-generator',
contributingUrl:
'https://gitlab.com/kefranabg/readme-md-generator/issues',
homepage: undefined,
githubUsername: undefined,
engines: undefined,
licenseName: undefined,
Expand All @@ -196,6 +200,7 @@ describe('projectInfos', () => {
author: undefined,
repositoryUrl: undefined,
contributingUrl: undefined,
homepage: undefined,
githubUsername: undefined,
engines: undefined,
licenseName: undefined,
Expand Down Expand Up @@ -240,6 +245,7 @@ describe('projectInfos', () => {
repositoryUrl: 'https://github.com/kefranabg/readme-md-generator',
contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
homepage: 'https://github.com/kefranabg/readme-md-generator',
githubUsername: 'kefranabg',
engines: {
npm: '>=5.5.0',
Expand Down
1 change: 1 addition & 0 deletions src/questions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
askProjectName: require('./project-name'),
askProjectVersion: require('./project-version'),
askProjectDescription: require('./project-description'),
askProjectHomepage: require('./project-homepage'),
askProjectDocumentationUrl: require('./project-documentation-url'),
askAuhtorName: require('./author-name'),
askAuthorGithub: require('./author-github'),
Expand Down
1 change: 1 addition & 0 deletions src/questions/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('questions', () => {
'askProjectName',
'askProjectVersion',
'askProjectDescription',
'askProjectHomepage',
'askProjectDocumentationUrl',
'askAuhtorName',
'askAuthorGithub',
Expand Down
6 changes: 6 additions & 0 deletions src/questions/project-homepage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = projectInfos => ({
type: 'input',
message: '🏠 Project homepage (use empty value to skip)',
name: 'projectHomepage',
default: projectInfos.homepage
})
17 changes: 17 additions & 0 deletions src/questions/project-homepage.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const askProjectHomepage = require('./project-homepage')

describe('askProjectHomepage', () => {
it('should return correct question format', () => {
const homepage = 'homepage'
const projectInfos = { homepage }

const result = askProjectHomepage(projectInfos)

expect(result).toEqual({
type: 'input',
message: '🏠 Project homepage (use empty value to skip)',
name: 'projectHomepage',
default: homepage
})
})
})
6 changes: 6 additions & 0 deletions src/readme.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ describe('readme', () => {
'Generates beautiful README files from git config & package.json infos',
projectDocumentationUrl:
'https://github.com/kefranabg/readme-md-generator#readme',
projectHomepage:
'https://github.com/kefranabg/readme-md-generator#readme',
authorName: 'Franck Abgrall',
authorGithubUsername: 'kefranabg',
authorTwitterUsername: '',
Expand Down Expand Up @@ -83,6 +85,10 @@ describe('readme', () => {
> Generates beautiful README files from git config & package.json infos
## 🏠 Homepage
[https://github.com/kefranabg/readme-md-generator#readme](https://github.com/kefranabg/readme-md-generator#readme)
## ⚠️ Prerequisites
- npm >=5.5.0
Expand Down
6 changes: 6 additions & 0 deletions templates/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

> <%= projectDescription %>
<% } -%>
<% if (projectHomepage) { -%>
## 🏠 Homepage

[<%= projectHomepage %>](<%= projectHomepage %>)
<% } -%>
<% if (projectPrerequisites) { -%>

## ⚠️ Prerequisites
Expand Down

0 comments on commit 1c1bf08

Please sign in to comment.