aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate-code-contributors.sh27
-rwxr-xr-xscripts/generate-code-contributors.ts80
-rwxr-xr-xscripts/prune-storage.ts2
3 files changed, 80 insertions, 29 deletions
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 @@
1#!/bin/sh
2
3set -eu
4
5echo -e "# Code\n"
6
7curl -s https://api.github.com/repos/chocobozzz/peertube/contributors | \
8 jq -r 'map(" * [" + .login + "](" + .url + ")") | .[]' | \
9 sed 's/api.github.com\/users/github.com/g'
10
11###################################################
12
13echo -e "\n\n# Translations\n"
14
15curl -s \
16 -H "Accept: application/json" \
17 -H "X-Auth-User: $(grep trad.framasoft.org.username ~/.config/zanata.ini | sed 's@.*=@@')" \
18 -H "X-Auth-Token: $(grep trad.framasoft.org.key ~/.config/zanata.ini | sed 's@.*=@@')" \
19 "https://trad.framasoft.org/zanata/rest/project/peertube/version/develop/contributors/2018-01-01..$(date +%Y-%m-%d)" \
20 | jq -r 'map(" * [" + .username + "](https://trad.framasoft.org/zanata/profile/view/" + .username + ")") | .[]'
21
22###################################################
23
24echo -e "\n\n# Design\n"
25
26echo -e "By [Olivier Massain](https://twitter.com/omassain)\n"
27echo -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 @@
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}
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 @@
1import * as prompt from 'prompt' 1import * as prompt from 'prompt'
2import { createReadStream } from 'fs'
3import { join } from 'path' 2import { join } from 'path'
4import { createInterface } from 'readline'
5import { readdirPromise, unlinkPromise } from '../server/helpers/core-utils' 3import { readdirPromise, unlinkPromise } from '../server/helpers/core-utils'
6import { CONFIG } from '../server/initializers/constants' 4import { CONFIG } from '../server/initializers/constants'
7import { VideoModel } from '../server/models/video/video' 5import { VideoModel } from '../server/models/video/video'