diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-22 17:06:32 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-22 17:08:44 +0200 |
commit | 92d83c6a78e86c66a55958f8e36a7f2e123efdf8 (patch) | |
tree | e03e146ec133b84a4891648f4d77dc552fa0b023 /scripts | |
parent | cd080b1a6b17727633cb42bd18d39eb3f7a9e030 (diff) | |
download | PeerTube-92d83c6a78e86c66a55958f8e36a7f2e123efdf8.tar.gz PeerTube-92d83c6a78e86c66a55958f8e36a7f2e123efdf8.tar.zst PeerTube-92d83c6a78e86c66a55958f8e36a7f2e123efdf8.zip |
Fix git credits
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/generate-code-contributors.sh | 27 | ||||
-rwxr-xr-x | scripts/generate-code-contributors.ts | 80 | ||||
-rwxr-xr-x | scripts/prune-storage.ts | 2 |
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 | |||
3 | set -eu | ||
4 | |||
5 | echo -e "# Code\n" | ||
6 | |||
7 | curl -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 | |||
13 | echo -e "\n\n# Translations\n" | ||
14 | |||
15 | curl -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 | |||
24 | echo -e "\n\n# Design\n" | ||
25 | |||
26 | echo -e "By [Olivier Massain](https://twitter.com/omassain)\n" | ||
27 | 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 @@ | |||
1 | import { doRequest } from '../server/helpers/requests' | ||
2 | import { readFileSync } from 'fs' | ||
3 | |||
4 | run() | ||
5 | .then(() => process.exit(0)) | ||
6 | .catch(err => { | ||
7 | console.error(err) | ||
8 | process.exit(-1) | ||
9 | }) | ||
10 | |||
11 | async 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 | |||
43 | function 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 | |||
53 | async 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 | |||
71 | async 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 @@ | |||
1 | import * as prompt from 'prompt' | 1 | import * as prompt from 'prompt' |
2 | import { createReadStream } from 'fs' | ||
3 | import { join } from 'path' | 2 | import { join } from 'path' |
4 | import { createInterface } from 'readline' | ||
5 | import { readdirPromise, unlinkPromise } from '../server/helpers/core-utils' | 3 | import { readdirPromise, unlinkPromise } from '../server/helpers/core-utils' |
6 | import { CONFIG } from '../server/initializers/constants' | 4 | import { CONFIG } from '../server/initializers/constants' |
7 | import { VideoModel } from '../server/models/video/video' | 5 | import { VideoModel } from '../server/models/video/video' |