feat(import-styles): init (#399)
Co-authored-by: uncenter <[email protected]> Co-authored-by: nekowinston <[email protected]>
This commit is contained in:
6 files changed
+112
-30
No files matched your search
@@ -0,0 +1,50 @@
|
||||
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
|
||||
@@ -1,23 +0,0 @@
|
||||
name: Lint
|
||||
|
||||
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
|
||||
@@ -1,5 +1,6 @@
|
||||
deno_cache/
|
||||
node_modules/
|
||||
dist/
|
||||
.DS_Store
|
||||
.idea
|
||||
.vscode
|
||||
@@ -40,16 +40,25 @@ 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.
|
||||
- [Firefox](https://addons.mozilla.org/en-GB/firefox/addon/styl-us/)
|
||||
- [Chrome](https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne)
|
||||
|
||||
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:
|
||||
### All Userstyles
|
||||
|
||||
1. Download [the Stylus export](https://github.com/catppuccin/userstyles/releases/all-userstyles-export).
|
||||
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!
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
},
|
||||
"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",
|
||||
|
||||
@@ -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));
|
||||
Reference in new issue
Block a user