Skip to content

Commit

Permalink
Merge branch 'main' into docs/needs-maintainer
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoudham authored Dec 17, 2023
2 parents 7cde0ac + af364af commit f3fa186
Show file tree
Hide file tree
Showing 69 changed files with 499 additions and 330 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
52 changes: 52 additions & 0 deletions .github/workflows/lint-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Lint & Build

on:
workflow_dispatch:
pull_request:
push:
branches: [main]

jobs:
lint:
name: Lint Userstyles
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Deno
uses: nekowinston/setup-deno@main
with:
deno-version: v1.x

- name: Run Lint
run: deno task lint

build:
name: Generate Stylus Export
runs-on: ubuntu-latest
needs: lint
if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' }}
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write

steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.USERSTYLES_TOKEN }}
ref: ${{ github.ref }}

- name: Setup Deno
uses: nekowinston/setup-deno@main
with:
deno-version: v1.x

- name: Generate import file
run: deno task ci:generate-import

- name: Upload Release Artifacts
run: gh release upload --clobber all-userstyles-export ./dist/import.json
env:
GH_TOKEN: ${{ github.token }}
23 changes: 0 additions & 23 deletions .github/workflows/lint.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
deno_cache/
node_modules/
dist/
.DS_Store
.idea
.vscode
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,26 @@ giving it a unique and appealing aesthetic in line with Catppuccin's color palet

## 🖥️ Install

To install these userstyles:
Install [Stylus](https://github.com/openstyles/stylus) for your chosen browser.

1. Install [Stylus](https://github.com/openstyles/stylus).
- [Firefox](https://addons.mozilla.org/en-GB/firefox/addon/styl-us/)/[Chrome](https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne)
extension.
2. Enable CSP Patching from `Stylus Settings` > `Advanced`.
3. Install the theme:
- [Firefox](https://addons.mozilla.org/en-GB/firefox/addon/styl-us/)
- [Chrome](https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne)

### All Userstyles

1. Download [the Stylus export](https://github.com/catppuccin/userstyles/releases/download/all-userstyles-export/import.json).
2. Open the Stylus "manage" page.
3. Locate backup (on the left bar) and select import.
- Select the downloaded file.
4. Enjoy!

### Individual Userstyles

1. Enable CSP Patching from `Stylus Settings` > `Advanced`.
2. Install the theme:
- `https://github.com/catppuccin/userstyles/raw/main/styles/<name>/catppuccin.user.css`
- Replacing `<name>` with the name of the userstyle.
4. Enjoy!
3. Enjoy!

&nbsp;

Expand Down Expand Up @@ -114,7 +124,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 @@ -150,7 +160,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
2 changes: 2 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"@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]"
},
"tasks": {
"ci:generate": "deno run -A ./scripts/generate/main.ts",
"ci:generate-import": "deno run -A ./scripts/import-styles/main.ts",
"ci:sync-maintainers": "deno run -A ./scripts/sync-maintainers/main.ts",
"lint": "deno run -A ./scripts/lint/main.ts",
"lint:fix": "deno task lint --fix",
Expand Down
44 changes: 44 additions & 0 deletions scripts/import-styles/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env -S deno run -A
import usercssMeta from "usercss-meta";
import { ensureDir } from "std/fs/mod.ts";
import { walk } from "std/fs/walk.ts";
import { join } from "std/path/mod.ts";

import { REPO_ROOT } from "@/deps.ts";

const stylesheets = walk(join(REPO_ROOT, "styles"), {
includeFiles: true,
includeDirs: false,
includeSymlinks: false,
match: [/\.user.css$/],
});

// Recommended settings.
const settings = {
settings: {
updateInterval: 24,
updateOnlyEnabled: true,
patchCsp: true,
},
};

const data: Record<string, unknown>[] = [settings];

for await (const entry of stylesheets) {
const content = await Deno.readTextFile(entry.path);
const { metadata } = usercssMeta.parse(content);

data.push({
enabled: true,
name: metadata.name,
description: metadata.description,
author: metadata.author,
url: metadata.url,
updateUrl: metadata.updateURL,
usercssData: metadata,
sourceCode: content,
});
}

ensureDir("dist");
Deno.writeTextFile("dist/import.json", JSON.stringify(data));
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
22 changes: 18 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,14 +69,26 @@ 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",
preprocessor: "less",
homepageURL: `${prefix}/tree/main/styles/${repo}`,
updateURL: `${prefix}/raw/main/styles/${repo}/catppuccin.user.css`,
supportURL: `${prefix}/issues?q=is%3Aopen+is%3Aissue+label%3A${repo}`,
};
};
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 @@ -300,11 +300,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 @@ -499,7 +499,7 @@ userstyles:
current-maintainers: []
past-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">;
1 change: 1 addition & 0 deletions styles/advent-of-code/catppuccin.user.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/advent-of-code
@version 0.0.1
@updateURL https://github.com/catppuccin/userstyles/raw/main/styles/advent-of-code/catppuccin.user.css
@supportURL https://github.com/catppuccin/userstyles/issues?q=is%3Aopen+is%3Aissue+label%3Aadvent-of-code
@description Soothing pastel theme for Advent Of Code
@author Catppuccin
@license MIT
Expand Down
17 changes: 9 additions & 8 deletions styles/anilist/catppuccin.user.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* ==UserStyle==
@name AniList Catppuccin
@namespace github.com/catppuccin/userstyles/styles/anilist
@homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/anilist
@version 2.1.1
@description Soothing pastel theme for AniList
@author Catppuccin
@updateURL https://github.com/catppuccin/userstyles/raw/main/styles/anilist/catppuccin.user.css
@license MIT
@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
@description Soothing pastel theme for AniList
@author Catppuccin
@updateURL https://github.com/catppuccin/userstyles/raw/main/styles/anilist/catppuccin.user.css
@supportURL https://github.com/catppuccin/userstyles/issues?q=is%3Aopen+is%3Aissue+label%3Aanilist
@license MIT
@preprocessor less
@var select lightFlavor "Light Flavor" ["latte:Latte*", "frappe:Frappé", "macchiato:Macchiato", "mocha:Mocha"]
Expand Down
1 change: 1 addition & 0 deletions styles/boringproxy/catppuccin.user.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@homepageURL https://github.com/catppuccin/userstyles/tree/main/styles/boringproxy
@version 0.0.1
@updateURL https://github.com/catppuccin/userstyles/raw/main/styles/boringproxy/catppuccin.user.css
@supportURL https://github.com/catppuccin/userstyles/issues?q=is%3Aopen+is%3Aissue+label%3Aboringproxy
@description Soothing pastel theme for boringproxy
@author Catppuccin
@license MIT
Expand Down
Loading

0 comments on commit f3fa186

Please sign in to comment.