diff --git a/.github/workflows/lint-build.yml b/.github/workflows/lint-build.yml new file mode 100644 index 00000000..b01880f9 --- /dev/null +++ b/.github/workflows/lint-build.yml @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index be023e16..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -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 diff --git a/.gitignore b/.gitignore index 8d408b04..5d7d9d3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ deno_cache/ node_modules/ +dist/ .DS_Store .idea .vscode diff --git a/README.md b/README.md index df3619da..bd5ac48d 100644 --- a/README.md +++ b/README.md @@ -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//catppuccin.user.css` - Replacing `` with the name of the userstyle. -4. Enjoy! +3. Enjoy!   diff --git a/deno.json b/deno.json index 0fcddb2f..94d27f30 100644 --- a/deno.json +++ b/deno.json @@ -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", diff --git a/scripts/import-styles/main.ts b/scripts/import-styles/main.ts new file mode 100644 index 00000000..35310ccf --- /dev/null +++ b/scripts/import-styles/main.ts @@ -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[] = [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));