1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/**
* Add CrowdIn Contributors to AllContributors list
*
* This script will add CrowdIn Contributors to the list of all contributors.
* As the CrowdIn API doesn't give good access to the data needed, this script
* requires you to manually execute a script on the members page of CrowdIn
* and paste its output into this script.
*
* Usage:
* 1. Open https://crowdin.com/project/getferdi/settings#members
* 2. Open the console and execute the script below:
const members = [];
// All elements containing members
const membersEl = [...document.querySelectorAll('.ps-members-name')];
// Remove the first 4 contributors as they are already in the list
for (let i = 0; i < 4; i += 1) {
membersEl.shift();
}
membersEl.forEach((el) => {
const text = el.innerText;
let picture = el.querySelector('img').getAttribute('src');
picture = picture.replace(/\?.+/, '');
// Check if the text includes a seperate username
if (text.includes('(')) {
const username = /(?<=\()\w*(?=\))/.exec(text)[0];
const name = /^.*(?= \()/.exec(text)[0];
if (username) {
members.push({
name: name || username,
login: username,
avatar_url: picture,
});
return;
}
}
members.push({
name: text,
login: text,
avatar_url: picture,
});
});
// Output data to console
console.clear();
console.log(JSON.stringify(members));
* 3. Paste the output of the script (JSON Array) below to set 'list' to that value
* 4. Execute this script using 'node src/scripts/add-crowdin-contributors.js'
* 5. Regenerate the README table using the CLI ('all-contributors generate')
* Please check if the generated data is ok and no data is lost.
*/
const list = [];
const fs = require('fs-extra');
const path = require('path');
const allContributors = require('all-contributors-cli');
const infoPath = path.join(__dirname, '../../.all-contributorsrc');
(async () => {
const info = await fs.readJSON(infoPath);
for (const user of list) {
// eslint-disable-next-line no-await-in-loop
info.contributors = await allContributors.addContributorWithDetails({
...user,
contributions: ['translation'],
profile: `https://crowdin.com/profile/${user.login}`,
options: {
contributors: info.contributors,
},
});
}
fs.writeJSON(infoPath, info, {
spaces: 2,
});
})();
|