Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨Ask user for a link to contributing guide (fixes #168) #179

Merged
merged 6 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/__snapshots__/readme.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ npm run test

## 🤝 Contributing

Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/kefranabg/readme-md-generator/issues).
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/kefranabg/readme-md-generator/issues). You can also take a look at the [contributing guide](https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md).

## Show your support

Expand Down Expand Up @@ -133,7 +133,7 @@ npm run test

Contributions, issues and feature requests are welcome!

Feel free to check [issues page](https://github.com/kefranabg/readme-md-generator/issues).
Feel free to check [issues page](https://github.com/kefranabg/readme-md-generator/issues). You can also take a look at the [contributing guide](https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md).

## Show your support

Expand Down
9 changes: 8 additions & 1 deletion src/project-infos.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ const getLicenseUrlFromGithubRepositoryUrl = repositoryUrl =>
const getReadmeUrlFromGithubRepositoryUrl = repositoryUrl =>
`${repositoryUrl}#readme`

const getContributingUrlFromRepositoryUrl = repositoryUrl =>
`${repositoryUrl}/blob/master/CONTRIBUTING.md`

/**
* Get project author name from package.json
*
Expand Down Expand Up @@ -137,8 +140,11 @@ const getProjectInfos = async () => {
? 'npm run test'
: undefined
const repositoryUrl = await getReposUrl(packageJson)
const contributingUrl = await getReposIssuesUrl(packageJson)
const issuesUrl = await getReposIssuesUrl(packageJson)
const isGithubRepos = isGithubRepository(repositoryUrl)
const contributingUrl = repositoryUrl
? getContributingUrlFromRepositoryUrl(repositoryUrl)
: undefined
const documentationUrl = isGithubRepos
? getReadmeUrlFromGithubRepositoryUrl(repositoryUrl)
: undefined
Expand All @@ -162,6 +168,7 @@ const getProjectInfos = async () => {
authorWebsite,
homepage,
repositoryUrl,
issuesUrl,
contributingUrl,
githubUsername,
engines,
Expand Down
19 changes: 13 additions & 6 deletions src/project-infos.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('projectInfos', () => {
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',
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
authorWebsite: 'https://www.franck-abgrall.me/',
githubUsername: 'kefranabg',
engines: {
Expand All @@ -84,6 +84,7 @@ describe('projectInfos', () => {
'https://github.com/kefranabg/readme-md-generator#readme',
isGithubRepos: true,
isJSProject: true,
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
usage: undefined,
testCommand: undefined
})
Expand Down Expand Up @@ -123,7 +124,7 @@ describe('projectInfos', () => {
author: 'Franck Abgrall',
repositoryUrl: 'https://gitlab.com/kefranabg/readme-md-generator',
contributingUrl:
'https://gitlab.com/kefranabg/readme-md-generator/issues',
'https://gitlab.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
homepage: 'https://gitlab.com/kefranabg/readme-md-generator',
githubUsername: undefined,
authorWebsite: undefined,
Expand All @@ -136,6 +137,7 @@ describe('projectInfos', () => {
documentationUrl: undefined,
isGithubRepos: false,
isJSProject: true,
issuesUrl: 'https://gitlab.com/kefranabg/readme-md-generator/issues',
usage: undefined,
testCommand: undefined
})
Expand All @@ -156,7 +158,7 @@ describe('projectInfos', () => {
author: undefined,
repositoryUrl: 'https://github.com/kefranabg/readme-md-generator',
contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
homepage: undefined,
githubUsername: 'kefranabg',
authorWebsite: 'https://www.franck-abgrall.me/',
Expand All @@ -168,6 +170,7 @@ describe('projectInfos', () => {
'https://github.com/kefranabg/readme-md-generator#readme',
isGithubRepos: true,
isJSProject: false,
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
usage: undefined,
testCommand: undefined
})
Expand All @@ -187,8 +190,9 @@ describe('projectInfos', () => {
version: undefined,
author: undefined,
repositoryUrl: 'https://gitlab.com/kefranabg/readme-md-generator',
authorWebsite: undefined,
contributingUrl:
'https://gitlab.com/kefranabg/readme-md-generator/issues',
'https://gitlab.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
homepage: undefined,
githubUsername: undefined,
engines: undefined,
Expand All @@ -197,6 +201,7 @@ describe('projectInfos', () => {
documentationUrl: undefined,
isGithubRepos: false,
isJSProject: false,
issuesUrl: 'https://gitlab.com/kefranabg/readme-md-generator/issues',
usage: undefined,
testCommand: undefined
})
Expand Down Expand Up @@ -265,7 +270,7 @@ describe('projectInfos', () => {
author: 'Franck Abgrall',
repositoryUrl: 'https://github.com/kefranabg/readme-md-generator',
contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
homepage: 'https://github.com/kefranabg/readme-md-generator',
githubUsername: 'kefranabg',
authorWebsite: 'https://www.franck-abgrall.me/',
Expand All @@ -280,6 +285,7 @@ describe('projectInfos', () => {
'https://github.com/kefranabg/readme-md-generator#readme',
isGithubRepos: true,
isJSProject: true,
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
usage: undefined,
testCommand: undefined
})
Expand Down Expand Up @@ -324,7 +330,7 @@ describe('projectInfos', () => {
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',
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
githubUsername: 'kefranabg',
authorWebsite: 'https://www.franck-abgrall.me/',
engines: {
Expand All @@ -338,6 +344,7 @@ describe('projectInfos', () => {
'https://github.com/kefranabg/readme-md-generator#readme',
isGithubRepos: true,
isJSProject: true,
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
usage: undefined,
testCommand: undefined
})
Expand Down
6 changes: 6 additions & 0 deletions src/questions/contributing-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = projectInfos => ({
type: 'input',
message: '🤝 Contributing guide url (use empty value to skip)',
name: 'contributingUrl',
default: projectInfos.contributingUrl
})
18 changes: 18 additions & 0 deletions src/questions/contributing-url.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const askContributingUrl = require('./contributing-url')

describe('askContributingUrl', () => {
it('should return correct question format', () => {
const contributingUrl =
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md'
const projectInfos = { contributingUrl }

const result = askContributingUrl(projectInfos)

expect(result).toEqual({
type: 'input',
message: '🤝 Contributing guide url (use empty value to skip)',
name: 'contributingUrl',
default: contributingUrl
})
})
})
18 changes: 0 additions & 18 deletions src/questions/contributing.spec.js

This file was deleted.

3 changes: 2 additions & 1 deletion src/questions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = {
askProjectPrerequisites: require('./project-prerequisites'),
askLicenseName: require('./license-name'),
askLicenseUrl: require('./license-url'),
askContributing: require('./contributing'),
askIssuesUrl: require('./issues-url'),
askContributingUrl: require('./contributing-url'),
askInstallCommand: require('./install-command'),
askUsage: require('./usage'),
askTestCommand: require('./test-command')
Expand Down
3 changes: 2 additions & 1 deletion src/questions/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ describe('questions', () => {
'askProjectPrerequisites',
'askLicenseName',
'askLicenseUrl',
'askContributing',
'askIssuesUrl',
'askContributingUrl',
'askInstallCommand',
'askUsage',
'askTestCommand'
Expand Down
4 changes: 2 additions & 2 deletions src/questions/contributing.js → src/questions/issues-url.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = packageJson => ({
type: 'input',
message: '🔧 Issues page url (use empty value to skip)',
name: 'contributingUrl',
default: packageJson.contributingUrl
name: 'issuesUrl',
default: packageJson.issuesUrl
})
17 changes: 17 additions & 0 deletions src/questions/issues-url.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const askIssues = require('./issues-url')

describe('askIssues', () => {
it('should return correct question format', () => {
const issuesUrl = 'https://github.com/kefranabg/readme-md-generator/issues'
const projectInfos = { issuesUrl }

const result = askIssues(projectInfos)

expect(result).toEqual({
type: 'input',
message: '🔧 Issues page url (use empty value to skip)',
name: 'issuesUrl',
default: issuesUrl
})
})
})
3 changes: 2 additions & 1 deletion src/readme.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ describe('readme', () => {
licenseName: 'MIT',
licenseUrl:
'https://github.com/kefranabg/readme-md-generator/blob/master/LICENSE',
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
installCommand: 'npm install',
usage: 'npm start',
testCommand: 'npm run test',
Expand Down
4 changes: 2 additions & 2 deletions templates/default-no-html.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@
* LinkedIn: [@<%= authorLinkedInUsername %>](https://linkedin.com/in/<%= authorLinkedInUsername %>)
<% } -%>
<% } -%>
<% if (contributingUrl) { -%>
<% if (issuesUrl) { -%>

## 🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check [issues page](<%= contributingUrl %>).
Feel free to check [issues page](<%= issuesUrl %>). <%= contributingUrl ? `You can also take a look at the [contributing guide](${contributingUrl}).` : '' %>
<% } -%>

## Show your support
Expand Down
4 changes: 2 additions & 2 deletions templates/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@
* LinkedIn: [@<%= authorLinkedInUsername %>](https://linkedin.com/in/<%= authorLinkedInUsername %>)
<% } -%>
<% } -%>
<% if (contributingUrl) { -%>
<% if (issuesUrl) { -%>

## 🤝 Contributing

Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](<%= contributingUrl %>).
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](<%= issuesUrl %>). <%= contributingUrl ? `You can also take a look at the [contributing guide](${contributingUrl}).` : '' %>
<% } -%>

## Show your support
Expand Down