feat(scripts): misc (#1542)

This commit is contained in:
uncenter authored and GitHub committed 2024-12-29 11:03:53 -05:00
1 parent 2c4eefa877
commit d0c973e9c9
10 files changed
+148 -101

No files matched your search

+20 -7
View File
@@ -5,7 +5,12 @@ import { syncIssueLabels } from "@/generate/labels.ts";
import { generateMainReadme } from "@/generate/readme-repo.ts";
import { generateStyleReadmes } from "@/generate/readme-styles.ts";
import { writeWithPreamble } from "@/generate/utils.ts";
import { getPortsData, getUserstylesData } from "@/utils.ts";
import {
getAuthenticatedOctokit,
getPortsData,
getUserstylesData,
getUserstylesTeamMembers,
} from "@/utils.ts";
const userstylesData = getUserstylesData();
const portsData = await getPortsData();
@@ -30,7 +35,7 @@ await syncIssueLabels(userstylesData.userstyles);
/**
* Keep `.github/CODEOWNERS` in sync with the userstyle metadata.
*/
const maintainersCodeOwners = () => {
function maintainersCodeOwners() {
return Object.entries(userstylesData.userstyles!)
.filter(([_, { "current-maintainers": currentMaintainers }]) =>
currentMaintainers.length > 0
@@ -42,14 +47,22 @@ const maintainersCodeOwners = () => {
return `/styles/${slug} ${codeOwners}`;
})
.join("\n");
};
const userstylesStaffCodeOwners = () => {
}
async function userstylesStaffCodeOwners() {
const paths = ["/.github/", "/scripts/", "/template/"];
return paths.map((path) => `${path} @catppuccin/userstyles-staff`).join(
const octokit = getAuthenticatedOctokit();
const staffMembers = await getUserstylesTeamMembers(
octokit,
"userstyles-staff",
);
return paths.map((path) =>
`${path} ${staffMembers.map((member) => "@" + member).join(" ")}`
).join(
"\n",
);
};
}
await writeWithPreamble(
path.join(REPO_ROOT, ".github/CODEOWNERS"),
`${maintainersCodeOwners()}\n\n${userstylesStaffCodeOwners()}`,
`${maintainersCodeOwners()}\n\n${await userstylesStaffCodeOwners()}`,
);
+1 -1
View File
@@ -64,7 +64,7 @@ export function generateStyleReadmes(userstyles: UserstylesSchema.Userstyles) {
},
],
) => {
console.log(`Generating README for ${slug}`);
console.log(`Generating README for styles/${slug}...`);
const readmeContent = Handlebars.compile(stylesReadmeContent)({
heading: heading(name, readme["app-link"]),
slug,
+1 -1
View File
@@ -18,7 +18,7 @@ export function updateReadme({
newContent: string;
}): string {
const preamble =
"<!-- the following section is auto-generated, do not edit -->";
"<!-- The following section is auto-generated, do not edit. -->";
const startMarker = `<!-- AUTOGEN:${section.toUpperCase()} START -->`;
const endMarker = `<!-- AUTOGEN:${section.toUpperCase()} END -->`;
const wrapped = `${startMarker}\n${preamble}\n${newContent}\n${endMarker}`;