diff options
author | 2021-08-21 09:03:32 +0530 | |
---|---|---|
committer | 2021-08-21 09:16:59 +0530 | |
commit | 16d8de38b74c298fda27c22c804850a999183d57 (patch) | |
tree | 6c869677e3bb8472f5b86c92908bb256ec0c5be5 /src/scripts/add-crowdin-contributors.js | |
parent | chore: typescript conversion (diff) | |
download | ferdium-app-16d8de38b74c298fda27c22c804850a999183d57.tar.gz ferdium-app-16d8de38b74c298fda27c22c804850a999183d57.tar.zst ferdium-app-16d8de38b74c298fda27c22c804850a999183d57.zip |
chore: move build-time js files out of 'src' and into 'scripts'
so that they not packaged into final deployable artefact
Diffstat (limited to 'src/scripts/add-crowdin-contributors.js')
-rw-r--r-- | src/scripts/add-crowdin-contributors.js | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/src/scripts/add-crowdin-contributors.js b/src/scripts/add-crowdin-contributors.js deleted file mode 100644 index ed29a0daf..000000000 --- a/src/scripts/add-crowdin-contributors.js +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
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 separate 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 | })(); | ||