From 92d83c6a78e86c66a55958f8e36a7f2e123efdf8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 22 Jun 2018 17:06:32 +0200 Subject: [PATCH] Fix git credits --- CREDITS.md | 30 ++++++++++ scripts/generate-code-contributors.sh | 27 --------- scripts/generate-code-contributors.ts | 80 +++++++++++++++++++++++++++ scripts/prune-storage.ts | 2 - 4 files changed, 110 insertions(+), 29 deletions(-) delete mode 100755 scripts/generate-code-contributors.sh create mode 100755 scripts/generate-code-contributors.ts diff --git a/CREDITS.md b/CREDITS.md index f8006fc17..f1dd95a6c 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -30,6 +30,36 @@ * [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 index 46bf86234..000000000 --- a/scripts/generate-code-contributors.sh +++ /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 index 000000000..0cce62180 --- /dev/null +++ b/scripts/generate-code-contributors.ts @@ -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) +} diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index 1973725c8..bc59da6af 100755 --- a/scripts/prune-storage.ts +++ b/scripts/prune-storage.ts @@ -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' -- 2.25.1