Fix git credits 707/head
authorChocobozzz <me@florianbigard.com>
Fri, 22 Jun 2018 15:06:32 +0000 (17:06 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 22 Jun 2018 15:08:44 +0000 (17:08 +0200)
CREDITS.md
scripts/generate-code-contributors.sh [deleted file]
scripts/generate-code-contributors.ts [new file with mode: 0755]
scripts/prune-storage.ts

index f8006fc17aa6876a8d4aa74ec1377b0e43841cb4..f1dd95a6cbbee0cc15a364ad647922ed56f61bbe 100644 (file)
  * [sticmac](https://github.com/sticmac)
  * [luzpaz](https://github.com/luzpaz)
  * [qsypoq](https://github.com/qsypoq)
+ * [noplanman](https://github.com/noplanman)
+ * [Nautigsam](https://github.com/Nautigsam)
+ * [benabbottnz](https://github.com/benabbottnz)
+ * [ewft](https://github.com/ewft)
+ * [WildYorkies](https://github.com/WildYorkies)
+ * [Ealhad](https://github.com/Ealhad)
+ * [DatBewar](https://github.com/DatBewar)
+ * [ReK2Fernandez](https://github.com/ReK2Fernandez)
+ * [jlebras](https://github.com/jlebras)
+ * [alcalyn](https://github.com/alcalyn)
+ * [mkody](https://github.com/mkody)
+ * [lucas-dclrcq](https://github.com/lucas-dclrcq)
+ * [zapashcanon](https://github.com/zapashcanon)
+ * [1000i100](https://github.com/1000i100)
+ * [zeograd](https://github.com/zeograd)
+ * [sesn](https://github.com/sesn)
+ * [ALSai](https://github.com/ALSai)
+ * [sschueller](https://github.com/sschueller)
+ * [TrashMacNugget](https://github.com/TrashMacNugget)
+ * [FrozenDroid](https://github.com/FrozenDroid)
+ * [anmol26s](https://github.com/anmol26s)
+ * [AugierLe42e](https://github.com/AugierLe42e)
+ * [ctlaltdefeat](https://github.com/ctlaltdefeat)
+ * [jomo](https://github.com/jomo)
+ * [memoryboxes](https://github.com/memoryboxes)
+ * [norrist](https://github.com/norrist)
+ * [SansPseudoFix](https://github.com/SansPseudoFix)
+ * [tuxayo](https://github.com/tuxayo)
+ * [victor-long](https://github.com/victor-long)
+ * [ewasion](https://github.com/ewasion)
 
 
 # Translations
diff --git a/scripts/generate-code-contributors.sh b/scripts/generate-code-contributors.sh
deleted file mode 100755 (executable)
index 46bf862..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-set -eu
-
-echo -e "# Code\n"
-
-curl -s https://api.github.com/repos/chocobozzz/peertube/contributors | \
-  jq -r 'map(" * [" + .login + "](" + .url + ")") | .[]' | \
-  sed 's/api.github.com\/users/github.com/g'
-
-###################################################
-
-echo -e "\n\n# Translations\n"
-
-curl -s \
-    -H "Accept: application/json" \
-    -H "X-Auth-User: $(grep trad.framasoft.org.username ~/.config/zanata.ini | sed 's@.*=@@')" \
-    -H "X-Auth-Token: $(grep trad.framasoft.org.key ~/.config/zanata.ini | sed 's@.*=@@')" \
-    "https://trad.framasoft.org/zanata/rest/project/peertube/version/develop/contributors/2018-01-01..$(date +%Y-%m-%d)" \
-    | jq -r 'map(" * [" + .username + "](https://trad.framasoft.org/zanata/profile/view/" + .username + ")") | .[]'
-
-###################################################
-
-echo -e "\n\n# Design\n"
-
-echo -e "By [Olivier Massain](https://twitter.com/omassain)\n"
-echo -e "Icons from [Robbie Pearce](https://robbiepearce.com/softies/)"
\ No newline at end of file
diff --git a/scripts/generate-code-contributors.ts b/scripts/generate-code-contributors.ts
new file mode 100755 (executable)
index 0000000..0cce621
--- /dev/null
@@ -0,0 +1,80 @@
+import { doRequest } from '../server/helpers/requests'
+import { readFileSync } from 'fs'
+
+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({
+    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 url = `https://trad.framasoft.org/zanata/rest/project/peertube/version/develop/contributors/2018-01-01..${today}`
+
+  const headers = {
+    'X-Auth-User': zanataUsername,
+    'X-Auth-Token': zanataPassword
+  }
+  return get(url, headers)
+}
index 1973725c86ebda92de21a3b14f966fa18d63d5a5..bc59da6afb383d124ca6e5913274d2d51d2d64b4 100755 (executable)
@@ -1,7 +1,5 @@
 import * as prompt from 'prompt'
-import { createReadStream } from 'fs'
 import { join } from 'path'
-import { createInterface } from 'readline'
 import { readdirPromise, unlinkPromise } from '../server/helpers/core-utils'
 import { CONFIG } from '../server/initializers/constants'
 import { VideoModel } from '../server/models/video/video'