dockge/extra/reformat-changelog.ts

57 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2023-11-21 12:44:27 +00:00
// Generate on GitHub
const input = `
* Add Korean translation by @Alanimdeo in https://github.com/louislam/dockge/pull/86
`;
const template = `
2023-12-10 13:20:08 +00:00
> [!WARNING]
>
2023-11-21 12:44:27 +00:00
### 🆕 New Features
2023-12-10 13:20:08 +00:00
### Improvements
2023-11-21 12:44:27 +00:00
2023-12-10 13:20:08 +00:00
### 🐛 Bug Fixes
2023-11-21 12:44:27 +00:00
### 🦎 Translation Contributions
2023-12-10 13:20:08 +00:00
### Security Fixes
2023-11-21 12:44:27 +00:00
### Others
- Other small changes, code refactoring and comment/doc updates in this repo:
2023-12-10 13:20:08 +00:00
Please let me know if your username is missing, if your pull request has been merged in this version, or your commit has been included in one of the pull requests.
2023-11-21 12:44:27 +00:00
`;
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();
2023-12-10 13:20:08 +00:00
let thanks = "";
if (username != "@louislam") {
thanks = `(Thanks ${username})`;
}
console.log(pullRequestID, message, thanks);
2023-11-21 12:44:27 +00:00
}
console.log(template);