summaryrefslogtreecommitdiffstats
path: root/extra/reformat-changelog.js
blob: 80a1b725afbd687215648e78e9f25fa89759a4da (plain)
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
// Generate on GitHub
const input = `
* Add Korean translation by @Alanimdeo in https://github.com/louislam/dockge/pull/86
`;

const template = `
### 🆕 New Features

### 💇‍♀️ Improvements

### 🐞 Bug Fixes

### ⬆️ Security Fixes

### 🦎 Translation Contributions

### Others
- Other small changes, code refactoring and comment/doc updates in this repo:
`;

const lines = input.split("\n").filter((line) => line.trim() !== "");

for (const line of lines) {
    // Split the last " by "
    const usernamePullRequesURL = line.split(" by ").pop();

    if (!usernamePullRequesURL) {
        console.log("Unable to parse", line);
        continue;
    }

    const [ username, pullRequestURL ] = usernamePullRequesURL.split(" in ");
    const pullRequestID = "#" + pullRequestURL.split("/").pop();
    let message = line.split(" by ").shift();

    if (!message) {
        console.log("Unable to parse", line);
        continue;
    }

    message = message.split("* ").pop();
    console.log("-", pullRequestID, message, `(Thanks ${username})`);
}
console.log(template);