aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/generate-code-contributors.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-22 17:06:32 +0200
committerChocobozzz <me@florianbigard.com>2018-06-22 17:08:44 +0200
commit92d83c6a78e86c66a55958f8e36a7f2e123efdf8 (patch)
treee03e146ec133b84a4891648f4d77dc552fa0b023 /scripts/generate-code-contributors.ts
parentcd080b1a6b17727633cb42bd18d39eb3f7a9e030 (diff)
downloadPeerTube-92d83c6a78e86c66a55958f8e36a7f2e123efdf8.tar.gz
PeerTube-92d83c6a78e86c66a55958f8e36a7f2e123efdf8.tar.zst
PeerTube-92d83c6a78e86c66a55958f8e36a7f2e123efdf8.zip
Fix git credits
Diffstat (limited to 'scripts/generate-code-contributors.ts')
-rwxr-xr-xscripts/generate-code-contributors.ts80
1 files changed, 80 insertions, 0 deletions
diff --git a/scripts/generate-code-contributors.ts b/scripts/generate-code-contributors.ts
new file mode 100755
index 000000000..0cce62180
--- /dev/null
+++ b/scripts/generate-code-contributors.ts
@@ -0,0 +1,80 @@
1import { doRequest } from '../server/helpers/requests'
2import { readFileSync } from 'fs'
3
4run()
5 .then(() => process.exit(0))
6 .catch(err => {
7 console.error(err)
8 process.exit(-1)
9 })
10
11async function run () {
12
13 {
14 const contributors = await fetchGithub('https://api.github.com/repos/chocobozzz/peertube/contributors')
15
16 console.log('# Code\n')
17 for (const contributor of contributors) {
18 const contributorUrl = contributor.url.replace('api.github.com/users', 'github.com')
19 console.log(` * [${contributor.login}](${contributorUrl})`)
20 }
21 }
22
23 {
24 const zanataConfig = readFileSync(require('os').homedir() + '/.config/zanata.ini').toString()
25 const zanataUsername = zanataConfig.match('.username=([^\n]+)')[1]
26 const zanataToken = zanataConfig.match('.key=([^\n]+)')[1]
27
28 const translators = await fetchZanata(zanataUsername, zanataToken)
29
30 console.log('\n\n# Translations\n')
31 for (const translator of translators) {
32 console.log(` * [${translator.username}](https://trad.framasoft.org/zanata/profile/view/${translator.username})`)
33 }
34 }
35
36 {
37 console.log('\n\n# Design\n')
38 console.log('By [Olivier Massain](https://twitter.com/omassain)\n')
39 console.log('Icons from [Robbie Pearce](https://robbiepearce.com/softies/)')
40 }
41}
42
43function get (url: string, headers: any = {}) {
44 return doRequest({
45 uri: url,
46 json: true,
47 headers: Object.assign(headers, {
48 'User-Agent': 'PeerTube-App'
49 })
50 }).then(res => res.body)
51}
52
53async function fetchGithub (url: string) {
54 let next = url
55 let allResult = []
56
57 let i = 1
58
59 // Hard limit
60 while (i < 20) {
61 const result = await get(next + '?page=' + i)
62 if (result.length === 0) break
63
64 allResult = allResult.concat(result)
65 i++
66 }
67
68 return allResult
69}
70
71async function fetchZanata (zanataUsername: string, zanataPassword: string) {
72 const today = new Date().toISOString().split('T')[0]
73 const url = `https://trad.framasoft.org/zanata/rest/project/peertube/version/develop/contributors/2018-01-01..${today}`
74
75 const headers = {
76 'X-Auth-User': zanataUsername,
77 'X-Auth-Token': zanataPassword
78 }
79 return get(url, headers)
80}