Skip to content

Commit ef8ef73

Browse files
author
Jérémie Parker
committed
feat(contributors): add new contributor to multiple languages & projects
1 parent 81b2f35 commit ef8ef73

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

cli.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
updateTranslations,
1313
viewProject,
1414
listContributors,
15+
addContributor,
1516
} = require('./gitpo')
1617

1718
let languages = []
@@ -157,6 +158,9 @@ inquirer
157158
case CONTRIBUTORS_LIST:
158159
listContributors().then((res) => console.log(pj.render(res)))
159160
break
161+
case CONTRIBUTORS_ADD:
162+
addContributor(email, fullname, projects, languages).then(() => console.log('Contributor added'))
163+
break
160164
default:
161165
console.log('Sorry, I did not get what it is that you want...')
162166
}

gitpo.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const synchronizeTerms = require('./lib/synchronizeTerms')(conf)
77
const updateTranslations = require('./lib/updateTranslations')(conf)
88
const viewProject = require('./lib/viewProject')(conf)
99
const listContributors = require('./lib/listContributors')(conf)
10+
const addContributor = require('./lib/addContributor')(conf)
1011

1112
module.exports = {
1213
cleanTranslationJSON,
@@ -17,4 +18,5 @@ module.exports = {
1718
updateTranslations,
1819
viewProject,
1920
listContributors,
21+
addContributor,
2022
}

lib/addContributor.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const rp = require('request-promise')
2+
3+
module.exports = ({ API_TOKEN }) => (email, name, projects, languages) =>
4+
Promise.all(
5+
projects.map(async (id) =>
6+
Promise.all(
7+
languages.map(async (language) =>
8+
rp({
9+
method: 'POST',
10+
url: 'https://api.poeditor.com/v2/contributors/add',
11+
headers: {
12+
'content-type': 'application/x-www-form-urlencoded',
13+
},
14+
form: {
15+
api_token: API_TOKEN,
16+
admin: 0,
17+
id,
18+
name,
19+
email,
20+
language,
21+
},
22+
})
23+
)
24+
)
25+
)
26+
)

0 commit comments

Comments
 (0)