Skip to content

Commit

Permalink
Merge branch 'main' into ci/gen-import
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses authored Dec 14, 2023
2 parents 0204a1f + 730ac8b commit 442c37e
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
description: Libreddit
color: '#f5a97f'
- name: lichess
description: lichess
description: Lichess
color: '#7dc4e4'
- name: linkedin
description: LinkedIn
Expand Down Expand Up @@ -156,7 +156,7 @@
description: WhatsApp Web
color: '#8aadf4'
- name: wikiwand
description: WikiWand
description: Wikiwand
color: '#8aadf4'
- name: youtube
description: YouTube
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ See [CONTRIBUTING.md](docs/CONTRIBUTING.md).
- [Stylus](styles/stylus)
- [Syncthing](styles/syncthing)
- [Tuta](styles/tuta)
- [WikiWand](styles/wikiwand)
- [Wikiwand](styles/wikiwand)

</details>
<details open>
Expand Down Expand Up @@ -159,7 +159,7 @@ See [CONTRIBUTING.md](docs/CONTRIBUTING.md).
- [Advent Of Code](styles/advent-of-code)
- [bStats](styles/bstats)
- [Chess.com](styles/chess.com)
- [lichess](styles/lichess)
- [Lichess](styles/lichess)
- [Modrinth](styles/modrinth)
- [Planet Minecraft](styles/planet-minecraft)

Expand Down
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@actions/core": "npm:@actions/[email protected]",
"@octokit/rest": "npm:@octokit/[email protected]",
"ajv": "npm:[email protected]",
"type-fest/": "https://esm.sh/v135/[email protected]/",
"handlebars": "npm:[email protected]",
"less": "npm:[email protected]",
"usercss-meta": "npm:[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
21 changes: 17 additions & 4 deletions scripts/lint/metadata.ts
Original file line number Diff line number Diff line change
@@ -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, {
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 4 additions & 10 deletions scripts/sync-maintainers/main.ts
Original file line number Diff line number Diff line change
@@ -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<UserstylesSchema>(
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 = [
Expand Down
6 changes: 3 additions & 3 deletions scripts/userstyles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ userstyles:
current-maintainers: [*isabelroses]
past-maintainers: [*andreasgrafen]
lichess:
name: lichess
name: Lichess
category: game
color: sapphire
readme:
usage: "Switch to a default lichess light/dark theme via **Username** > **Background** for the best experience!"
usage: "Switch to a default Lichess light/dark theme via **Username** > **Background** for the best experience!"
app-link: "https://lichess.org/"
current-maintainers: [*coopw1]
linkedin:
Expand Down Expand Up @@ -495,7 +495,7 @@ userstyles:
app-link: "https://web.whatsapp.com"
current-maintainers: [*francorav]
wikiwand:
name: WikiWand
name: Wikiwand
category: productivity
icon: wikipedia
readme:
Expand Down
25 changes: 25 additions & 0 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,3 +25,23 @@ export const validateYaml = <T>(
return resolve(data);
});
};

/**
* Utility function that calls {@link validateYaml} on the userstyles.yml file.
* Fails when data.userstyles is undefined.
*/
export const getUserstylesData = (): Promise<Userstyles> => {
return new Promise((resolve, reject) => {
validateYaml<UserstylesSchema>(
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<UserstylesSchema, "userstyles" | "collaborators">;
2 changes: 1 addition & 1 deletion styles/anilist/catppuccin.user.css
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion styles/hacker-news/catppuccin.user.css
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion styles/hoppscotch/catppuccin.user.css
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions styles/lichess/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<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"/>
Catppuccin for <a href="https://lichess.org/">lichess</a>
Catppuccin for <a href="https://lichess.org/">Lichess</a>
<img src="https://raw.githubusercontent.com/catppuccin/catppuccin/main/assets/misc/transparent.png" height="30" width="0px"/>
</h3>

Expand Down Expand Up @@ -37,7 +37,7 @@
</details>

## Usage
Switch to a default lichess light/dark theme via **Username** > **Background** for the best experience!
Switch to a default Lichess light/dark theme via **Username** > **Background** for the best experience!


## 💝 Current Maintainer
Expand Down
4 changes: 0 additions & 4 deletions styles/reddit/catppuccin.user.css
Original file line number Diff line number Diff line change
Expand Up @@ -1133,10 +1133,6 @@
.snoo-cls-11 {
fill: @sky;
}

.snoo-cls-11 {
fill: @sky;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion styles/whatsapp-web/catppuccin.user.css
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion styles/wikiwand/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<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"/>
Catppuccin for <a href="https://www.wikiwand.com">WikiWand</a>
Catppuccin for <a href="https://www.wikiwand.com">Wikiwand</a>
<img src="https://raw.githubusercontent.com/catppuccin/catppuccin/main/assets/misc/transparent.png" height="30" width="0px"/>
</h3>

Expand Down

0 comments on commit 442c37e

Please sign in to comment.