blob: 96110307aa3b6c07f7a374577744c9a462400e3f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
import { doRequest } from '../server/helpers/requests'
import { readFileSync } from 'fs-extra'
run()
.then(() => process.exit(0))
.catch(err => {
console.error(err)
process.exit(-1)
})
async function run () {
{
const contributors = await fetchGithub('https://api.github.com/repos/chocobozzz/peertube/contributors')
console.log('# Code\n')
for (const contributor of contributors) {
const contributorUrl = contributor.url.replace('api.github.com/users', 'github.com')
console.log(` * [${contributor.login}](${contributorUrl})`)
}
}
{
const zanataConfig = readFileSync(require('os').homedir() + '/.config/zanata.ini').toString()
const zanataUsername = zanataConfig.match('.username=([^\n]+)')[1]
const zanataToken = zanataConfig.match('.key=([^\n]+)')[1]
const translators = await fetchZanata(zanataUsername, zanataToken)
console.log('\n\n# Translations\n')
for (const translator of translators) {
console.log(` * [${translator.username}](https://trad.framasoft.org/zanata/profile/view/${translator.username})`)
}
}
{
console.log('\n\n# Design\n')
console.log('By [Olivier Massain](https://twitter.com/omassain)\n')
console.log('Icons from [Robbie Pearce](https://robbiepearce.com/softies/)')
}
}
function get (url: string, headers: any = {}) {
return doRequest<any>({
uri: url,
json: true,
headers: Object.assign(headers, {
'User-Agent': 'PeerTube-App'
})
}).then(res => res.body)
}
async function fetchGithub (url: string) {
let next = url
let allResult = []
let i = 1
// Hard limit
while (i < 20) {
const result = await get(next + '?page=' + i)
if (result.length === 0) break
allResult = allResult.concat(result)
i++
}
return allResult
}
async function fetchZanata (zanataUsername: string, zanataPassword: string) {
const today = new Date().toISOString().split('T')[0]
const year2018 = `https://trad.framasoft.org/zanata/rest/project/peertube/version/develop/contributors/2018-01-01..2019-01-01`
const year2019 = `https://trad.framasoft.org/zanata/rest/project/peertube/version/develop/contributors/2019-01-01..${today}`
const headers = {
'X-Auth-User': zanataUsername,
'X-Auth-Token': zanataPassword
}
const [ results2018, results2019 ] = await Promise.all([
get(year2018, headers),
get(year2019, headers)
])
return results2018.concat(results2019)
}
|