diff options
author | 2020-04-17 20:50:37 +0200 | |
---|---|---|
committer | 2020-04-17 19:50:37 +0100 | |
commit | 0927dcbf4a8338150c61f91079a42a2ef96ec4ef (patch) | |
tree | e836a02110cd076c32b5e3eedfbe912f0d5f4c1e /src | |
parent | New Crowdin translations (#586) (diff) | |
download | ferdium-app-0927dcbf4a8338150c61f91079a42a2ef96ec4ef.tar.gz ferdium-app-0927dcbf4a8338150c61f91079a42a2ef96ec4ef.tar.zst ferdium-app-0927dcbf4a8338150c61f91079a42a2ef96ec4ef.zip |
Add 5.5.0-gm and 5.5.0 changelog (#574)
* Update README and CHANGELOG
* Add script to automatically link issues inside README.md
* Add #573 to README
* Add documentation for regex used in link-readme-issues script
* Fix linking for Franz issues
* Add linking for GitHub users
* Link more contributors
* Link more contributors
* Fix information about "npm run link-readme" command
* Add recipes to changelog
* Add 5.5.0 changelog
Diffstat (limited to 'src')
-rw-r--r-- | src/scripts/link-readme.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/scripts/link-readme.js b/src/scripts/link-readme.js new file mode 100644 index 000000000..223451d84 --- /dev/null +++ b/src/scripts/link-readme.js | |||
@@ -0,0 +1,53 @@ | |||
1 | /** | ||
2 | * Script that automatically creates links to issues and users inside README.md | ||
3 | * | ||
4 | * e.g. "#123" => "[#123](https://github.com/getferdi/ferdi/issues/123)" | ||
5 | * and "franz/#123" => "[franz#123](https://github.com/meetfranz/franz/issues/123)" | ||
6 | * and "@abc" => "[@abc](https://github.com/abc)" | ||
7 | */ | ||
8 | |||
9 | const fs = require('fs-extra'); | ||
10 | const path = require('path'); | ||
11 | |||
12 | console.log('Linking issues and PRs in README.md'); | ||
13 | |||
14 | const readmepath = path.join(__dirname, '../../', 'README.md'); | ||
15 | |||
16 | // Read README.md | ||
17 | let readme = fs.readFileSync(readmepath, 'utf-8'); | ||
18 | |||
19 | let replacements = 0; | ||
20 | |||
21 | // Replace Ferdi issues | ||
22 | // Regex matches strings that don't begin with a "[", i.e. are not already linked and | ||
23 | // don't begin with "franz", i.e. are not Franz issues, followed by a "#" and 3 digits to indicate | ||
24 | // a GitHub issue, and not ending with a "]" | ||
25 | readme = readme.replace(/(?<!\[|franz)#\d{3}(?!\])/gi, (match) => { | ||
26 | const issueNr = match.replace('#', ''); | ||
27 | replacements += 1; | ||
28 | return `[#${issueNr}](https://github.com/getferdi/ferdi/issues/${issueNr})`; | ||
29 | }); | ||
30 | |||
31 | // Replace Franz issues | ||
32 | // Regex matches strings that don't begin with a "[", i.e. are not already linked | ||
33 | // followed by a "franz#" and 3 digits to indicate | ||
34 | // a GitHub issue, and not ending with a "]" | ||
35 | readme = readme.replace(/(?<!\[)franz#\d{3,}(?!\])/gi, (match) => { | ||
36 | const issueNr = match.replace('franz#', ''); | ||
37 | replacements += 1; | ||
38 | return `[franz#${issueNr}](https://github.com/meetfranz/franz/issues/${issueNr})`; | ||
39 | }); | ||
40 | |||
41 | // Link GitHub users | ||
42 | // Regex matches strings that don't begin with a "[", i.e. are not already linked | ||
43 | // followed by a "@" and at least one word character and not ending with a "]" | ||
44 | readme = readme.replace(/(?<!\[)@\w+(?!\])/gi, (match) => { | ||
45 | const username = match.replace('@', ''); | ||
46 | replacements += 1; | ||
47 | return `[@${username}](https://github.com/${username})`; | ||
48 | }); | ||
49 | |||
50 | // Write to file | ||
51 | fs.writeFileSync(readmepath, readme); | ||
52 | |||
53 | console.log(`Added ${replacements} strings`); | ||