refactor(treewide)!: simplify userstyles.yml & remove style previews (#1691)
Co-authored-by: uncenter <[email protected]>
This commit is contained in:
1 parent
b8e16c7524
commit
37fd16969a
265 files changed
+543
-1635
No files matched your search
+35
-14
@@ -16,7 +16,11 @@ const macchiatoHex = flavors.macchiato.colorEntries
|
||||
return acc;
|
||||
}, {} as Record<ColorName, string>);
|
||||
|
||||
const toIssueLabel = (slug: string | number) => `lbl:${slug}`;
|
||||
const toIssueLabel = (key: string) => `lbl:${key}`;
|
||||
|
||||
const toIssueLabelRegex = (key: string) => `/${toIssueLabel(key)}(,.*)?$/gm`;
|
||||
|
||||
const toPrLabel = (key: string) => `styles/${key}/**/*`;
|
||||
|
||||
export async function syncIssueLabels(userstyles: UserstylesSchema.Userstyles) {
|
||||
// .github/issue-labeler.yml
|
||||
@@ -24,8 +28,11 @@ export async function syncIssueLabels(userstyles: UserstylesSchema.Userstyles) {
|
||||
path.join(REPO_ROOT, ".github/issue-labeler.yml"),
|
||||
yaml.stringify(
|
||||
Object.entries(userstyles)
|
||||
.reduce((acc, [key]) => {
|
||||
acc[key.toString()] = [`/${toIssueLabel(key)}(,.*)?$/gm`];
|
||||
.reduce((acc, [key, { supports }]) => {
|
||||
acc[key.toString()] = [toIssueLabelRegex(key)];
|
||||
Object.keys(supports ?? {}).forEach((key) => {
|
||||
acc[key.toString()] = [toIssueLabelRegex(key)];
|
||||
});
|
||||
return acc;
|
||||
}, {} as Record<string, string[]>),
|
||||
),
|
||||
@@ -42,7 +49,12 @@ export async function syncIssueLabels(userstyles: UserstylesSchema.Userstyles) {
|
||||
`"$LABELS"`,
|
||||
`${
|
||||
Object.entries(userstyles)
|
||||
.map(([key]) => `"${toIssueLabel(key)}"`)
|
||||
.flatMap(([slug, { supports }]) =>
|
||||
[slug, ...Object.keys(supports ?? {})].map((key) =>
|
||||
`"${toIssueLabel(key)}"`
|
||||
)
|
||||
)
|
||||
.sort()
|
||||
.join(", ")
|
||||
}`,
|
||||
),
|
||||
@@ -53,8 +65,11 @@ export async function syncIssueLabels(userstyles: UserstylesSchema.Userstyles) {
|
||||
path.join(REPO_ROOT, ".github/pr-labeler.yml"),
|
||||
yaml.stringify(
|
||||
Object.entries(userstyles)
|
||||
.reduce((acc, [key]) => {
|
||||
acc[`${key}`] = `styles/${key}/**/*`;
|
||||
.reduce((acc, [key, { supports }]) => {
|
||||
acc[key] = toPrLabel(key);
|
||||
Object.keys(supports ?? {}).forEach((supportedKey) => {
|
||||
acc[supportedKey] = toPrLabel(key);
|
||||
});
|
||||
return acc;
|
||||
}, {} as Record<string, string>),
|
||||
),
|
||||
@@ -64,14 +79,20 @@ export async function syncIssueLabels(userstyles: UserstylesSchema.Userstyles) {
|
||||
await writeWithPreamble(
|
||||
path.join(REPO_ROOT, ".github/labels.yml"),
|
||||
yaml.stringify(
|
||||
Object.entries(userstyles)
|
||||
.map(([slug, style]) => {
|
||||
return {
|
||||
name: slug,
|
||||
description: [style.name].flat().join(", "),
|
||||
color: style.color ? macchiatoHex[style.color] : macchiatoHex.blue,
|
||||
};
|
||||
}),
|
||||
Object.entries(userstyles).flatMap(([key, style]) => [
|
||||
{
|
||||
name: key,
|
||||
description: style.name,
|
||||
color: style.color ? macchiatoHex[style.color] : macchiatoHex.blue,
|
||||
},
|
||||
...Object.entries(style.supports ?? {}).map((
|
||||
[supportedKey, { name }],
|
||||
) => ({
|
||||
name: supportedKey,
|
||||
description: name,
|
||||
color: style.color ? macchiatoHex[style.color] : macchiatoHex.blue,
|
||||
})),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -19,21 +19,30 @@ export async function generateMainReadme(
|
||||
if (!categoriesData) throw ("Categories data is missing categories");
|
||||
|
||||
const categorized = Object.entries(userstyles)
|
||||
.reduce((acc, [slug, { categories, ...port }]) => {
|
||||
.reduce((acc, [slug, { categories, supports, ...userstyle }]) => {
|
||||
// initialize category array if it doesn't exist
|
||||
// only care about the first (primary) category in the categories array
|
||||
acc[categories[0]] ??= [];
|
||||
|
||||
acc[categories[0]].push({
|
||||
const baseUserstyle = {
|
||||
path: `styles/${slug}`,
|
||||
categories,
|
||||
...port,
|
||||
});
|
||||
...userstyle,
|
||||
};
|
||||
|
||||
// Sort by name, first array entry if necessary
|
||||
acc[categories[0]].sort((a, b) =>
|
||||
[a.name].flat()[0].localeCompare([b.name].flat()[0])
|
||||
acc[categories[0]].push(
|
||||
baseUserstyle,
|
||||
// supported websites themed by the userstyle are added as their own entries for the README
|
||||
...(Object.values(supports ?? {}).map(({ name, link }) => ({
|
||||
...baseUserstyle,
|
||||
name,
|
||||
link,
|
||||
}))),
|
||||
);
|
||||
|
||||
// sort by name
|
||||
acc[categories[0]].sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
return acc;
|
||||
}, {} as MappedPorts);
|
||||
|
||||
@@ -48,11 +57,12 @@ export async function generateMainReadme(
|
||||
<summary>{{emoji}} {{name}}</summary>
|
||||
|
||||
{{#each ports}}
|
||||
- {{#unless maintained}}❤️🩹 {{/unless}}[{{#each name}}{{ this }}{{#unless @last}}, {{/unless}}{{/each}}]({{ path }})
|
||||
- {{#unless maintained}}❤️🩹 {{/unless}}[{{ name }}]({{ path }})
|
||||
{{/each}}
|
||||
|
||||
</details>
|
||||
{{/each}}`)({
|
||||
{{/each}}
|
||||
`)({
|
||||
category: portListData.map(({ meta, ports }) => {
|
||||
return {
|
||||
emoji: meta.emoji,
|
||||
@@ -66,7 +76,7 @@ export async function generateMainReadme(
|
||||
},
|
||||
) => {
|
||||
return {
|
||||
name: [name].flat(),
|
||||
name,
|
||||
maintained: currentMaintainers.length > 0,
|
||||
path,
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@ import { REPO_ROOT } from "@/constants.ts";
|
||||
|
||||
import * as path from "@std/path";
|
||||
import Handlebars from "handlebars";
|
||||
import { formatListOfItems } from "@/utils.ts";
|
||||
|
||||
// we can have some nice things :)
|
||||
Handlebars.registerHelper(
|
||||
@@ -16,19 +17,15 @@ Handlebars.registerHelper(
|
||||
|
||||
const heading = (
|
||||
name: UserstylesSchema.Name,
|
||||
link: UserstylesSchema.ApplicationLink,
|
||||
link: UserstylesSchema.Link,
|
||||
supports: UserstylesSchema.Supports | undefined,
|
||||
) => {
|
||||
const [nameArray, linkArray] = [[name].flat(), [link].flat()];
|
||||
|
||||
if (nameArray.length !== linkArray.length) {
|
||||
throw new Error(
|
||||
'The "name" and "app-link" arrays must have the same length',
|
||||
);
|
||||
}
|
||||
|
||||
return nameArray.map((title, i) => {
|
||||
return { title, url: linkArray[i] };
|
||||
});
|
||||
return [{ title: name, url: link }].concat(
|
||||
Object.values(supports ?? {}).map(({ name, link }) => ({
|
||||
title: name,
|
||||
url: link,
|
||||
})),
|
||||
);
|
||||
};
|
||||
|
||||
function getNameWithGitHubUrl(
|
||||
@@ -60,7 +57,9 @@ export function generateStyleReadmes(userstyles: UserstylesSchema.Userstyles) {
|
||||
slug,
|
||||
{
|
||||
name,
|
||||
readme,
|
||||
link,
|
||||
note,
|
||||
supports,
|
||||
"current-maintainers": currentMaintainers,
|
||||
"past-maintainers": pastMaintainers,
|
||||
},
|
||||
@@ -68,10 +67,14 @@ export function generateStyleReadmes(userstyles: UserstylesSchema.Userstyles) {
|
||||
) => {
|
||||
console.log(`Generating README for styles/${slug}...`);
|
||||
const readmeContent = Handlebars.compile(stylesReadmeContent)({
|
||||
heading: heading(name, readme["app-link"]),
|
||||
heading: heading(name, link, supports),
|
||||
supportedWebsites: formatListOfItems(
|
||||
Object.values(supports ?? {}).map(({ name, link }) =>
|
||||
`[${name}](${link})`
|
||||
),
|
||||
),
|
||||
slug,
|
||||
note: readme.note,
|
||||
faq: readme.faq,
|
||||
note,
|
||||
collaborators: {
|
||||
currentMaintainers: getNameWithGitHubUrl(currentMaintainers),
|
||||
pastMaintainers: getNameWithGitHubUrl(pastMaintainers),
|
||||
|
||||
@@ -13,12 +13,14 @@
|
||||
<a href="https://raw.githubusercontent.com/catppuccin/userstyles/main/styles/{{ slug }}/catppuccin.user.less"><img src="https://img.shields.io/badge/stylus-install-cba6f7?colorA=363a4f&style=for-the-badge"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="preview.webp"/>
|
||||
</p>
|
||||
|
||||
## Usage
|
||||
|
||||
{{#if supportedWebsites}}
|
||||
> [!IMPORTANT]
|
||||
> This userstyle also applies to {{ supportedWebsites }}.
|
||||
|
||||
{{/if~}}
|
||||
|
||||
See [the userstyle usage instructions](../../docs/USAGE.md).
|
||||
|
||||
{{#if note}}
|
||||
@@ -26,14 +28,6 @@ See [the userstyle usage instructions](../../docs/USAGE.md).
|
||||
> {{{ note }}}
|
||||
{{/if}}
|
||||
|
||||
{{#if faq}}
|
||||
## 🙋 FAQ
|
||||
{{#each faq}}
|
||||
- Q: {{{ question }}}\
|
||||
A: {{{ answer }}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
|
||||
{{#if collaborators.currentMaintainers.length}}
|
||||
## 💝 Current {{pluralize collaborators.currentMaintainers 'Maintainer'}}
|
||||
{{#each collaborators.currentMaintainers}}
|
||||
@@ -61,4 +55,4 @@ This userstyle currently lacks maintainers, and may not work correctly. Please f
|
||||
Copyright © 2021-present <a href="https://github.com/catppuccin" target="_blank">Catppuccin Org</a>
|
||||
</p>
|
||||
|
||||
<!-- AUTOGEN:README END -->
|
||||
<!-- AUTOGEN:README END -->
|
||||
Reference in new issue
Block a user