diff --git a/deno.json b/deno.json index 7c21bb7aff..0fcddb2ff3 100644 --- a/deno.json +++ b/deno.json @@ -6,6 +6,7 @@ "@actions/core": "npm:@actions/core@1.10.1", "@octokit/rest": "npm:@octokit/rest@20.0.2", "ajv": "npm:ajv@8.12.0", + "type-fest/": "https://esm.sh/v135/type-fest@4.8.1/", "handlebars": "npm:handlebars@4.7.8", "less": "npm:less@4.2.0", "usercss-meta": "npm:usercss-meta@0.12.0" diff --git a/scripts/lint/main.ts b/scripts/lint/main.ts index 236bab4709..0a6ac2b383 100755 --- a/scripts/lint/main.ts +++ b/scripts/lint/main.ts @@ -28,7 +28,7 @@ for await (const entry of stylesheets) { const content = await Deno.readTextFile(entry.path); // verify the usercss metadata - const { globalVars, isLess } = verifyMetadata(entry, content, repo); + const { globalVars, isLess } = await verifyMetadata(entry, content, repo); // don't attempt to compile or lint non-less files if (!isLess) continue; diff --git a/scripts/lint/metadata.ts b/scripts/lint/metadata.ts index 77dbecb11b..74bc54ca78 100644 --- a/scripts/lint/metadata.ts +++ b/scripts/lint/metadata.ts @@ -1,18 +1,20 @@ // @deno-types="@/types/usercss-meta.d.ts"; import usercssMeta from "usercss-meta"; -import { log } from "@/lint/logger.ts"; import * as color from "std/fmt/colors.ts"; import { sprintf } from "std/fmt/printf.ts"; import type { WalkEntry } from "std/fs/walk.ts"; import { relative } from "std/path/mod.ts"; + import { REPO_ROOT } from "@/deps.ts"; +import { log } from "@/lint/logger.ts"; +import { getUserstylesData } from "@/utils.ts"; -export const verifyMetadata = ( +export const verifyMetadata = async ( entry: WalkEntry, content: string, repo: string, ) => { - const assert = assertions(repo); + const assert = await assertions(repo); const file = relative(REPO_ROOT, entry.path); const { metadata, errors: parsingErrors } = usercssMeta.parse(content, { @@ -67,9 +69,20 @@ export const verifyMetadata = ( }; }; -const assertions = (repo: string) => { +const assertions = async (repo: string) => { const prefix = "https://github.com/catppuccin/userstyles"; + + const { userstyles } = await getUserstylesData().catch((err) => { + console.error(err); + Deno.exit(1); + }); + return { + name: `${ + Array.isArray(userstyles[repo].name) + ? (userstyles[repo].name as string[]).join("/") + : userstyles[repo].name + } Catppuccin`, namespace: `github.com/catppuccin/userstyles/styles/${repo}`, author: "Catppuccin", license: "MIT", diff --git a/scripts/sync-maintainers/main.ts b/scripts/sync-maintainers/main.ts index 0665e4dd1e..d44b6888a2 100755 --- a/scripts/sync-maintainers/main.ts +++ b/scripts/sync-maintainers/main.ts @@ -1,23 +1,17 @@ #!/usr/bin/env -S deno run -A import * as assert from "std/assert/mod.ts"; -import * as path from "std/path/mod.ts"; import { Octokit } from "@octokit/rest"; -import { REPO_ROOT, userStylesSchema } from "@/deps.ts"; import type { UserStylesSchema } from "@/types/mod.ts"; -import { validateYaml } from "@/utils.ts"; -import { UserstylesSchema } from "@/types/userstyles.d.ts"; +import { getUserstylesData } from "@/utils.ts"; const octokit = new Octokit({ auth: Deno.env.get("GITHUB_TOKEN") }); const team = { org: "catppuccin", team_slug: "userstyles-maintainers" }; -const userstylesData = await validateYaml( - Deno.readTextFileSync(path.join(REPO_ROOT, "scripts/userstyles.yml")), - userStylesSchema, -); -if (userstylesData.userstyles === undefined) { +const userstylesData = await getUserstylesData().catch((err) => { + console.error(err); Deno.exit(1); -} +}); // lowercase usernames of all the "current-maintainers" in the file const maintainers = [ diff --git a/scripts/utils.ts b/scripts/utils.ts index c600ff56a8..0ca6e7723a 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,5 +1,10 @@ import Ajv, { Schema } from "ajv"; import { parse } from "std/yaml/parse.ts"; +import { join } from "std/path/join.ts"; +import { SetRequired } from "type-fest/source/set-required.d.ts"; + +import { REPO_ROOT, userStylesSchema } from "@/deps.ts"; +import { UserstylesSchema } from "@/types/userstyles.d.ts"; /** * @param content A string of YAML content @@ -20,3 +25,23 @@ export const validateYaml = ( return resolve(data); }); }; + +/** + * Utility function that calls {@link validateYaml} on the userstyles.yml file. + * Fails when data.userstyles is undefined. + */ +export const getUserstylesData = (): Promise => { + return new Promise((resolve, reject) => { + validateYaml( + Deno.readTextFileSync(join(REPO_ROOT, "scripts/userstyles.yml")), + userStylesSchema, + ).then((data) => { + if (data.userstyles === undefined || data.collaborators === undefined) { + return reject("userstyles.yml is missing required fields"); + } + return resolve(data as Userstyles); + }); + }); +}; + +type Userstyles = SetRequired; diff --git a/styles/anilist/catppuccin.user.css b/styles/anilist/catppuccin.user.css index 2281b3d0cc..3db7f994ad 100644 --- a/styles/anilist/catppuccin.user.css +++ b/styles/anilist/catppuccin.user.css @@ -1,5 +1,5 @@ /* ==UserStyle== -@name AniList Catppuccin +@name AniList/AniChart Catppuccin @namespace github.com/catppuccin/userstyles/styles/anilist @homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/anilist @version 2.1.1 diff --git a/styles/chess.com/catppuccin.user.css b/styles/chess.com/catppuccin.user.css index ea33b644c9..e4c9d2c9df 100644 --- a/styles/chess.com/catppuccin.user.css +++ b/styles/chess.com/catppuccin.user.css @@ -2,7 +2,7 @@ @name Chess.com Catppuccin @namespace github.com/catppuccin/userstyles/styles/chess.com @homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/chess.com -@version 0.1.2 +@version 0.1.3 @updateURL https://github.com/catppuccin/userstyles/raw/main/styles/chess.com/catppuccin.user.css @supportURL https://github.com/catppuccin/userstyles/issues?q=is%3Aopen+is%3Aissue+label%3Achess.com @description Soothing pastel theme for Chess.com @@ -62,8 +62,8 @@ @crust: @catppuccin[@@lookup][@crust]; @accent-color: @catppuccin[@@lookup][@@accent]; - #piece(@name) { - @url: url("https://media.githubusercontent.com/media/catppuccin/userstyles/main/styles/chess.com/assets/@{lookup}/@{name}.png"); + #piece(@piece) { + @url: url("https://media.githubusercontent.com/media/catppuccin/userstyles/main/styles/chess.com/assets/@{lookup}/@{piece}.png"); } @bb: #piece("b/bb") []; diff --git a/styles/github/catppuccin.user.css b/styles/github/catppuccin.user.css index b2bfee73e1..fb085cfa81 100644 --- a/styles/github/catppuccin.user.css +++ b/styles/github/catppuccin.user.css @@ -1,13 +1,13 @@ /* ==UserStyle== -@name Github Catppuccin -@namespace github.com/catppuccin/userstyles/styles/github -@homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/github -@version 1.3.2 -@description Soothing pastel theme for GitHub -@author Catppuccin -@updateURL https://github.com/catppuccin/userstyles/raw/main/styles/github/catppuccin.user.css -@supportURL https://github.com/catppuccin/userstyles/issues?q=is%3Aopen+is%3Aissue+label%3Agithub -@license MIT +@name GitHub Catppuccin +@namespace github.com/catppuccin/userstyles/styles/github +@homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/github +@version 1.3.3 +@description Soothing pastel theme for GitHub +@author Catppuccin +@updateURL https://github.com/catppuccin/userstyles/raw/main/styles/github/catppuccin.user.css +@supportURL https://github.com/catppuccin/userstyles/issues?q=is%3Aopen+is%3Aissue+label%3Agithub +@license MIT @preprocessor less @var select lightFlavor "Light Flavor" ["latte:Latte*", "frappe:Frappé", "macchiato:Macchiato", "mocha:Mocha"] @@ -58,49 +58,49 @@ z-index: 9999; } - #coloredButton(@name, @color, @flat) { + #coloredButton(@item, @color, @flat) { & when (@flat) { - --color-btn-@{name}-text: @color; - --color-btn-@{name}-bg: @base; - --color-btn-@{name}-icon: @color; + --color-btn-@{item}-text: @color; + --color-btn-@{item}-bg: @base; + --color-btn-@{item}-icon: @color; - --color-btn-@{name}-hover-text: @base; - --color-btn-@{name}-hover-bg: @color; - --color-btn-@{name}-hover-border: @color; + --color-btn-@{item}-hover-text: @base; + --color-btn-@{item}-hover-bg: @color; + --color-btn-@{item}-hover-border: @color; - --color-btn-@{name}-selected-text: @base; - --color-btn-@{name}-selected-bg: @color; - --color-btn-@{name}-selected-border: @color; + --color-btn-@{item}-selected-text: @base; + --color-btn-@{item}-selected-bg: @color; + --color-btn-@{item}-selected-border: @color; - --color-btn-@{name}-disabled-text: fadeout(@color, 60%); - --color-btn-@{name}-disabled-bg: @mantle; + --color-btn-@{item}-disabled-text: fadeout(@color, 60%); + --color-btn-@{item}-disabled-bg: @mantle; } & when not (@flat) { - --color-btn-@{name}-text: @base; - --color-btn-@{name}-bg: @color; - --color-btn-@{name}-icon: @base; + --color-btn-@{item}-text: @base; + --color-btn-@{item}-bg: @color; + --color-btn-@{item}-icon: @base; - --color-btn-@{name}-hover-text: @base; - --color-btn-@{name}-hover-bg: lighten(@color, 10%); - --color-btn-@{name}-hover-border: lighten(@color, 10%); + --color-btn-@{item}-hover-text: @base; + --color-btn-@{item}-hover-bg: lighten(@color, 10%); + --color-btn-@{item}-hover-border: lighten(@color, 10%); - --color-btn-@{name}-selected-text: @base; - --color-btn-@{name}-selected-bg: lighten(@color, 10%); - --color-btn-@{name}-selected-border: lighten(@color, 10%); + --color-btn-@{item}-selected-text: @base; + --color-btn-@{item}-selected-bg: lighten(@color, 10%); + --color-btn-@{item}-selected-border: lighten(@color, 10%); - --color-btn-@{name}-disabled-text: @crust; - --color-btn-@{name}-disabled-bg: fadeout(@color, 60%); + --color-btn-@{item}-disabled-text: @crust; + --color-btn-@{item}-disabled-bg: fadeout(@color, 60%); } - --color-btn-@{name}-hover-icon: @base; + --color-btn-@{item}-hover-icon: @base; /* set these to transparent for the looks */ - --color-btn-@{name}-border: transparent; - --color-btn-@{name}-shadow: 0 0 transparent; - --color-btn-@{name}-inset-shadow: 0 0 transparent; - --color-btn-@{name}-selected-shadow: 0 0 transparent; - --color-btn-@{name}-disabled-border: transparent; + --color-btn-@{item}-border: transparent; + --color-btn-@{item}-shadow: 0 0 transparent; + --color-btn-@{item}-inset-shadow: 0 0 transparent; + --color-btn-@{item}-selected-shadow: 0 0 transparent; + --color-btn-@{item}-disabled-border: transparent; } #catppuccin(@lookup, @accent) { diff --git a/styles/hacker-news/catppuccin.user.css b/styles/hacker-news/catppuccin.user.css index 22547bdef7..2249db942b 100644 --- a/styles/hacker-news/catppuccin.user.css +++ b/styles/hacker-news/catppuccin.user.css @@ -1,5 +1,5 @@ /* ==UserStyle== -@name HackerNews Catppuccin +@name Hacker News Catppuccin @namespace github.com/catppuccin/userstyles/styles/hacker-news @homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/hacker-news @version 0.1.1 diff --git a/styles/hoppscotch/catppuccin.user.css b/styles/hoppscotch/catppuccin.user.css index 1f5a37da23..1436701d90 100644 --- a/styles/hoppscotch/catppuccin.user.css +++ b/styles/hoppscotch/catppuccin.user.css @@ -1,5 +1,5 @@ /* ==UserStyle== -@name Hoppscotch.io Catppuccin +@name Hoppscotch Catppuccin @namespace github.com/catppuccin/userstyles/styles/hoppscotch @homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/hoppscotch @version 1.0.0 diff --git a/styles/lichess/catppuccin.user.css b/styles/lichess/catppuccin.user.css index fcdf4509f9..0abb364fc7 100644 --- a/styles/lichess/catppuccin.user.css +++ b/styles/lichess/catppuccin.user.css @@ -1,5 +1,5 @@ /* ==UserStyle== -@name Lichess Catppuccin +@name lichess Catppuccin @namespace github.com/catppuccin/userstyles/styles/lichess @homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/lichess @version 0.0.1 diff --git a/styles/reddit/catppuccin.user.css b/styles/reddit/catppuccin.user.css index def27528af..3815dc78a4 100644 --- a/styles/reddit/catppuccin.user.css +++ b/styles/reddit/catppuccin.user.css @@ -1133,10 +1133,6 @@ .snoo-cls-11 { fill: @sky; } - - .snoo-cls-11 { - fill: @sky; - } } } diff --git a/styles/whatsapp-web/catppuccin.user.css b/styles/whatsapp-web/catppuccin.user.css index 9587e349e8..ca4ea07db4 100644 --- a/styles/whatsapp-web/catppuccin.user.css +++ b/styles/whatsapp-web/catppuccin.user.css @@ -1,5 +1,5 @@ /* ==UserStyle== -@name WhatsApp Web Catppuccin +@name WhatsApp Web Catppuccin @namespace github.com/catppuccin/userstyles/styles/whatsapp-web @homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/whatsapp-web @version 0.0.4 diff --git a/styles/wikiwand/catppuccin.user.css b/styles/wikiwand/catppuccin.user.css index 5a8e6cf898..a2e7fee7f1 100644 --- a/styles/wikiwand/catppuccin.user.css +++ b/styles/wikiwand/catppuccin.user.css @@ -1,5 +1,5 @@ /* ==UserStyle== -@name Wikiwand Catppuccin +@name WikiWand Catppuccin @namespace github.com/catppuccin/userstyles/styles/wikiwand @homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/wikiwand @version 1.2.0