mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-01-31 02:50:03 +08:00
build: move changelog building to external file
This commit is contained in:
parent
9f987a613a
commit
c4df72b084
4 changed files with 113 additions and 26 deletions
|
@ -9,7 +9,8 @@
|
|||
},
|
||||
"git": {
|
||||
"commitMessage": "chore: release v${version}",
|
||||
"requireCleanWorkingDir": true
|
||||
"requireCleanWorkingDir": true,
|
||||
"changelog": "node bin/buildChangelog.mjs"
|
||||
},
|
||||
"github": {
|
||||
"release": true
|
||||
|
@ -17,30 +18,5 @@
|
|||
"npm": {
|
||||
"publish": false,
|
||||
"ignoreVersion": true
|
||||
},
|
||||
"plugins": {
|
||||
"@release-it/conventional-changelog": {
|
||||
"preset": {
|
||||
"name": "conventionalcommits",
|
||||
"types": [
|
||||
{
|
||||
"type": "feat",
|
||||
"section": "Features"
|
||||
},
|
||||
{
|
||||
"type": "impr",
|
||||
"section": "Improvements"
|
||||
},
|
||||
{
|
||||
"type": "fix",
|
||||
"section": "Fixes"
|
||||
},
|
||||
{}
|
||||
]
|
||||
},
|
||||
"writerOpts": {
|
||||
"headerPartial": "Thank you to all the contributors!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
109
bin/buildChangelog.mjs
Normal file
109
bin/buildChangelog.mjs
Normal file
|
@ -0,0 +1,109 @@
|
|||
import conventionalChangelog from "conventional-changelog";
|
||||
import { exec } from "child_process";
|
||||
|
||||
const stream = conventionalChangelog(
|
||||
{
|
||||
preset: {
|
||||
name: "conventionalcommits",
|
||||
types: [
|
||||
{ type: "feat", section: "Features" },
|
||||
{ type: "impr", section: "Improvements" },
|
||||
{ type: "fix", section: "Fixes" },
|
||||
],
|
||||
},
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
headerPartial: "",
|
||||
}
|
||||
);
|
||||
|
||||
const header =
|
||||
"Thank you to all the contributors who made this release possible!\n\n---";
|
||||
const footer = `\n### Other\n\nVarious style, documentation, refactoring, performance, or build improvements.`;
|
||||
|
||||
let log = "";
|
||||
for await (const chunk of stream) {
|
||||
log += chunk;
|
||||
}
|
||||
|
||||
log = log.replace(/^\*/gm, "-");
|
||||
|
||||
console.log(header + log + footer);
|
||||
|
||||
//i might come back to the approach below at some point
|
||||
|
||||
async function getLog() {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(
|
||||
`git log --oneline $(git describe --tags --abbrev=0 @^)..@ --pretty="format:%H %h %s"`,
|
||||
(err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
resolve(stdout);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function itemIsAddingQuotes(item) {
|
||||
return (
|
||||
(item.scope?.includes("quote") ||
|
||||
item.scope?.includes("quotes") ||
|
||||
item.message?.includes("quote")) &&
|
||||
(item.message.includes("add") ||
|
||||
item.message.includes("added") ||
|
||||
item.message.includes("adding") ||
|
||||
item.message.includes("adds"))
|
||||
);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
let logString = await getLog();
|
||||
logString = logString.split("\n");
|
||||
|
||||
let log = [];
|
||||
for (let line of logString) {
|
||||
//split line based on the format: d2739e4f193137db4d86450f0d50b3489d75c106 d2739e4f1 style: adjusted testConfig and modesNotice.
|
||||
//use regex to split
|
||||
const [_, hash, shortHash, fullMessage] = line.split(
|
||||
/(\w{40}) (\w{9}) (.*)/
|
||||
);
|
||||
|
||||
//split message using regex based on fix(language): spelling mistakes in Nepali wordlist and quotes (sapradhan) (#4528)
|
||||
//scope is optional, username is optional, pr number is optional
|
||||
const [__, type, scope, message, username, pr] = fullMessage.split(
|
||||
/^([^\s()]+)(?:\(([^\s()]+)\))?:\s(.*?)(?:\(([^\s()]+)\))?(?:\s\((#\d+)\))?$/
|
||||
);
|
||||
|
||||
if (type && message) {
|
||||
log.push({
|
||||
hash,
|
||||
shortHash,
|
||||
type,
|
||||
scope,
|
||||
message,
|
||||
username,
|
||||
pr,
|
||||
});
|
||||
} else {
|
||||
console.warn("skipping line due to invalid format: " + line);
|
||||
}
|
||||
}
|
||||
|
||||
log = log.filter((item) => ["feat", "fix", "impr"].includes(item.type));
|
||||
|
||||
log = log.filter((item) => !itemIsAddingQuotes(item));
|
||||
|
||||
let quoteAddCommits = log.filter((item) => itemIsAddingQuotes(item));
|
||||
|
||||
console.log(quoteAddCommits);
|
||||
|
||||
// console.log(log);
|
||||
}
|
||||
|
||||
// main();
|
1
package-lock.json
generated
1
package-lock.json
generated
|
@ -15,6 +15,7 @@
|
|||
"@typescript-eslint/eslint-plugin": "5.59.11",
|
||||
"@typescript-eslint/parser": "5.59.11",
|
||||
"concurrently": "7.2.1",
|
||||
"conventional-changelog": "4.0.0",
|
||||
"eslint": "8.42.0",
|
||||
"eslint-plugin-json": "2.1.2",
|
||||
"eslint-plugin-require-path-exists": "1.1.9",
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
"@typescript-eslint/eslint-plugin": "5.59.11",
|
||||
"@typescript-eslint/parser": "5.59.11",
|
||||
"concurrently": "7.2.1",
|
||||
"conventional-changelog": "4.0.0",
|
||||
"eslint": "8.42.0",
|
||||
"eslint-plugin-json": "2.1.2",
|
||||
"eslint-plugin-require-path-exists": "1.1.9",
|
||||
|
|
Loading…
Reference in a new issue