Update changelog related scripts (#19226)

This commit is contained in:
fisker Cheung authored and GitHub committed 2026-05-28 01:26:59 +08:00
1 parent 3672a239ba
commit cf07f287e5
6 files changed
+33 -54

No files matched your search

+14 -9
View File
@@ -7,8 +7,7 @@ import fg from "fast-glob";
import semver from "semver";
import {
categories,
changelogUnreleasedDirPath,
changelogUnreleasedDirs,
changelogUnreleasedDirectory,
getEntries,
printEntries,
replaceVersions,
@@ -16,11 +15,11 @@ import {
const { __dirname, require } = createEsmUtils(import.meta);
const blogDir = path.join(__dirname, "../website/blog");
const introTemplateFile = path.join(
changelogUnreleasedDirPath,
const introTemplateFile = new URL(
"BLOG_POST_INTRO_TEMPLATE.md",
changelogUnreleasedDirectory,
);
const introFile = path.join(changelogUnreleasedDirPath, "blog-post-intro.md");
const introFile = new URL("blog-post-intro.md", changelogUnreleasedDirectory);
if (!fs.existsSync(introFile)) {
fs.copyFileSync(introTemplateFile, introFile);
}
@@ -41,12 +40,18 @@ const categoriesByDir = new Map(
categories.map((category) => [category.dir, category]),
);
for (const dir of changelogUnreleasedDirs) {
const dirPath = path.join(changelogUnreleasedDirPath, dir.name);
const category = categoriesByDir.get(dir.name);
for (const entry of fs.readdirSync(changelogUnreleasedDirectory, {
withFileTypes: true,
})) {
if (!entry.isDirectory()) {
continue;
}
const dirPath = path.join(entry.path, entry.name);
const category = categoriesByDir.get(entry.name);
if (!category) {
throw new Error("Unknown category: " + dir.name);
throw new Error("Unknown category: " + entry.name);
}
category.entries = getEntries(dirPath, { useFriendlyHeadingId: true });