]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - scripts/generate-code-contributors.ts
Translated using Weblate (Czech)
[github/Chocobozzz/PeerTube.git] / scripts / generate-code-contributors.ts
index 0cce62180cb5c36420288228c39097679754408b..5635d988952e052131507e0fe0ef92be6cf3cc29 100755 (executable)
@@ -1,5 +1,10 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+
+registerTSPaths()
+
 import { doRequest } from '../server/helpers/requests'
-import { readFileSync } from 'fs'
+import { readFileSync } from 'fs-extra'
+import { uniqBy } from 'lodash'
 
 run()
   .then(() => process.exit(0))
@@ -13,7 +18,7 @@ async function run () {
   {
     const contributors = await fetchGithub('https://api.github.com/repos/chocobozzz/peertube/contributors')
 
-    console.log('# Code\n')
+    console.log('# Code contributors\n')
     for (const contributor of contributors) {
       const contributorUrl = contributor.url.replace('api.github.com/users', 'github.com')
       console.log(` * [${contributor.login}](${contributorUrl})`)
@@ -27,7 +32,7 @@ async function run () {
 
     const translators = await fetchZanata(zanataUsername, zanataToken)
 
-    console.log('\n\n# Translations\n')
+    console.log('\n\n# Translation contributors\n')
     for (const translator of translators) {
       console.log(` * [${translator.username}](https://trad.framasoft.org/zanata/profile/view/${translator.username})`)
     }
@@ -35,13 +40,17 @@ async function run () {
 
   {
     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/)')
+    console.log(' * [Olivier Massain](https://twitter.com/omassain)')
+
+    console.log('\n\n# Icons\n')
+    console.log(' * [Robbie Pearce](https://robbiepearce.com/softies/)')
+    console.log(' * [Fork-Awesome](https://github.com/ForkAwesome/Fork-Awesome)')
+    console.log(' * playlist add by Google')
   }
 }
 
 function get (url: string, headers: any = {}) {
-  return doRequest({
+  return doRequest<any>({
     uri: url,
     json: true,
     headers: Object.assign(headers, {
@@ -70,11 +79,17 @@ async function fetchGithub (url: string) {
 
 async function fetchZanata (zanataUsername: string, zanataPassword: string) {
   const today = new Date().toISOString().split('T')[0]
-  const url = `https://trad.framasoft.org/zanata/rest/project/peertube/version/develop/contributors/2018-01-01..${today}`
+  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
   }
-  return get(url, headers)
+  const [ results2018, results2019 ] = await Promise.all([
+    get(year2018, headers),
+    get(year2019, headers)
+  ])
+
+  return uniqBy(results2018.concat(results2019) as { username: string }[], 'username')
 }