mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 13:36:29 +00:00
* run prettier on everything * add hipstersmoothie as contributor
This commit is contained in:
parent
526d4dbba2
commit
4f7bbdf56f
12 changed files with 156 additions and 90 deletions
|
@ -204,6 +204,17 @@
|
|||
"doc",
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "hipstersmoothie",
|
||||
"name": "Andrew Lisowski",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/1192452?v=4",
|
||||
"profile": "http://hipstersmoothie.com",
|
||||
"contributions": [
|
||||
"code",
|
||||
"doc",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
[![version][version-badge]][package] [![downloads][downloads-badge]][downloads]
|
||||
[![MIT License][license-badge]][license]
|
||||
|
||||
[![All Contributors](https://img.shields.io/badge/all_contributors-21-orange.svg?style=flat-square)](#contributors)
|
||||
[![All Contributors](https://img.shields.io/badge/all_contributors-22-orange.svg?style=flat-square)](#contributors)
|
||||
[![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc]
|
||||
[![Watch on GitHub][github-watch-badge]][github-watch]
|
||||
[![Star on GitHub][github-star-badge]][github-star]
|
||||
|
@ -178,7 +178,7 @@ Thanks goes to these wonderful people
|
|||
| :---: | :---: | :---: | :---: | :---: | :---: |
|
||||
| [<img src="https://avatars3.githubusercontent.com/u/8212?v=3" width="100px;"/><br /><sub><b>Jerod Santo</b></sub>](https://jerodsanto.net)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jerodsanto "Code") | [<img src="https://avatars1.githubusercontent.com/u/574871?v=3" width="100px;"/><br /><sub><b>Kevin Jalbert</b></sub>](https://github.com/kevinjalbert)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=kevinjalbert "Code") | [<img src="https://avatars3.githubusercontent.com/u/5038030?v=4" width="100px;"/><br /><sub><b>tunnckoCore</b></sub>](https://i.am.charlike.online)<br />[🔧](#tool-charlike "Tools") | [<img src="https://avatars2.githubusercontent.com/u/304450?v=4" width="100px;"/><br /><sub><b>Mehdi Achour</b></sub>](https://machour.idk.tn/)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=machour "Code") | [<img src="https://avatars1.githubusercontent.com/u/8344688?v=4" width="100px;"/><br /><sub><b>Roy Revelt</b></sub>](https://codsen.com)<br />[🐛](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3Arevelt "Bug reports") | [<img src="https://avatars1.githubusercontent.com/u/422331?v=4" width="100px;"/><br /><sub><b>Chris Vickery</b></sub>](https://github.com/chrisinajar)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=chrisinajar "Code") |
|
||||
| [<img src="https://avatars2.githubusercontent.com/u/1026002?v=4" width="100px;"/><br /><sub><b>Bryce Reynolds</b></sub>](https://github.com/brycereynolds)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=brycereynolds "Code") | [<img src="https://avatars3.githubusercontent.com/u/2322305?v=4" width="100px;"/><br /><sub><b>James, please</b></sub>](http://www.jmeas.com)<br />[🤔](#ideas-jmeas "Ideas, Planning, & Feedback") [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jmeas "Code") | [<img src="https://avatars3.githubusercontent.com/u/1057324?v=4" width="100px;"/><br /><sub><b>Spyros Ioakeimidis</b></sub>](http://www.spyros.io)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=spirosikmd "Code") | [<img src="https://avatars3.githubusercontent.com/u/12335761?v=4" width="100px;"/><br /><sub><b>Fernando Costa</b></sub>](https://github.com/fadc80)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=fadc80 "Code") | [<img src="https://avatars0.githubusercontent.com/u/197404?v=4" width="100px;"/><br /><sub><b>snipe</b></sub>](https://snipe.net)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=snipe "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/997157?v=4" width="100px;"/><br /><sub><b>Gant Laborde</b></sub>](http://gantlaborde.com/)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=GantMan "Code") |
|
||||
| [<img src="https://avatars2.githubusercontent.com/u/17708702?v=4" width="100px;"/><br /><sub><b>Md Zubair Ahmed</b></sub>](https://in.linkedin.com/in/mzubairahmed)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Documentation") [🐛](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3AM-ZubairAhmed "Bug reports") [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Code") [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Tests") | [<img src="https://avatars3.githubusercontent.com/u/6177621?v=4" width="100px;"/><br /><sub><b>Divjot Singh</b></sub>](http://bogas04.github.io)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=bogas04 "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/15315098?v=4" width="100px;"/><br /><sub><b>João Marques</b></sub>](https://github.com/tigermarques)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=tigermarques "Code") [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=tigermarques "Documentation") [🤔](#ideas-tigermarques "Ideas, Planning, & Feedback") |
|
||||
| [<img src="https://avatars2.githubusercontent.com/u/17708702?v=4" width="100px;"/><br /><sub><b>Md Zubair Ahmed</b></sub>](https://in.linkedin.com/in/mzubairahmed)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Documentation") [🐛](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3AM-ZubairAhmed "Bug reports") [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Code") [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Tests") | [<img src="https://avatars3.githubusercontent.com/u/6177621?v=4" width="100px;"/><br /><sub><b>Divjot Singh</b></sub>](http://bogas04.github.io)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=bogas04 "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/15315098?v=4" width="100px;"/><br /><sub><b>João Marques</b></sub>](https://github.com/tigermarques)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=tigermarques "Code") [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=tigermarques "Documentation") [🤔](#ideas-tigermarques "Ideas, Planning, & Feedback") | [<img src="https://avatars3.githubusercontent.com/u/1192452?v=4" width="100px;"/><br /><sub><b>Andrew Lisowski</b></sub>](http://hipstersmoothie.com)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=hipstersmoothie "Code") [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=hipstersmoothie "Documentation") [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=hipstersmoothie "Tests") |
|
||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||
|
||||
This project follows the
|
||||
|
|
30
src/cli.js
30
src/cli.js
|
@ -76,7 +76,12 @@ function checkContributors(argv) {
|
|||
const configData = util.configFile.readConfig(argv.config)
|
||||
|
||||
return repo
|
||||
.getContributors(configData.projectOwner, configData.projectName, configData.repoType, configData.repoHost)
|
||||
.getContributors(
|
||||
configData.projectOwner,
|
||||
configData.projectName,
|
||||
configData.repoType,
|
||||
configData.repoHost,
|
||||
)
|
||||
.then(repoContributors => {
|
||||
const checkKey = repo.getCheckKey(configData.repoType)
|
||||
const knownContributions = configData.contributors.reduce((obj, item) => {
|
||||
|
@ -138,7 +143,8 @@ function promptForCommand(argv) {
|
|||
value: 'generate',
|
||||
},
|
||||
{
|
||||
name: 'Compare contributors from the repository with the credited ones',
|
||||
name:
|
||||
'Compare contributors from the repository with the credited ones',
|
||||
value: 'check',
|
||||
},
|
||||
],
|
||||
|
@ -155,16 +161,16 @@ function promptForCommand(argv) {
|
|||
promptForCommand(yargv)
|
||||
.then(command => {
|
||||
switch (command) {
|
||||
case 'init':
|
||||
return init()
|
||||
case 'generate':
|
||||
return startGeneration(yargv)
|
||||
case 'add':
|
||||
return addContribution(yargv)
|
||||
case 'check':
|
||||
return checkContributors(yargv)
|
||||
default:
|
||||
throw new Error(`Unknown command ${command}`)
|
||||
case 'init':
|
||||
return init()
|
||||
case 'generate':
|
||||
return startGeneration(yargv)
|
||||
case 'add':
|
||||
return addContribution(yargv)
|
||||
case 'check':
|
||||
return checkContributors(yargv)
|
||||
default:
|
||||
throw new Error(`Unknown command ${command}`)
|
||||
}
|
||||
})
|
||||
.catch(onError)
|
||||
|
|
|
@ -38,12 +38,14 @@ function updateExistingContributor(options, username, contributions) {
|
|||
}
|
||||
|
||||
function addNewContributor(options, username, contributions, infoFetcher) {
|
||||
return infoFetcher(username, options.repoType, options.repoHost).then(userData => {
|
||||
const contributor = _.assign(userData, {
|
||||
contributions: formatContributions(options, [], contributions),
|
||||
})
|
||||
return options.contributors.concat(contributor)
|
||||
})
|
||||
return infoFetcher(username, options.repoType, options.repoHost).then(
|
||||
userData => {
|
||||
const contributor = _.assign(userData, {
|
||||
contributions: formatContributions(options, [], contributions),
|
||||
})
|
||||
return options.contributors.concat(contributor)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = function addContributor(
|
||||
|
|
|
@ -127,6 +127,9 @@ test('retrieve user from a different github registry', async () => {
|
|||
html_url: 'http://github.myhost.com:3000/nodisplayname',
|
||||
})
|
||||
|
||||
const info = await getUserInfo('nodisplayname', 'http://github.myhost.com:3000')
|
||||
const info = await getUserInfo(
|
||||
'nodisplayname',
|
||||
'http://github.myhost.com:3000',
|
||||
)
|
||||
expect(info.name).toBe('No Display Name')
|
||||
})
|
||||
|
|
|
@ -19,12 +19,15 @@ test('handle errors', async () => {
|
|||
test('fill in the name when it is returned', async () => {
|
||||
nock('https://gitlab.com')
|
||||
.get('/api/v4/users?username=nodisplayname')
|
||||
.reply(200, [{
|
||||
username: 'nodisplayname',
|
||||
name: 'No Display Name',
|
||||
avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
web_url: 'https://gitlab.com/nodisplayname',
|
||||
}])
|
||||
.reply(200, [
|
||||
{
|
||||
username: 'nodisplayname',
|
||||
name: 'No Display Name',
|
||||
avatar_url:
|
||||
'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
web_url: 'https://gitlab.com/nodisplayname',
|
||||
},
|
||||
])
|
||||
|
||||
const info = await getUserInfo('nodisplayname')
|
||||
expect(info.name).toBe('No Display Name')
|
||||
|
@ -33,12 +36,15 @@ test('fill in the name when it is returned', async () => {
|
|||
test('fill in the name when null is returned', async () => {
|
||||
nock('https://gitlab.com')
|
||||
.get('/api/v4/users?username=nodisplayname')
|
||||
.reply(200, [{
|
||||
username: 'nodisplayname',
|
||||
name: null,
|
||||
avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
web_url: 'https://gitlab.com/nodisplayname',
|
||||
}])
|
||||
.reply(200, [
|
||||
{
|
||||
username: 'nodisplayname',
|
||||
name: null,
|
||||
avatar_url:
|
||||
'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
web_url: 'https://gitlab.com/nodisplayname',
|
||||
},
|
||||
])
|
||||
|
||||
const info = await getUserInfo('nodisplayname')
|
||||
expect(info.name).toBe('nodisplayname')
|
||||
|
@ -47,12 +53,15 @@ test('fill in the name when null is returned', async () => {
|
|||
test('fill in the name when an empty string is returned', async () => {
|
||||
nock('https://gitlab.com')
|
||||
.get('/api/v4/users?username=nodisplayname')
|
||||
.reply(200, [{
|
||||
username: 'nodisplayname',
|
||||
name: '',
|
||||
avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
web_url: 'https://gitlab.com/nodisplayname',
|
||||
}])
|
||||
.reply(200, [
|
||||
{
|
||||
username: 'nodisplayname',
|
||||
name: '',
|
||||
avatar_url:
|
||||
'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
web_url: 'https://gitlab.com/nodisplayname',
|
||||
},
|
||||
])
|
||||
|
||||
const info = await getUserInfo('nodisplayname')
|
||||
expect(info.name).toBe('nodisplayname')
|
||||
|
@ -61,12 +70,15 @@ test('fill in the name when an empty string is returned', async () => {
|
|||
test('append http when no absolute link is provided', async () => {
|
||||
nock('https://gitlab.com')
|
||||
.get('/api/v4/users?username=nodisplayname')
|
||||
.reply(200, [{
|
||||
username: 'nodisplayname',
|
||||
name: 'No Display Name',
|
||||
avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
web_url: 'www.gitlab.com/nodisplayname',
|
||||
}])
|
||||
.reply(200, [
|
||||
{
|
||||
username: 'nodisplayname',
|
||||
name: 'No Display Name',
|
||||
avatar_url:
|
||||
'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
web_url: 'www.gitlab.com/nodisplayname',
|
||||
},
|
||||
])
|
||||
|
||||
const info = await getUserInfo('nodisplayname')
|
||||
expect(info.profile).toBe('http://www.gitlab.com/nodisplayname')
|
||||
|
@ -75,13 +87,19 @@ test('append http when no absolute link is provided', async () => {
|
|||
test('retrieve user from a different gitlab registry', async () => {
|
||||
nock('http://gitlab.myhost.com:3000')
|
||||
.get('/api/v4/users?username=nodisplayname')
|
||||
.reply(200, [{
|
||||
username: 'nodisplayname',
|
||||
name: 'No Display Name',
|
||||
avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
web_url: 'https://gitlab.com/nodisplayname',
|
||||
}])
|
||||
.reply(200, [
|
||||
{
|
||||
username: 'nodisplayname',
|
||||
name: 'No Display Name',
|
||||
avatar_url:
|
||||
'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
web_url: 'https://gitlab.com/nodisplayname',
|
||||
},
|
||||
])
|
||||
|
||||
const info = await getUserInfo('nodisplayname', 'http://gitlab.myhost.com:3000')
|
||||
const info = await getUserInfo(
|
||||
'nodisplayname',
|
||||
'http://gitlab.myhost.com:3000',
|
||||
)
|
||||
expect(info.name).toBe('No Display Name')
|
||||
})
|
||||
|
|
|
@ -7,20 +7,27 @@ const githubAPI = require('../github')
|
|||
const gitlabAPI = require('../gitlab')
|
||||
|
||||
test('get choices for init command', () => {
|
||||
expect(repo.getChoices()).toEqual([{
|
||||
value: 'github',
|
||||
name: 'GitHub'
|
||||
}, {
|
||||
value: 'gitlab',
|
||||
name: 'GitLab'
|
||||
}])
|
||||
expect(repo.getChoices()).toEqual([
|
||||
{
|
||||
value: 'github',
|
||||
name: 'GitHub',
|
||||
},
|
||||
{
|
||||
value: 'gitlab',
|
||||
name: 'GitLab',
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
test('get hostname for a given repo type', () => {
|
||||
expect(repo.getHostname('github')).toEqual('https://github.com')
|
||||
expect(repo.getHostname('github', 'http://my-github.com')).toEqual('http://my-github.com')
|
||||
expect(repo.getHostname('github', 'http://my-github.com')).toEqual(
|
||||
'http://my-github.com',
|
||||
)
|
||||
expect(repo.getHostname('gitlab')).toEqual('https://gitlab.com')
|
||||
expect(repo.getHostname('gitlab', 'http://my-gitlab.com:3000')).toEqual('http://my-gitlab.com:3000')
|
||||
expect(repo.getHostname('gitlab', 'http://my-gitlab.com:3000')).toEqual(
|
||||
'http://my-gitlab.com:3000',
|
||||
)
|
||||
expect(repo.getHostname('other')).toBe(null)
|
||||
})
|
||||
|
||||
|
@ -43,7 +50,8 @@ test('get user info calls underlying APIs', () => {
|
|||
return {
|
||||
login: 'nodisplayname',
|
||||
name: 'nodisplayname',
|
||||
avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
avatar_url:
|
||||
'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
profile: 'https://gitlab.com/nodisplayname',
|
||||
}
|
||||
})
|
||||
|
@ -57,7 +65,8 @@ test('get user info calls underlying APIs', () => {
|
|||
expect(repo.getUserInfo('nodisplayname', 'gitlab')).toEqual({
|
||||
login: 'nodisplayname',
|
||||
name: 'nodisplayname',
|
||||
avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
avatar_url:
|
||||
'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon',
|
||||
profile: 'https://gitlab.com/nodisplayname',
|
||||
})
|
||||
expect(repo.getUserInfo('nodisplayname', 'other')).toBe(null)
|
||||
|
|
|
@ -47,7 +47,7 @@ function getContributorsPage(url) {
|
|||
const getUserInfo = function(username, hostname) {
|
||||
/* eslint-disable complexity */
|
||||
if (!hostname) {
|
||||
hostname = 'https://github.com';
|
||||
hostname = 'https://github.com'
|
||||
}
|
||||
|
||||
const root = hostname.replace(/:\/\//, '://api.')
|
||||
|
@ -80,7 +80,7 @@ const getUserInfo = function(username, hostname) {
|
|||
|
||||
const getContributors = function(owner, name, hostname) {
|
||||
if (!hostname) {
|
||||
hostname = 'https://github.com';
|
||||
hostname = 'https://github.com'
|
||||
}
|
||||
|
||||
const root = hostname.replace(/:\/\//, '://api.')
|
||||
|
@ -90,5 +90,5 @@ const getContributors = function(owner, name, hostname) {
|
|||
|
||||
module.exports = {
|
||||
getUserInfo,
|
||||
getContributors
|
||||
getContributors,
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ const request = pify(require('request'))
|
|||
const getUserInfo = function(username, hostname) {
|
||||
/* eslint-disable complexity */
|
||||
if (!hostname) {
|
||||
hostname = 'https://gitlab.com';
|
||||
hostname = 'https://gitlab.com'
|
||||
}
|
||||
|
||||
return request
|
||||
|
@ -28,14 +28,16 @@ const getUserInfo = function(username, hostname) {
|
|||
login: user.username,
|
||||
name: user.name || username,
|
||||
avatar_url: user.avatar_url,
|
||||
profile: user.web_url.startsWith('http') ? user.web_url : `http://${user.web_url}`,
|
||||
profile: user.web_url.startsWith('http')
|
||||
? user.web_url
|
||||
: `http://${user.web_url}`,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const getContributors = function(owner, name, hostname) {
|
||||
if (!hostname) {
|
||||
hostname = 'https://gitlab.com';
|
||||
hostname = 'https://gitlab.com'
|
||||
}
|
||||
|
||||
return request
|
||||
|
@ -57,7 +59,7 @@ const getContributors = function(owner, name, hostname) {
|
|||
for (let i = 0; i < projects.length; i++) {
|
||||
if (projects[i].path_with_namespace === `${owner}/${name}`) {
|
||||
project = projects[i]
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +69,9 @@ const getContributors = function(owner, name, hostname) {
|
|||
|
||||
return request
|
||||
.get({
|
||||
url: `${hostname}/api/v4/projects/${project.id}/repository/contributors`,
|
||||
url: `${hostname}/api/v4/projects/${
|
||||
project.id
|
||||
}/repository/contributors`,
|
||||
headers: {
|
||||
'User-Agent': 'request',
|
||||
},
|
||||
|
@ -87,5 +91,5 @@ const getContributors = function(owner, name, hostname) {
|
|||
|
||||
module.exports = {
|
||||
getUserInfo,
|
||||
getContributors
|
||||
getContributors,
|
||||
}
|
||||
|
|
|
@ -7,30 +7,36 @@ const SUPPORTED_REPO_TYPES = {
|
|||
name: 'GitHub',
|
||||
checkKey: 'login',
|
||||
defaultHost: 'https://github.com',
|
||||
linkToCommits: '<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits?author=<%= contributor.login %>',
|
||||
linkToIssues: '<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?q=author%3A<%= contributor.login %>',
|
||||
linkToCommits:
|
||||
'<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits?author=<%= contributor.login %>',
|
||||
linkToIssues:
|
||||
'<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?q=author%3A<%= contributor.login %>',
|
||||
getUserInfo: githubAPI.getUserInfo,
|
||||
getContributors: githubAPI.getContributors
|
||||
getContributors: githubAPI.getContributors,
|
||||
},
|
||||
gitlab: {
|
||||
value: 'gitlab',
|
||||
name: 'GitLab',
|
||||
checkKey: 'name',
|
||||
defaultHost: 'https://gitlab.com',
|
||||
linkToCommits: '<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits/master',
|
||||
linkToIssues: '<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?author_username=<%= contributor.login %>',
|
||||
linkToCommits:
|
||||
'<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits/master',
|
||||
linkToIssues:
|
||||
'<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?author_username=<%= contributor.login %>',
|
||||
getUserInfo: gitlabAPI.getUserInfo,
|
||||
getContributors: gitlabAPI.getContributors
|
||||
}
|
||||
getContributors: gitlabAPI.getContributors,
|
||||
},
|
||||
}
|
||||
|
||||
const getChoices = function() {
|
||||
return Object.keys(SUPPORTED_REPO_TYPES).map(key => SUPPORTED_REPO_TYPES[key]).map(item => {
|
||||
return {
|
||||
value: item.value,
|
||||
name: item.name
|
||||
}
|
||||
})
|
||||
return Object.keys(SUPPORTED_REPO_TYPES)
|
||||
.map(key => SUPPORTED_REPO_TYPES[key])
|
||||
.map(item => {
|
||||
return {
|
||||
value: item.value,
|
||||
name: item.name,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const getHostname = function(repoType, repoHost) {
|
||||
|
@ -72,14 +78,21 @@ const getLinkToIssues = function(repoType) {
|
|||
|
||||
const getUserInfo = function(username, repoType, repoHost) {
|
||||
if (repoType in SUPPORTED_REPO_TYPES) {
|
||||
return SUPPORTED_REPO_TYPES[repoType].getUserInfo(username, getHostname(repoType, repoHost))
|
||||
return SUPPORTED_REPO_TYPES[repoType].getUserInfo(
|
||||
username,
|
||||
getHostname(repoType, repoHost),
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const getContributors = function(owner, name, repoType, repoHost) {
|
||||
if (repoType in SUPPORTED_REPO_TYPES) {
|
||||
return SUPPORTED_REPO_TYPES[repoType].getContributors(owner, name, getHostname(repoType, repoHost))
|
||||
return SUPPORTED_REPO_TYPES[repoType].getContributors(
|
||||
owner,
|
||||
name,
|
||||
getHostname(repoType, repoHost),
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
@ -92,5 +105,5 @@ module.exports = {
|
|||
getLinkToCommits,
|
||||
getLinkToIssues,
|
||||
getUserInfo,
|
||||
getContributors
|
||||
getContributors,
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ const defaultTypes = function(repoType) {
|
|||
video: {
|
||||
symbol: '📹',
|
||||
description: 'Videos',
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,5 +2,5 @@ module.exports = {
|
|||
configFile: require('./config-file'),
|
||||
contributionTypes: require('./contribution-types'),
|
||||
git: require('./git'),
|
||||
markdown: require('./markdown')
|
||||
markdown: require('./markdown'),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue