Skip to content

Commit

Permalink
refactor: hoist current/past maintainers up
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoudham committed Apr 12, 2024
1 parent b1a248d commit 0765dc9
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 133 deletions.
8 changes: 4 additions & 4 deletions scripts/generate/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ await syncIssueLabels(userstylesData.userstyles);
await updateFile(
join(REPO_ROOT, ".github/CODEOWNERS"),
Object.entries(userstylesData.userstyles)
.filter(([_, { readme }]) => readme["current-maintainers"].length > 0)
.map(([slug, { readme }]) => {
const currentMaintainers = readme["current-maintainers"]
.filter(([_, { "current-maintainers": currentMaintainers }]) => currentMaintainers.length > 0)
.map(([slug, { "current-maintainers": currentMaintainers }]) => {
const codeOwners = currentMaintainers
.map((maintainer) => `@${maintainer.url.split("/").pop()}`)
.join(" ");
return `/styles/${slug} ${currentMaintainers}`;
return `/styles/${slug} ${codeOwners}`;
})
.join("\n"),
);
4 changes: 2 additions & 2 deletions scripts/generate/readme-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export const generateMainReadme = async (
return {
emoji: meta.emoji,
name: meta.name,
ports: ports.map(({ name, path, readme }) => {
ports: ports.map(({ name, path, "current-maintainers": currentMaintainers }) => {
return {
name: [name].flat(),
maintained: readme["current-maintainers"].length > 0,
maintained: currentMaintainers.length > 0,
path,
};
}),
Expand Down
6 changes: 3 additions & 3 deletions scripts/generate/readme-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ export const generateStyleReadmes = (
);
const stylesReadmeContent = Deno.readTextFileSync(stylesReadmePath);

Object.entries(userstyles).map(([slug, { name, readme }]) => {
Object.entries(userstyles).map(([slug, { name, readme, "current-maintainers": currentMaintainers, "past-maintainers": pastMaintainers }]) => {
console.log(`Generating README for ${slug}`);
const readmeContent = Handlebars.compile(stylesReadmeContent)({
heading: heading(name, readme["app-link"]),
slug,
usage: readme.usage,
faq: readme.faq,
collaborators: {
currentMaintainers: extractName(readme["current-maintainers"]),
pastMaintainers: extractName(readme["past-maintainers"]),
currentMaintainers: extractName(currentMaintainers),
pastMaintainers: extractName(pastMaintainers),
},
});
Deno.writeTextFile(
Expand Down
6 changes: 3 additions & 3 deletions scripts/types/userstyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export type CurrentMaintainers = {
[k: string]: unknown;
}[];
/**
* List of all maintainers that have maintained on this userstyle in the past.
* List of all users that have maintained this userstyle in the past.
*
* @minItems 1
*/
Expand Down Expand Up @@ -176,6 +176,8 @@ export interface Userstyle {
color: Color;
icon?: Icon;
readme: README;
"current-maintainers": CurrentMaintainers;
"past-maintainers"?: PastMaintainers;
}
/**
* Options to help in the auto-generation of the userstyle README.
Expand All @@ -184,7 +186,5 @@ export interface README {
"app-link": ApplicationLink;
usage?: Usage;
faq?: FAQ;
"current-maintainers": CurrentMaintainers;
"past-maintainers"?: PastMaintainers;
[k: string]: unknown;
}
36 changes: 18 additions & 18 deletions scripts/userstyles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "object",
"description": "The directory of the userstyle.",
"examples": ["youtube"],
"required": ["name", "categories", "readme", "color"],
"required": ["name", "categories", "readme", "color", "current-maintainers"],
"additionalProperties": false,
"properties": {
"name": {
Expand Down Expand Up @@ -79,7 +79,7 @@
"title": "README",
"description": "Options to help in the auto-generation of the userstyle README.",
"type": "object",
"required": ["app-link", "current-maintainers"],
"required": ["app-link"],
"properties": {
"app-link": {
"$id": "#userstyles/userstyle/readme/app-link",
Expand Down Expand Up @@ -130,23 +130,23 @@
},
"required": ["question", "answer"]
}
},
"current-maintainers": {
"$id": "#userstyles/userstyle/readme/current-maintainers",
"title": "Current Maintainers",
"description": "List of all active maintainers for this userstyle.",
"type": "array",
"$ref": "#/$defs/collaborators"
},
"past-maintainers": {
"$id": "#userstyles/userstyle/readme/past-maintainers",
"title": "Past Maintainers",
"type":"array",
"minItems": 1,
"description": "List of all maintainers that have maintained on this userstyle in the past.",
"$ref": "#/$defs/collaborators"
}
}
},
"current-maintainers": {
"$id": "#userstyles/userstyle/current-maintainers",
"title": "Current Maintainers",
"description": "List of all active maintainers for this userstyle.",
"type": "array",
"$ref": "#/$defs/collaborators"
},
"past-maintainers": {
"$id": "#userstyles/userstyle/past-maintainers",
"title": "Past Maintainers",
"type": "array",
"minItems": 1,
"description": "List of all users that have maintained this userstyle in the past.",
"$ref": "#/$defs/collaborators"
}
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@
"required": ["url"]
}
},
"categories": {
"categories": {
"$id": "#categories",
"type": "array",
"minItems": 1,
Expand Down
Loading

0 comments on commit 0765dc9

Please sign in to comment.