ci: move src/ -> scripts/, deno.json to repo root (#332)

This commit is contained in:
winston authored and GitHub committed 2023-11-18 07:18:08 +01:00
1 parent f977c5a64c
commit 790e7cb83c
21 files changed
+21 -26

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import schema from "./userstyles.schema.json" assert { type: "json" };
import portsSchema from "catppuccin-repo/resources/ports.schema.json" assert {
type: "json",
};
import { join } from "std/path/mod.ts";
const ROOT = new URL(".", import.meta.url).pathname;
/** absolute path to the repository */
export const REPO_ROOT = join(ROOT, "..");
export { portsSchema, schema };
+287
View File
@@ -0,0 +1,287 @@
#!/usr/bin/env -S deno run --allow-env --allow-read --allow-write --allow-net
import * as path from "std/path/mod.ts";
import { parse as parseYaml } from "std/yaml/mod.ts";
import Ajv from "ajv";
import { portsSchema, REPO_ROOT, schema } from "@/deps.ts";
import {
ApplicationLink,
CurrentMaintainers,
FAQ,
Name,
PastMaintainers,
PortCategories,
Usage,
Userstyle,
Userstyles,
} from "@/types.d.ts";
const ROOT = new URL(".", import.meta.url).pathname;
const ISSUE_PREFIX = "lbl:";
type Metadata = {
userstyles: Userstyles;
};
type PortMetadata = {
categories: PortCategories;
};
type CollaboratorsData = {
collaborators: CurrentMaintainers | PastMaintainers | undefined;
heading: string;
};
export type MappedPort = Userstyle & { path: string };
const ajv = new (Ajv as unknown as (typeof Ajv)["default"])();
const validate = ajv.compile<Metadata>(schema);
const validatePorts = ajv.compile<PortMetadata>(portsSchema);
const userstylesYaml = Deno.readTextFileSync(
path.join(REPO_ROOT, "scripts/userstyles.yml"),
);
const userstylesData = parseYaml(userstylesYaml);
if (!validate(userstylesData)) {
console.log(validate.errors);
Deno.exit(1);
}
const portsYaml = await fetch(
"https://raw.githubusercontent.com/catppuccin/catppuccin/main/resources/ports.yml",
);
const portsData = parseYaml(await portsYaml.text());
if (!validatePorts(portsData)) {
console.log(validate.errors);
Deno.exit(1);
}
const categorized = Object.entries(userstylesData.userstyles).reduce(
(acc, [slug, { category, ...port }]) => {
acc[category] ??= [];
acc[category].push({ path: `styles/${slug}`, category, ...port });
acc[category].sort((a, b) => {
const aName = typeof a.name === "string" ? a.name : a.name.join(", ");
const bName = typeof b.name === "string" ? b.name : b.name.join(", ");
return aName.localeCompare(bName);
});
return acc;
},
{} as Record<string, MappedPort[]>,
);
const portListData = portsData.categories
.filter((category) => categorized[category.key] !== undefined)
.map((category) => {
return {
meta: category,
ports: categorized[category.key],
};
});
const portContent = portListData
.map(
(data) =>
`<details open>
<summary>${data.meta.emoji} ${data.meta.name}</summary>
${
data.ports
.map((port) => {
const name = Array.isArray(port.name)
? port.name.join(", ")
: port.name;
return `- [${name}](${port.path})`;
})
.join("\n")
}
</details>`,
)
.join("\n");
const updateReadme = ({
readme,
section,
newContent,
}: {
readme: string;
section: string;
newContent: string;
}): string => {
const preamble =
"<!-- 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}`;
if (
!(readmeContent.includes(startMarker) && readmeContent.includes(endMarker))
) {
throw new Error("Markers not found in README.md");
}
const pre = readme.split(startMarker)[0];
const end = readme.split(endMarker)[1];
return pre + wrapped + end;
};
const updateFile = (filePath: string, fileContent: string, comment = true) => {
const preamble = comment
? "# THIS FILE IS AUTOGENERATED. DO NOT EDIT IT BY HAND.\n"
: "";
Deno.writeTextFileSync(filePath, preamble + fileContent);
};
const readmePath = path.join(REPO_ROOT, "README.md");
let readmeContent = Deno.readTextFileSync(readmePath);
try {
readmeContent = updateReadme({
readme: readmeContent,
section: "userstyles",
newContent: portContent,
});
updateFile(readmePath, readmeContent, false);
} catch (e) {
console.log("Failed to update the README:", e);
}
const pullRequestLabelerPath = path.join(REPO_ROOT, ".github/pr-labeler.yml");
const pullRequestLabelerContent = Object.entries(userstylesData.userstyles)
.map(([key]) => `${key}: styles/${key}/**/*`)
.join("\n");
updateFile(pullRequestLabelerPath, pullRequestLabelerContent);
const syncLabels = path.join(REPO_ROOT, ".github/labels.yml");
const syncLabelsContent = Object.entries(userstylesData.userstyles)
.map(
([key, style]) =>
`- name: ${key}
description: ${style.name}
color: "#8aadf4"`,
)
.join("\n");
updateFile(syncLabels, syncLabelsContent);
const issuesLabelerPath = path.join(REPO_ROOT, ".github/issue-labeler.yml");
const issuesLabelerContent = Object.entries(userstylesData.userstyles)
.map(([key]) => `${key}: ['(${ISSUE_PREFIX + key})']`)
.join("\n");
updateFile(issuesLabelerPath, issuesLabelerContent);
const ownersPath = path.join(REPO_ROOT, ".github/CODEOWNERS");
const ownersContent = Object.entries(userstylesData.userstyles)
.map(([key, style]) => {
const currentMaintainers = style.readme["current-maintainers"]
.map((maintainer) => `@${maintainer.url.split("/").pop()}`)
.join(" ");
return `/styles/${key} ${currentMaintainers}`;
})
.join("\n");
updateFile(ownersPath, ownersContent);
const userstyleIssuePath = path.join(ROOT, "templates/userstyle-issue.yml");
const userstyleIssueContent = Deno.readTextFileSync(userstyleIssuePath);
const replacedUserstyleIssueContent = userstyleIssueContent.replace(
"$PORTS",
`${
Object.entries(userstylesData.userstyles)
.map(([key]) => `'${ISSUE_PREFIX + key}'`)
.join(", ")
}`,
);
Deno.writeTextFileSync(
path.join(REPO_ROOT, ".github/ISSUE_TEMPLATE/userstyle.yml"),
replacedUserstyleIssueContent,
);
const heading = (name: Name, link: ApplicationLink) => {
const nameArray = Array.isArray(name) ? name : [name];
const linkArray = Array.isArray(link) ? link : [link];
if (nameArray.length !== linkArray.length) {
throw new Error(
'The "name" and "app-link" arrays must have the same length',
);
}
return `Catppuccin for ${
nameArray
.map((name, index) => `<a href="${linkArray[index]}">${name}</a>`)
.join(", ")
}`;
};
const usageContent = (usage?: Usage) => {
return !usage ? "" : `## Usage \n${usage}`;
};
const faqContent = (faq?: FAQ) => {
if (!faq) {
return "";
}
return `## 🙋 FAQ
${
faq
.map(({ question, answer }) => `- Q: ${question} \n\tA: ${answer}`)
.join("\n")
}`;
};
const collaboratorsContent = (allCollaborators: CollaboratorsData[]) => {
return allCollaborators
.filter(({ collaborators }) => collaborators !== undefined)
.map(({ collaborators, heading }) => {
const collaboratorBody = collaborators
?.map(({ name, url }) => `- [${name ?? url.split("/").pop()}](${url})`)
.join("\n");
return `${heading}\n${collaboratorBody}`;
})
.join("\n\n");
};
const updateStylesReadmeContent = (
readme: string,
key: string,
userstyle: Userstyle,
) => {
return readme
.replace("$TITLE", heading(userstyle.name, userstyle.readme["app-link"]))
.replaceAll("$LOWERCASE-PORT", key)
.replace("$USAGE", usageContent(userstyle.readme.usage))
.replace("$FAQ", faqContent(userstyle.readme.faq))
.replace(
"$COLLABORATORS",
collaboratorsContent([
{
collaborators: userstyle.readme["current-maintainers"],
heading: "## 💝 Current Maintainer(s)",
},
{
collaborators: userstyle.readme["past-maintainers"],
heading: "## 💖 Past Maintainer(s)",
},
]),
);
};
const stylesReadmePath = path.join(ROOT, "templates/userstyle.md");
const stylesReadmeContent = Deno.readTextFileSync(stylesReadmePath);
for (const [key, userstyle] of Object.entries(userstylesData.userstyles)) {
try {
console.log(`Generating README for ${key}`);
readmeContent = updateStylesReadmeContent(
stylesReadmeContent,
key,
userstyle,
);
Deno.writeTextFileSync(
path.join(REPO_ROOT, "styles", key, "README.md"),
readmeContent,
);
} catch (e) {
console.log(`Failed to update ${userstyle} README:`, e);
}
}
@@ -0,0 +1,41 @@
# THIS FILE IS AUTOGENERATED. DO NOT EDIT IT BY HAND.
name: Userstyle Issue
description: Report your problems with any of the userstyles here!
body:
- type: checkboxes
attributes:
label: Is there an existing issue outlining your problem?
description: Please search to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues and they do not solve my problem.
required: true
- type: dropdown
attributes:
label: What userstyles are you seeing the problem on?
description: "Don't worry about the `lbl:` prefix, it allows issues to be automatically labeled!"
multiple: true
options: [$PORTS]
validations:
required: true
- type: textarea
attributes:
label: Describe your problem.
description: Also tell us, what do you expect to see?
placeholder: The navigation bar on the website is highlighted incorrectly...
validations:
required: true
- type: textarea
attributes:
label: Attach screenshots.
description: If applicable, attach screenshots which clearly highlight the issue.
- type: input
attributes:
label: What browser(s) are you seeing the problem on?
description: "The browser version is also important, you can find out how to get that info [here](https://github.com/catppuccin/userstyles/blob/main/docs/browsers.md)."
placeholder: Firefox v112.0.2
validations:
required: true
- type: textarea
attributes:
label: Any additional comments?
description: Add any information that hasn't been covered in the previous sections!
+55
View File
@@ -0,0 +1,55 @@
<!-- AUTOGEN:README START -->
<!-- THIS FILE IS AUTOGENERATED. DO NOT EDIT IT BY HAND -->
<h3 align="center">
<img src="https://raw.githubusercontent.com/catppuccin/catppuccin/main/assets/logos/exports/1544x1544_circle.png" width="100" alt="Logo"/><br/>
<img src="https://raw.githubusercontent.com/catppuccin/catppuccin/main/assets/misc/transparent.png" height="30" width="0px"/>
$TITLE
<img src="https://raw.githubusercontent.com/catppuccin/catppuccin/main/assets/misc/transparent.png" height="30" width="0px"/>
</h3>
<p align="center">
<a href="https://github.com/catppuccin/userstyles/issues?q=is%3Aissue+is%3Aopen+label%3A$LOWERCASE-PORT"><img src="https://img.shields.io/github/issues/catppuccin/userstyles/$LOWERCASE-PORT?colorA=363a4f&colorB=f5a97f&style=for-the-badge"></a>
<a href="https://raw.githubusercontent.com/catppuccin/userstyles/main/styles/$LOWERCASE-PORT/catppuccin.user.css"><img src="https://img.shields.io/badge/stylus-install-cba6f7?colorA=363a4f&style=for-the-badge"></a>
</p>
<p align="center">
<img src="assets/catwalk.webp"/>
</p>
## Previews
<details>
<summary>🌻 Latte</summary>
<img src="assets/latte.webp"/>
</details>
<details>
<summary>🪴 Frappé</summary>
<img src="assets/frappe.webp"/>
</details>
<details>
<summary>🌺 Macchiato</summary>
<img src="assets/macchiato.webp"/>
</details>
<details>
<summary>🌿 Mocha</summary>
<img src="assets/mocha.webp"/>
</details>
$USAGE
$FAQ
$COLLABORATORS
&nbsp;
<p align="center">
<img src="https://raw.githubusercontent.com/catppuccin/catppuccin/main/assets/footers/gray0_ctp_on_line.svg?sanitize=true" />
</p>
<p align="center">
Copyright &copy; 2021-present <a href="https://github.com/catppuccin" target="_blank">Catppuccin Org</a>
</p>
<!-- AUTOGEN:README END -->
+47
View File
@@ -0,0 +1,47 @@
import { exists } from "std/fs/mod.ts";
import { join, relative } from "std/path/mod.ts";
import core from "@actions/core";
import { REPO_ROOT } from "@/deps.ts";
import { log } from "./logger.ts";
import chalk from "chalk";
const requiredFiles = [
"catppuccin.user.css",
...["latte", "frappe", "macchiato", "mocha", "catwalk"].map((f) =>
join("assets", `${f}.webp`)
),
];
export const checkForMissingFiles = async () => {
const stylesRoot = join(REPO_ROOT, "styles");
const missingFiles: string[] = [];
for await (const entry of Deno.readDir(stylesRoot)) {
if (!entry.isDirectory) continue;
const styleRoot = join(stylesRoot, entry.name);
await Promise.all(requiredFiles.map(async (f) => {
const fp = join(styleRoot, f);
const rfp = relative(REPO_ROOT, fp);
if (!(await exists(fp))) {
missingFiles.push(rfp);
}
}));
}
// only write summary if running in github actions
if (Deno.env.has("GITHUB_ACTIONS")) {
await core.summary
.addHeading("Missing files")
.addList(missingFiles)
.write();
} else {
missingFiles.map((f) => {
log(chalk.red(`Missing file:`) + ` ${f}`, { file: f }, "error");
});
}
return missingFiles.length === 0;
};
+82
View File
@@ -0,0 +1,82 @@
import { sprintf } from "std/fmt/printf.ts";
import chalk from "chalk";
import core from "@actions/core";
export type LoggerProps = core.AnnotationProperties & { content?: string };
const pretty_print = (
message: string,
props: LoggerProps,
severity: "error" | "warning" = "warning",
) => {
const { file, startColumn, startLine } = props;
if (!startLine) return console.log(message);
const lines = (props.content ?? "").split("\n");
const error = [
chalk[severity === "error" ? "red" : "yellow"](severity),
message,
].join(" ");
const line = lines[startLine - 1].split("").map((char, i) => {
const startCol = (props.startColumn ?? 0) - 1;
const endCol = (props.endColumn ?? Infinity) - 1;
if (i >= startCol && i <= endCol) {
return chalk[severity === "error" ? "red" : "yellow"](char);
} else {
return char;
}
}).join("");
const pad = startLine.toString().length;
console.log(
[
chalk.underline(
sprintf(
"%s%s%d%s%d",
file,
startLine ? ":" : "",
startLine ?? "",
startColumn ? ":" : "",
startColumn ?? "",
),
),
sprintf(
"%*s│ %s",
pad,
chalk.dim(startLine - 1),
chalk.dim(lines[startLine - 2]),
),
sprintf("%*s│ %s", pad, chalk.bold(startLine), line),
sprintf(
"%*s│ %s",
pad,
chalk.dim(startLine + 1),
chalk.dim(lines[startLine]),
),
sprintf("%*s╰─► %s", pad, "", error),
undefined,
].join("\n"),
);
};
export const log = (
message: string,
props: LoggerProps,
severity: "error" | "warning" = "warning",
) => {
if (Deno.env.has("CI")) {
switch (severity) {
case "error":
core.error(message, props);
break;
case "warning":
core.warning(message, props);
break;
}
} else {
pretty_print(message, props, severity);
}
};
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env -S deno run -A
import { walk } from "std/fs/mod.ts";
import { parse as parseFlags } from "std/flags/mod.ts";
import { basename, dirname, join, relative } from "std/path/mod.ts";
// @deno-types="npm:@types/less";
import less from "less";
import { REPO_ROOT } from "@/deps.ts";
import { checkForMissingFiles } from "./file-checker.ts";
import { log } from "./logger.ts";
import { verifyMetadata } from "./metadata.ts";
import { lint } from "./stylelint.ts";
const flags = parseFlags(Deno.args, { boolean: ["fix"] });
const stylesheets = walk(join(REPO_ROOT, "styles"), {
includeFiles: true,
includeDirs: false,
includeSymlinks: false,
match: [/\.user.css$/],
});
for await (const entry of stylesheets) {
const repodir = dirname(entry.path);
const repo = basename(repodir);
const file = relative(REPO_ROOT, entry.path);
const content = await Deno.readTextFile(entry.path);
// verify the usercss metadata
const { globalVars, isLess } = await verifyMetadata(entry, content, repo)
.catch((e) => {
const lines = content.split("\n");
let startLine = -1;
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (e.index >= line.length) {
e.index -= line.length;
startLine++;
} else break;
}
log(e.message, { file, startLine, content }, "error");
throw e;
});
// don't attempt to compile or lint non-less files
if (!isLess) continue;
// try to compile the less file, report any errors
less.render(content, { lint: true, globalVars }).then().catch(
(err) => {
log(
err.message,
{ file, startLine: err.line, endLine: err.line, content },
"error",
);
},
);
// advanced linting with stylelint
lint(entry, content, flags.fix);
}
// if any files are missing, cause the workflow to fail
if (await checkForMissingFiles() === false) {
Deno.exit(1);
}
+81
View File
@@ -0,0 +1,81 @@
// TODO: remove this once types for usercss-meta are available
// deno-lint-ignore-file no-explicit-any
import chalk from "chalk";
import usercssMeta from "usercss-meta";
import { log } from "./logger.ts";
import { sprintf } from "std/fmt/printf.ts";
import type { WalkEntry } from "std/fs/mod.ts";
import { relative } from "std/path/mod.ts";
import { REPO_ROOT } from "@/deps.ts";
export const verifyMetadata = (
entry: WalkEntry,
content: string,
repo: string,
): Promise<{
globalVars: Record<string, string>;
isLess: boolean;
}> => {
return new Promise((resolve, reject) => {
const assert = assertions(repo);
const file = relative(REPO_ROOT, entry.path);
let metadata: Record<string, any> = {};
try {
metadata = usercssMeta.parse(content).metadata;
} catch (err) {
log(err, { file }, "error");
reject(err);
}
Object.entries(assert).forEach(([k, v]) => {
const defacto = metadata[k];
if (defacto !== v) {
const line = content
.split("\n")
.findIndex((line) => line.includes(k)) + 1;
const message = sprintf(
"Metadata %s should be %s but is %s",
chalk.bold(k),
chalk.green(v),
chalk.red(defacto),
);
log(message, {
file,
startLine: line !== 0 ? line : undefined,
content,
}, "warning");
}
});
// parse the usercss variables to less global variables, e.g.
// `@var select lightFlavor "Light Flavor" ["latte:Latte*", "frappe:Frappé", "macchiato:Macchiato", "mocha:Mocha"]`
// gets parsed as
// `lightFlavor: "latte"`
const globalVars = Object.entries<{ default: string }>(metadata.vars)
.reduce((acc, [k, v]) => {
return { ...acc, [k]: v.default };
}, {});
resolve({
globalVars,
isLess: metadata.preprocessor === assert.preprocessor,
});
});
};
const assertions = (repo: string) => {
const prefix = "https://github.com/catppuccin/userstyles";
return {
namespace: `github.com/catppuccin/userstyles/styles/${repo}`,
author: "Catppuccin",
license: "MIT",
preprocessor: "less",
homepageURL: `${prefix}/tree/main/styles/${repo}`,
updateURL: `${prefix}/raw/main/styles/${repo}/catppuccin.user.css`,
};
};
+199
View File
@@ -0,0 +1,199 @@
import { deepMerge } from "std/collections/mod.ts";
import chalk from "chalk";
import stylelint from "npm:stylelint";
import stylelintConfigStandard from "npm:stylelint-config-standard";
import stylelintConfigRecommended from "npm:stylelint-config-recommended";
import postcssLess from "npm:postcss-less";
import { log } from "./logger.ts";
import { relative } from "https://deno.land/[email protected]/path/mod.ts";
import { REPO_ROOT } from "@/deps.ts";
import { WalkEntry } from "std/fs/walk.ts";
const config: stylelint.Config = {
customSyntax: postcssLess,
rules: {
"selector-class-pattern": null,
"custom-property-pattern": null,
"selector-id-pattern": null,
"rule-empty-line-before": null,
"comment-empty-line-before": null,
"custom-property-empty-line-before": null,
"at-rule-empty-line-before": null,
"declaration-empty-line-before": null,
"property-no-vendor-prefix": null,
"alpha-value-notation": null,
"color-function-notation": null,
"hue-degree-notation": null,
// less doesn't care about these
"no-invalid-position-at-import-rule": null,
"no-invalid-double-slash-comments": null,
"at-rule-disallowed-list": [[
"/^font.*/",
], {
message: (atRule: string) =>
`At-rule ${atRule} is not allowed in Catppuccin userstyles`,
}],
"property-disallowed-list": [[
// disallow setting fonts
"/font.*/",
// ideally we could disallow these, but CSS continues to be gross
// "/animation.*/",
// "/transition.*/",
// prefer `border-color` over `border`, `outline-color` over `outline`, etc.
"border",
"outline",
], {
message: (prop: string) => {
if (["border", "outline"].includes(prop)) {
return `Use \`${prop}-color\` instead of \`${prop}\``;
} else {
return `Property \`${prop}\` is not allowed in Catppuccin userstyles`;
}
},
}],
"function-no-unknown": [
true,
{
ignoreFunctions: [
// generated from https://lesscss.org/functions/
// via `Array.from(document.querySelectorAll('.section-content h3.docs-heading'), heading => heading.textContent.replace('\n', ''))`
"%",
"abs",
"acos",
"alpha",
"argb",
"asin",
"atan",
"average",
"blue",
"boolean",
"ceil",
"color",
"contrast",
"convert",
"cos",
"darken",
"data-uri",
"default",
"desaturate",
"difference",
"e",
"each",
"escape",
"exclusion",
"extract",
"fade",
"fadein",
"fadeout",
"floor",
"get-unit",
"green",
"greyscale",
"hardlight",
"hsl",
"hsla",
"hsv",
"hsva",
"hsvhue",
"hsvsaturation",
"hsvvalue",
"hue",
"if",
"image-height",
"image-size",
"image-width",
"iscolor",
"isdefined",
"isem",
"iskeyword",
"isnumber",
"ispercentage",
"ispixel",
"isruleset",
"isstring",
"isunit",
"isurl",
"length",
"lighten",
"lightness",
"luma",
"luminance",
"max",
"min",
"mix",
"mod",
"multiply",
"negation",
"overlay",
"percentage",
"pi",
"pow",
"range",
"red",
"replace",
"rgb",
"rgba",
"round",
"saturate",
"saturation",
"screen",
"shade",
"sin",
"softlight",
"spin",
"sqrt",
"svg-gradient",
"tan",
"tint",
"unit",
],
},
],
"function-name-case": null,
"no-descending-specificity": null,
},
};
const base = deepMerge(
stylelintConfigRecommended,
{ ...stylelintConfigStandard, extends: {} },
);
export const lint = (entry: WalkEntry, content: string, fix: boolean) => {
const file = relative(REPO_ROOT, entry.path);
stylelint.lint({
config: deepMerge(base, config),
files: entry.path,
fix,
})
.then(({ results }) => {
results.map((result) => {
result.warnings.map((warning) => {
// some cleanup for fancier logging, dims the rule name
const message = warning.text?.replace(
new RegExp(`\\(?${warning.rule}\\)?`),
chalk.dim(`(${warning.rule})`),
) ?? "unspecified stylelint error";
log(message, {
file,
startLine: warning.line,
endLine: warning.endLine,
startColumn: warning.column,
endColumn: warning.endColumn,
content,
}, warning.severity);
});
});
});
};
+77
View File
@@ -0,0 +1,77 @@
#!/usr/bin/env -S deno run --allow-read --allow-net --allow-env
import * as assert from "std/assert/mod.ts";
import * as path from "std/path/mod.ts";
import { parse as parseYaml } from "std/yaml/mod.ts";
import Ajv from "ajv";
import { Octokit } from "@octokit/rest";
import { REPO_ROOT, schema } from "@/deps.ts";
import { Userstyle, UserstylesSchema } from "@/types.d.ts";
const octokit = new Octokit({ auth: Deno.env.get("GITHUB_TOKEN") });
const team = { org: "catppuccin", team_slug: "userstyles-maintainers" };
const ajv = new Ajv.default();
const validate = ajv.compile<UserstylesSchema>(schema);
const userstylesYaml = Deno.readTextFileSync(
path.join(REPO_ROOT, "scripts/userstyles.yml"),
);
const userstylesData = parseYaml(userstylesYaml);
if (!validate(userstylesData)) {
console.error(validate.errors);
Deno.exit(1);
}
if (userstylesData.userstyles === undefined) {
Deno.exit(1);
}
// lowercase usernames of all the "current-maintainers" in the file
const maintainers = [
...new Set(
Object.values(userstylesData.userstyles).flatMap((style: Userstyle) =>
style.readme["current-maintainers"].map((m) => {
const username = m.url.split("github.com/")?.pop();
// check that they follow github.com/username pattern
assert.assertExists(username);
return username.toLowerCase();
})
),
),
];
// lowercase usernames of all maintainers in the current GH team
const teamMembers = await octokit.teams
.listMembersInOrg({
...team,
per_page: 100,
})
.then((res) => res.data.map((m) => m.login.toLowerCase()));
const syncMaintainers = async () => {
if (!maintainers) return;
if (assert.equal(maintainers, teamMembers)) {
console.log("Maintainers are in sync");
return;
}
const toAdd = maintainers.filter((m) => !teamMembers.includes(m));
const toRemove = teamMembers.filter((m) => !maintainers.includes(m));
for (const m of toAdd) {
await octokit.teams.addOrUpdateMembershipForUserInOrg({
...team,
username: m,
});
}
for (const m of toRemove) {
await octokit.teams.removeMembershipForUserInOrg({
...team,
username: m,
});
}
};
await syncMaintainers();
+2
View File
@@ -0,0 +1,2 @@
export * from "./types/userstyles.d.ts";
export type { Categories as PortCategories } from "catppuccin-repo/resources/generate/types.d.ts";
+180
View File
@@ -0,0 +1,180 @@
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
/**
* The name of the userstyle(s).
*/
export type Name = [string, string, ...string[]] | string;
/**
* The category that fits the port the most.
*/
export type Category =
| "browser"
| "browser_extension"
| "cli"
| "code_editor"
| "development"
| "game"
| "leisure"
| "library"
| "messaging"
| "note_taking"
| "productivity"
| "search_engine"
| "social"
| "system"
| "terminal";
/**
* The fill color for the icon on the Catppuccin website.
*/
export type Color =
| "rosewater"
| "flamingo"
| "pink"
| "mauve"
| "red"
| "maroon"
| "peach"
| "yellow"
| "green"
| "teal"
| "sky"
| "sapphire"
| "blue"
| "lavender"
| "text";
/**
* The icon to use on the website. This should be the same name as the SVG file on https://simpleicons.org/. If a `.svg` suffix is present, it's taken from the local website repository resources.
*/
export type Icon = string;
/**
* The hyperlink of the app that is being themed.
*/
export type ApplicationLink = [string, string, ...string[]] | string;
/**
* The Usage section of the userstyle README.
*/
export type Usage = string;
/**
* The FAQ section of the userstyle README.
*
* @minItems 1
*/
export type FAQ = [
{
question: Question;
answer: Answer;
[k: string]: unknown;
},
...{
question: Question;
answer: Answer;
[k: string]: unknown;
}[],
];
/**
* A question that a user may have about the userstyle.
*/
export type Question = string;
/**
* An answer to the question about the userstyle.
*/
export type Answer = string;
/**
* List of all active maintainers for this userstyle.
*
* @minItems 1
*/
export type CurrentMaintainers = [
{
name?: DisplayName;
url: GitHubProfile;
[k: string]: unknown;
},
...{
name?: DisplayName;
url: GitHubProfile;
[k: string]: unknown;
}[],
];
/**
* The display name of the collaborator to show in the userstyle README.
*/
export type DisplayName = string;
/**
* The GitHub profile link of the collaborator to show in the userstyle README.
*/
export type GitHubProfile = string;
/**
* List of all maintainers that have maintained on this userstyle in the past.
*
* @minItems 1
*/
export type PastMaintainers = [
{
name?: DisplayName;
url: GitHubProfile;
[k: string]: unknown;
},
...{
name?: DisplayName;
url: GitHubProfile;
[k: string]: unknown;
}[],
];
/**
* Represents all maintainers and contributors to all userstyles.
*
* @minItems 1
*/
export type AllCollaborators = [
{
name?: DisplayName;
url: GitHubProfile;
[k: string]: unknown;
},
...{
name?: DisplayName;
url: GitHubProfile;
[k: string]: unknown;
}[],
];
export interface UserstylesSchema {
userstyles?: Userstyles;
collaborators?: AllCollaborators;
}
/**
* All userstyles in the Catppuccin org.
*/
export interface Userstyles {
[k: string]: Userstyle;
}
/**
* The directory of the userstyle.
*
* This interface was referenced by `Userstyles`'s JSON-Schema definition
* via the `patternProperty` "[A-Za-z0-9_\-]".
*/
export interface Userstyle {
name: Name;
category: Category;
color?: Color;
icon?: Icon;
readme: README;
}
/**
* Options to help in the auto-generation of the userstyle README.
*/
export interface README {
"app-link": ApplicationLink;
usage?: Usage;
faq?: FAQ;
"current-maintainers": CurrentMaintainers;
"past-maintainers"?: PastMaintainers;
[k: string]: unknown;
}
+203
View File
@@ -0,0 +1,203 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": false,
"properties": {
"userstyles": {
"$id": "#userstyles",
"title": "Userstyles",
"type": "object",
"description": "All userstyles in the Catppuccin org.",
"patternProperties": {
"[A-Za-z0-9_\\-]": {
"$id": "#userstyles/userstyle",
"title": "Userstyle",
"type": "object",
"description": "The directory of the userstyle.",
"examples": ["youtube"],
"required": ["name", "category", "readme"],
"additionalProperties": false,
"properties": {
"name": {
"$id": "#userstyles/userstyle/name",
"title": "Name",
"description": "The name of the userstyle(s).",
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
},
"minItems": 2,
"examples": [["AniList", "AniChart"]]
},
{
"type": "string",
"examples": ["YouTube"]
}
]
},
"category": {
"$id": "#userstyles/userstyle/category",
"title": "Category",
"description": "The category that fits the port the most.",
"$ref": "#/$defs/category"
},
"color": {
"$id": "#userstyles/userstyle/color",
"title": "Color",
"description": "The fill color for the icon on the Catppuccin website.",
"type": "string",
"enum": [
"rosewater",
"flamingo",
"pink",
"mauve",
"red",
"maroon",
"peach",
"yellow",
"green",
"teal",
"sky",
"sapphire",
"blue",
"lavender",
"text"
],
"examples": ["pink"]
},
"icon": {
"$id": "#userstyles/userstyle/icon",
"title": "Icon",
"description": "The icon to use on the website. This should be the same name as the SVG file on https://simpleicons.org/. If a `.svg` suffix is present, it's taken from the local website repository resources.",
"type": "string",
"examples": ["twitch", "twitch.svg"]
},
"readme": {
"$id": "#userstyles/userstyle/readme",
"title": "README",
"description": "Options to help in the auto-generation of the userstyle README.",
"type": "object",
"required": ["app-link", "current-maintainers"],
"properties": {
"app-link": {
"$id": "#userstyles/userstyle/readme/app-link",
"title": "Application Link",
"description": "The hyperlink of the app that is being themed.",
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
},
"minItems": 2,
"examples": [
["https://anilist.co", "https://anichart.net"]
]
},
{
"type": "string",
"examples": ["https://github.com"]
}
]
},
"usage": {
"$id": "#userstyles/userstyle/readme/usage",
"title": "Usage",
"description": "The Usage section of the userstyle README.",
"type": "string"
},
"faq": {
"$id": "#userstyles/userstyle/readme/faq",
"title": "FAQ",
"description": "The FAQ section of the userstyle README.",
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"properties": {
"question": {
"type": "string",
"title": "Question",
"description": "A question that a user may have about the userstyle."
},
"answer": {
"type": "string",
"title": "Answer",
"description": "An answer to the question about the userstyle."
}
},
"required": ["question", "answer"]
}
},
"current-maintainers": {
"$id": "#userstyles/userstyle/readme/current-maintainers",
"title": "Current Maintainers",
"description": "List of all active maintainers for this userstyle.",
"$ref": "#/$defs/collaborators"
},
"past-maintainers": {
"$id": "#userstyles/userstyle/readme/past-maintainers",
"title": "Past Maintainers",
"description": "List of all maintainers that have maintained on this userstyle in the past.",
"$ref": "#/$defs/collaborators"
}
}
}
}
}
}
},
"collaborators": {
"$id": "#all-collaborators",
"title": "All Collaborators",
"description": "Represents all maintainers and contributors to all userstyles.",
"$ref": "#/$defs/collaborators"
}
},
"$defs": {
"collaborators": {
"$id": "#collaborators",
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Display Name",
"description": "The display name of the collaborator to show in the userstyle README."
},
"url": {
"type": "string",
"title": "GitHub Profile",
"description": "The GitHub profile link of the collaborator to show in the userstyle README."
}
},
"required": ["url"]
}
},
"category": {
"$id": "#category",
"type": "string",
"enum": [
"browser",
"browser_extension",
"cli",
"code_editor",
"development",
"game",
"leisure",
"library",
"messaging",
"note_taking",
"productivity",
"search_engine",
"social",
"system",
"terminal"
]
}
}
}
+482
View File
@@ -0,0 +1,482 @@
collaborators:
- &anubisnekhet
url: https://github.com/AnubisNekhet
- &ndsboy
url: https://github.com/ndsboy
- &jn-sena
name: Sena
url: https://github.com/jn-sena
- &watatomo
name: Ren
url: https://github.com/watatomo
- &ryanccn
name: Ryan Cao
url: https://github.com/ryanccn
- &pocco81
url: https://github.com/Pocco81
- &glowingumbreon
name: Umbreon
url: https://github.com/GlowingUmbreon
- &justtobbi
url: https://github.com/justTOBBI
- &andreasgrafen
name: Andreas Grafen
url: https://github.com/andreasgrafen
- &lucasmelin
name: Lucas Melin
url: https://github.com/lucasmelin
- &gingeh
url: https://github.com/Gingeh
- &isabelroses
name: Isabel
url: https://github.com/isabelroses
- &thismoon
url: https://github.com/thismoon
- &alaidriel
url: https://github.com/alaidriel
- &soya-daizu
name: soya_daizu
url: https://github.com/soya-daizu
- &jayylmao
url: https://github.com/jayylmao
- &sekki21956
name: Sekki
url: https://github.com/Sekki21956
- &winston
name: winston
url: https://github.com/nekowinston
- &gitmuslim
url: https://github.com/GitMuslim
- &tnixc
name: Tnixc
url: https://github.com/tnixc
- &elkrien
name: Elkrien
url: https://github.com/elkrien
- &thememesniper
name: TheMemeSniper
url: https://github.com/TheMemeSniper
- &spaghettiosareyummy
url: https://github.com/spaghettiosareyummy
- &stonks3141
name: Stonks3141
url: https://github.com/Stonks3141
- &rubyowo
url: https://github.com/rubyowo
- &gandalf-the-blue
name: Gandalf the Blue
url: https://github.com/Gandalf-the-Blue
- &francorav
name: FrancoRav
url: https://github.com/FrancoRav
- &coldenate
name: coldenate
url: https://github.com/coldenate
- &skelebro1
name: skele
url: https://github.com/skelebro1
- &r58Playz
name: r58Playz
url: https://github.com/r58Playz
- &rockquiet
name: rockquiet
url: https://github.com/rockquiet
- &night-lake
name: Amelia Katherine
url: https://github.com/night-lake
- &bartlibert
name: Bart Libert
url: https://github.com/bartlibert
- &BlankParticle
name: BlankParticle
url: https://github.com/BlankParticle
- &haiksgithub
name: haiksgithub
url: https://github.com/haiksgithub
- &genshibe
name: GenShibe
url: https://github.com/GenShibe
userstyles:
advent-of-code:
name: Advent Of Code
category: game
readme:
app-link: https://adventofcode.com
current-maintainers: [*rubyowo]
anilist:
name: ["AniList", "AniChart"]
category: leisure
color: blue
readme:
app-link: ["https://anilist.co", "https://anichart.net"]
usage: |+
> [!NOTE]
> This theme applies to [AniChart](https://anichart.net/) as well, which is an extension of AniList.
current-maintainers: [*anubisnekhet]
boringproxy:
name: boringproxy
category: productivity
readme:
app-link: "https://boringproxy.io"
current-maintainers: [*gandalf-the-blue]
brave-search:
name: Brave Search
category: search_engine
icon: brave
color: peach
readme:
app-link: "https://search.brave.com"
usage: "Make sure to set the theme to either dark or light in Brave Search settings, as the automatic setting will not work."
current-maintainers: [*ndsboy]
bstats:
name: bStats
category: game
color: green
readme:
app-link: "https://bstats.org"
usage: "Make sure to use the default **Teal** theme from the built-in color picker (located at the bottom of the page) for the best experience!"
current-maintainers: [*rockquiet]
canvas-lms:
name: Canvas LMS
category: productivity
readme:
app-link: "https://www.instructure.com/canvas"
current-maintainers: [*thememesniper]
chatgpt:
name: ChatGPT
category: productivity
readme:
app-link: "https://chat.openai.com"
current-maintainers: [*rubyowo]
chatreplay:
name: ChatReplay
category: leisure
readme:
app-link: "https://chatreplay.stream"
current-maintainers: [*anubisnekhet]
chess.com:
name: Chess.com
category: game
color: green
readme:
app-link: "https://chess.com"
current-maintainers: [*coldenate, *isabelroses, *skelebro1]
cinny:
name: Cinny
category: messaging
readme:
app-link: "https://cinny.in"
current-maintainers: [*jn-sena]
codeberg:
name: Codeberg
category: productivity
readme:
app-link: "https://codeberg.org"
faq:
- question: "How do I change the accent color?"
answer: "Changing `--color-primary` to any other color should change the accent color in most places."
current-maintainers: [*justtobbi]
crowdin:
name: Crowdin
category: productivity
readme:
app-link: "https://crowdin.com"
current-maintainers: [*ryanccn]
deepl:
name: DeepL
category: productivity
readme:
app-link: "https://deepl.com"
current-maintainers: [*watatomo]
ecosia:
name: Ecosia
category: search_engine
readme:
app-link: "https://www.ecosia.org"
current-maintainers: [*isabelroses]
elk:
name: Elk
category: social
readme:
app-link: "https://elk.zone"
current-maintainers: [*ryanccn]
formative:
name: Formative
category: productivity
readme:
app-link: "https://app.formative.com/home"
current-maintainers: [*r58Playz]
github:
name: GitHub
category: productivity
color: text
readme:
usage: "Switch to a default GitHub light/dark theme via **Settings** > **Appearance** for the best experience!"
app-link: "https://github.com"
current-maintainers: [*pocco81, *glowingumbreon]
past-maintainers: [*andreasgrafen]
gmail:
name: Gmail
category: productivity
readme:
usage: "Switch to either the dark or default themes via the **gear icon** > **themes** > **view all** for the best experience!"
app-link: "https://mail.google.com"
current-maintainers: [*isabelroses]
hacker-news:
name: Hacker News
category: social
icon: ycombinator
readme:
app-link: "https://news.ycombinator.com"
current-maintainers: [*lucasmelin]
homepage:
name: homepage
category: productivity
readme:
app-link: "https://github.com/benphelps/homepage"
current-maintainers: [*gandalf-the-blue]
hoppscotch:
name: Hoppscotch
category: development
color: green
readme:
app-link: "https://hoppscotch.io/"
current-maintainers: [*justtobbi]
ichi.moe:
name: ichi.moe
category: productivity
readme:
app-link: "https://ichi.moe"
current-maintainers: [*watatomo]
instagram:
name: Instagram
category: social
readme:
app-link: "https://instagram.com"
current-maintainers: [*genshibe]
past-maintainers: [*haiksgithub, *isabelroses]
invidious:
name: Invidious
category: leisure
icon: youtube
color: red
readme:
app-link: "https://invidious.io"
current-maintainers: [*winston]
past-maintainers: [*andreasgrafen]
invokeai:
name: InvokeAI
category: productivity
readme:
app-link: "https://invoke-ai.github.io/InvokeAI"
current-maintainers: [*ryanccn]
lastfm:
name: Last.fm
category: leisure
icon: lastdotfm
color: red
readme:
app-link: "https://last.fm"
current-maintainers: [*anubisnekhet]
past-maintainers: [*gingeh]
libreddit:
name: Libreddit
category: social
icon: reddit
color: peach
readme:
app-link: "https://github.com/libreddit/libreddit"
current-maintainers: [*isabelroses]
past-maintainers: [*andreasgrafen]
linkedin:
name: LinkedIn
category: social
icon: LinkedIn
readme:
app-link: "https://www.linkedin.com"
current-maintainers: [*isabelroses]
mastodon:
name: Mastodon
category: social
readme:
app-link: "https://github.com/mastodon/mastodon"
usage: |+
This userstyle is applied by default on a few commonly used Mastodon servers, listed at the top:
```css
@-moz-document domain("mastodon.social"), domain("mstdn.social"), domain("fosstodon.org"), domain("piaille.fr"), domain("tech.lgbt") {
```
If the theme isn't being applied to your instance, go to the userstyle's **Settings > Custom included sites** and add your instance to the list, for instance, `*://floss.social/*`.
faq:
- question: "**The theme does not look the same as the preview?**"
answer: "Your Mastodon instance may be using its own custom CSS, which is changing the look of the theme."
- question: "**The theme is not working?**"
answer: |
One solution might be changing the theme to either light or dark via **Preferences** > **Appearance** > **Site theme**.
current-maintainers: [*isabelroses]
past-maintainers: [*andreasgrafen]
modrinth:
name: Modrinth
category: game
color: green
readme:
app-link: "https://modrinth.com"
current-maintainers: [*thismoon]
nitter:
name: Nitter
category: social
icon: twitter
color: blue
readme:
app-link: "https://nitter.net"
current-maintainers: [*anubisnekhet]
nixos-search:
name: NixOS Search
category: search_engine
icon: nixos
color: blue
readme:
app-link: "https://search.nixos.org"
current-maintainers: [*alaidriel]
nixos.wiki:
name: NixOS Wiki
category: productivity
icon: nixos
color: blue
readme:
app-link: "https://nixos.wiki"
current-maintainers: [*winston]
paste.rs:
name: paste.rs
category: development
readme:
app-link: "https://paste.rs"
current-maintainers: [*stonks3141]
pinterest:
name: Pinterest
category: social
readme:
app-link: "https://www.pinterest.com"
current-maintainers: [*jn-sena]
planet-minecraft:
name: Planet Minecraft
category: game
readme:
app-link: "https://planetminecraft.com"
current-maintainers: [*night-lake]
proton:
name: Proton
category: productivity
icon: protonmail
color: lavender
readme:
app-link: "https://proton.me/"
usage: |+
> [!NOTE]
> Set Proton Mail's built-in theme to 'Snow' if you're using Latte or 'Carbon' if you're using the others.
current-maintainers: [*soya-daizu]
quizlet:
name: Quizlet
category: productivity
readme:
app-link: "https://quizlet.com"
current-maintainers: [*spaghettiosareyummy]
reddit:
name: Reddit
category: social
color: red
icon: reddit
readme:
app-link: "https://reddit.com"
current-maintainers: [*jayylmao]
searxng:
name: SearXNG
category: search_engine
readme:
usage: |+
This userstyle is applied by default on a few commonly used Searxng servers, listed at the top:
```css
@-moz-document url-prefix("https://searx.baczek.me/"), url-prefix("https://searx.be/") {
```
If the theme isn't being applied to your instance, go to the userstyle's **Settings > Custom included sites** and add your instance to the list, for instance, `*://searxng.example.com/*`.
app-link: "https://github.com/searxng/searxng"
current-maintainers: [*sekki21956, *ryanccn]
startpage:
name: Startpage
category: search_engine
readme:
app-link: "https://startpage.com"
current-maintainers: [*bartlibert]
stylus:
name: Stylus
category: productivity
readme:
app-link: "https://github.com/openstyles/stylus"
current-maintainers: [*gitmuslim]
substack:
name: Substack
category: social
readme:
app-link: "https://substack.com"
current-maintainers: [*winston]
syncthing:
name: Syncthing
category: productivity
readme:
app-link: "https://syncthing.net"
usage: |+
> [!NOTE]
> This theme is designed to be used with the default WebGUI and default theme provided by Syncthing. This does not theme syncthing.net.
current-maintainers: [*BlankParticle]
tutanota:
name: Tutanota
category: productivity
color: red
readme:
app-link: "https://tutanota.com/"
usage: |+
> [!NOTE]
> Set Tutanota's built-in theme to either **light** if you're using Latte or **dark** if you're using the others.
current-maintainers: [*ryanccn]
twitch:
name: Twitch
category: leisure
icon: twitch
color: mauve
readme:
app-link: "https://twitch.tv"
usage: |+
> [!NOTE]
> Set Twitch's built-in theme to either **light** if you're using Latte or **dark** if you're using the others.
current-maintainers: [*gitmuslim, *isabelroses]
vercel:
name: Vercel
category: development
readme:
app-link: "https://vercel.com"
current-maintainers: [*ryanccn]
whatsapp-web:
name: WhatsApp Web
category: messaging
readme:
app-link: "https://web.whatsapp.com"
current-maintainers: [*francorav]
wikiwand:
name: WikiWand
category: productivity
icon: wikipedia
readme:
app-link: "https://www.wikiwand.com"
current-maintainers: [*tnixc]
youtube:
name: YouTube
category: leisure
color: red
readme:
app-link: "https://youtube.com"
faq:
- question: "**What does the 'Enable for black bars' option mean?**"
answer: "It's available in case you have an OLED display. If you have one, you might want to enable this."
current-maintainers: [*isabelroses]
past-maintainers: [*elkrien]
# yaml-language-server: $schema=https://raw.githubusercontent.com/catppuccin/userstyles/main/scripts/userstyles.schema.json