diff options
author | Bennett <hello@vantezzen.io> | 2020-03-03 10:57:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-03 10:57:59 +0100 |
commit | ddcea1d11cb46c114e3a8833a7c1874bc3dd1c7d (patch) | |
tree | b64bcf1a58501c8cfcf3eaf84edb7f5314df10f1 /src/scripts | |
parent | Improve installation guide (#431) (diff) | |
download | ferdium-app-ddcea1d11cb46c114e3a8833a7c1874bc3dd1c7d.tar.gz ferdium-app-ddcea1d11cb46c114e3a8833a7c1874bc3dd1c7d.tar.zst ferdium-app-ddcea1d11cb46c114e3a8833a7c1874bc3dd1c7d.zip |
Add Crowdin contributors to list of contributors (#429)
* Enhance installation guide in README
* Add CrowdIn Contributors to the list
* Create script to add CrowdIn contributors
* Fix lint
* Fix ESLint error
* Revert change of contributors per line
* Revert change in badge template
* Update All-contributors badge
* Remove unrelated changes
Diffstat (limited to 'src/scripts')
-rw-r--r-- | src/scripts/add-crowdin-contributors.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/scripts/add-crowdin-contributors.js b/src/scripts/add-crowdin-contributors.js new file mode 100644 index 000000000..7ad3df0ed --- /dev/null +++ b/src/scripts/add-crowdin-contributors.js | |||
@@ -0,0 +1,81 @@ | |||
1 | /** | ||
2 | * Add CrowdIn Contributors to AllContributors list | ||
3 | * | ||
4 | * This script will add CrowdIn Contributors to the list of all contributors. | ||
5 | * As the CrowdIn API doesn't give good access to the data needed, this script | ||
6 | * requires you to manually execute a script on the members page of CrowdIn | ||
7 | * and paste its output into this script. | ||
8 | * | ||
9 | * Usage: | ||
10 | * 1. Open https://crowdin.com/project/getferdi/settings#members | ||
11 | * 2. Open the console and execute the script below: | ||
12 | |||
13 | const members = []; | ||
14 | // All elements containing members | ||
15 | const membersEl = [...document.querySelectorAll('.ps-members-name')]; | ||
16 | // Remove the first 4 contributors as they are already in the list | ||
17 | for (let i = 0; i < 4; i += 1) { | ||
18 | membersEl.shift(); | ||
19 | } | ||
20 | membersEl.forEach((el) => { | ||
21 | const text = el.innerText; | ||
22 | let picture = el.querySelector('img').getAttribute('src'); | ||
23 | picture = picture.replace(/\?.+/, ''); | ||
24 | |||
25 | // Check if the text includes a seperate username | ||
26 | if (text.includes('(')) { | ||
27 | const username = /(?<=\()\w*(?=\))/.exec(text)[0]; | ||
28 | const name = /^.*(?= \()/.exec(text)[0]; | ||
29 | |||
30 | if (username) { | ||
31 | members.push({ | ||
32 | name: name || username, | ||
33 | login: username, | ||
34 | avatar_url: picture, | ||
35 | }); | ||
36 | return; | ||
37 | } | ||
38 | } | ||
39 | members.push({ | ||
40 | name: text, | ||
41 | login: text, | ||
42 | avatar_url: picture, | ||
43 | }); | ||
44 | }); | ||
45 | |||
46 | // Output data to console | ||
47 | console.clear(); | ||
48 | console.log(JSON.stringify(members)); | ||
49 | |||
50 | * 3. Paste the output of the script (JSON Array) below to set 'list' to that value | ||
51 | * 4. Execute this script using 'node src/scripts/add-crowdin-contributors.js' | ||
52 | * 5. Regenerate the README table using the CLI ('all-contributors generate') | ||
53 | * Please check if the generated data is ok and no data is lost. | ||
54 | */ | ||
55 | const list = []; | ||
56 | |||
57 | const fs = require('fs-extra'); | ||
58 | const path = require('path'); | ||
59 | const allContributors = require('all-contributors-cli'); | ||
60 | |||
61 | const infoPath = path.join(__dirname, '../../.all-contributorsrc'); | ||
62 | |||
63 | (async () => { | ||
64 | const info = await fs.readJSON(infoPath); | ||
65 | |||
66 | for (const user of list) { | ||
67 | // eslint-disable-next-line no-await-in-loop | ||
68 | info.contributors = await allContributors.addContributorWithDetails({ | ||
69 | ...user, | ||
70 | contributions: ['translation'], | ||
71 | profile: `https://crowdin.com/profile/${user.login}`, | ||
72 | options: { | ||
73 | contributors: info.contributors, | ||
74 | }, | ||
75 | }); | ||
76 | } | ||
77 | |||
78 | fs.writeJSON(infoPath, info, { | ||
79 | spaces: 2, | ||
80 | }); | ||
81 | })(); | ||