Theme template woo! [WIP]

This commit is contained in:
Albert Portnoy 2022-12-16 12:29:34 -06:00
commit 512dcb1dd5
No known key found for this signature in database
13 changed files with 2493 additions and 0 deletions

33
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,33 @@
name: Lint
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Install Node.js dependencies
run: pnpm install
- name: Run linters
run: pnpm run lint

37
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,37 @@
name: Release
on:
push:
tags:
- "v*"
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Install Node.js dependencies
run: pnpm install
- name: Build TypeScript and bundle into asar
run: pnpm run build-and-bundle
- uses: ncipollo/release-action@v1
with:
artifacts: "*.asar"
makeLatest: true

107
.gitignore vendored Normal file
View file

@ -0,0 +1,107 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
.parcel-cache
/*.asar

14
.prettierrc.json Normal file
View file

@ -0,0 +1,14 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "always",
"proseWrap": "always"
}

3
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"recommendations": ["EditorConfig.EditorConfig", "esbenp.prettier-vscode"]
}

4
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,4 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}

76
README.md Normal file
View file

@ -0,0 +1,76 @@
# Replugged plugin template
[Use this template](https://github.com/replugged-org/plugin-template/generate)
## Prerequisites
- NodeJS
- pnpm: `npm i -g pnpm`
- [Replugged](https://github.com/replugged-org/replugged#installation)
## Install
1. [Create a copy of this template](https://github.com/replugged-org/plugin-template/generate)
2. Clone your new repository and cd into it
3. Install dependencies: `pnpm i`
4. Build the plugin: `pnpm run build`
5. Reload Discord to load the plugin
The unmodified plugin will log "Typing prevented" in the console when you start typing in any
channel.
## Development
The code must be rebuilt after every change. You can use `pnpm run watch` to automatically rebuild
the plugin when you save a file.
Building using the script above will automatically install the updated version of the plugin in
Replugged. You can find the plugin folder directories for your OS
[here](https://github.com/replugged-org/replugged#installing-plugins-and-themes).
If you don't want to install the updated version, set the `NO_INSTALL` environment variable with any
value: `NO_INSTALL=true pnpm run build`.
You can format the code by running `pnpm run lint:fix`. The repository includes VSCode settings to
automatically format on save.
API docs coming soon(tm)
## Distribution
For plugin distribution, Replugged uses bundled `.asar` files. Bundled plugins can be installed to
the same plugin folder as listed above.
This repository includes a GitHub workflow to compile and publish a release with the asar file. To
trigger it, create a tag with the version number preceded by a `v` (e.g. `v1.0.0`) and push it to
GitHub:
```sh
git tag v1.0.0
git push --tags
```
The Replugged updater (coming soon™) will automatically check for updates on the repository
specified in the manifest. Make sure to update it to point to the correct repository!
You can manually compile the asar file with `pnpm run build-and-bundle`.
## Troubleshooting
### Make sure Replugged is installed and running.
Open Discord settings and make sure the Replugged tab is there. If not,
[follow these instructions](https://github.com/replugged-org/replugged#installation) to install
Replugged.
### Make sure the plugin is installed.
Check the [plugin folder](https://github.com/replugged-org/replugged#installing-plugins-and-themes)
for your OS and make sure the plugin is there. If not, make sure you have built the plugin and that
the `NO_INSTALL` environment variable is not set.
You can run `replugged.plugins.list().then(console.log)` in the console to see a list of plugins in
the plugin folder.
### Make sure the plugin is running.
Check the console for a message saying `[Replugged:Plugin:Plugin Template] Plugin started`. If you
don't see it, try reloading Discord. If that doesn't work, check for any errors in the console.

214
main.css Normal file
View file

@ -0,0 +1,214 @@
@font-face {
font-family: Whitney;
font-style: normal;
font-weight: 300;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/46933da896ba96126074286056614542.woff2)
format("woff2");
}
@font-face {
font-family: Whitney;
font-style: italic;
font-weight: 300;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/1651ce6325c0da043476ace0bec3971b.woff2)
format("woff2");
}
@font-face {
font-family: Whitney;
font-style: normal;
font-weight: 400;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/24bda95d153a319704c33329f3ab84bb.woff2)
format("woff2");
}
@font-face {
font-family: Whitney;
font-style: italic;
font-weight: 400;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/7f18f1d5ab6ded7cf71bbc1f907ee3d4.woff2)
format("woff2");
}
@font-face {
font-family: Whitney;
font-style: normal;
font-weight: 500;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/cf4a8a10bbdf9b775fad41e0b9921c84.woff2)
format("woff2");
}
@font-face {
font-family: Whitney;
font-style: italic;
font-weight: 500;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/9cfa747e897c772d25efd8e4a42a005e.woff2)
format("woff2");
}
@font-face {
font-family: Whitney;
font-style: normal;
font-weight: 600;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/f9e7047f6447547781512ec4b977b2ab.woff2)
format("woff2");
}
@font-face {
font-family: Whitney;
font-style: italic;
font-weight: 600;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/21070f52a8a6a61edef9785eaf303fb8.woff2)
format("woff2");
}
@font-face {
font-family: Whitney;
font-style: normal;
font-weight: 700;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/f9c8fcfa7dcc5d6a291a6ebbe3bb847e.woff2)
format("woff2");
}
@font-face {
font-family: Whitney;
font-style: italic;
font-weight: 700;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/5e1649183589023fb24667a369af585d.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Normal;
font-style: normal;
font-weight: 300;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/ab688947d482808a0b3347f84ebb17a9.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Normal;
font-style: italic;
font-weight: 300;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/0635f419b122d24f9f60ac4d1066cbc6.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Normal;
font-style: normal;
font-weight: 400;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/91dcabd038a2e07ea6fbe7ddb625ecfb.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Normal;
font-style: italic;
font-weight: 400;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/ea053183733605b24806f222b067b1e1.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Normal;
font-style: normal;
font-weight: 500;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/9491a199bd318f1fc38711fb5067f401.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Normal;
font-style: italic;
font-weight: 500;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/f0cf30536a7fa447f0c45fdb3b2a6f28.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Normal;
font-style: normal;
font-weight: 700;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/7d66dfcf8e39f27f163fba8d79577fd8.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Normal;
font-style: italic;
font-weight: 700;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/9a07cb5ae387a52309b7198543ae5e02.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Nord;
font-style: normal;
font-weight: 300;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/5e6f352adb4a6b55ed230f2f91769156.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Nord;
font-style: italic;
font-weight: 300;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/30b475dcfa1e8b74d815946e4c18ee09.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Nord;
font-style: normal;
font-weight: 400;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/1ace668db419a5014cf75bc116321af3.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Nord;
font-style: italic;
font-weight: 400;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/50510b66614a2f395530c61b7c9b6827.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Nord;
font-style: normal;
font-weight: 500;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/9e94673570e295b6fb5d4456c4211015.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Nord;
font-style: italic;
font-weight: 500;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/6603a2fb4d2bc997e023972a51938144.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Nord;
font-style: normal;
font-weight: 700;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/87c79174865938aedf188b7344fb0428.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Nord;
font-style: italic;
font-weight: 700;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/d93311938f51e8608a5d5cb2ea975157.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Nord;
font-style: normal;
font-weight: 800;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/bc5af8e71e27d363e2eeac75c9628922.woff2)
format("woff2");
}
@font-face {
font-family: ABC Ginto Nord;
font-style: italic;
font-weight: 800;
src: url(https://cdn.jsdelivr.net/gh/Overimagine1/old-discord-font/fonts/dc407fd65057fce34a56bf7b6ebb0b9f.woff2)
format("woff2");
}
:root {
--font-primary: Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;
--font-display: "ABC Ginto Normal", "Helvetica Neue", Helvetica, Arial, sans-serif;
--font-headline: "ABC Ginto Nord", "Helvetica Neue", Helvetica, Arial, sans-serif;
--font-code: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter",
"DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco,
"Courier New", Courier, monospace;
--font-korean: Whitney, "Apple SD Gothic Neo", NanumBarunGothic, "\B9D1\C740 \ACE0\B515",
"Malgun Gothic", Gulim, 굴림, Dotum, 돋움, "Helvetica Neue", Helvetica, Arial, sans-serif;
--font-japanese: Whitney, "Hiragino Sans", "\30D2\30E9\30AE\30CE\89D2\30B4 ProN W3",
"Hiragino Kaku Gothic ProN", メイリオ, Meiryo, Osaka, "MS PGothic", "Helvetica Neue", Helvetica,
Arial, sans-serif;
--font-chinese-simplified: Whitney, "Microsoft YaHei New", 微软雅黑, "Microsoft Yahei",
"Microsoft JhengHei", 宋体, SimSun, "Helvetica Neue", Helvetica, Arial, sans-serif;
--font-chinese-traditional: Whitney, "Microsoft JhengHei", 微軟正黑體, "Microsoft JhengHei UI",
"Microsoft YaHei", 微軟雅黑, 宋体, SimSun, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

18
manifest.json Normal file
View file

@ -0,0 +1,18 @@
{
"id": "dev.replugged.ThemeTemplate",
"name": "Theme Template",
"description": "A theme template",
"author": {
"name": "replugged",
"discordID": "1000992611840049192",
"github": "replugged-org"
},
"version": "1.0.2",
"updater": {
"type": "github",
"id": "replugged-org/theme-template"
},
"license": "MIT",
"type": "replugged-theme",
"main": "main.css"
}

29
package.json Normal file
View file

@ -0,0 +1,29 @@
{
"name": "theme-template",
"version": "1.0.0",
"description": "A theme template",
"engines": {
"node": ">=14.0.0"
},
"scripts": {
"build": "tsx scripts/build.ts",
"watch": "tsx scripts/build.ts --watch",
"bundle": "tsx scripts/bundle.ts",
"build-and-bundle": "NO_INSTALL=true pnpm run build && pnpm run bundle",
"lint": "prettier ./src ./scripts --check",
"lint:fix": "prettier ./src ./scripts --write"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@electron/asar": "^3.2.1",
"@parcel/config-default": "^2.8.2",
"@parcel/core": "^2.8.2",
"@parcel/transformer-sass": "^2.8.2",
"@types/node": "^18.11.15",
"parcel": "^2.8.2",
"prettier": "^2.8.1",
"replugged": "4.0.0-beta0.16"
}
}

1863
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

87
scripts/build.ts Normal file
View file

@ -0,0 +1,87 @@
import { Parcel } from "@parcel/core";
import { cpSync, existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
import _manifest from "../manifest.json";
import { Theme } from "replugged/dist/types/addon";
import { join } from "path";
const manifest: Theme = _manifest;
const main = manifest.main || (existsSync("main.css") ? "main.css" : undefined);
const splash = manifest.splash || (existsSync("splash.css") ? "splash.css" : undefined);
const bundler = new Parcel({
entries: [main, splash].filter(Boolean) as string[],
defaultConfig: "@parcel/config-default",
});
const REPLUGGED_FOLDER_NAME = "replugged";
export const CONFIG_PATH = (() => {
switch (process.platform) {
case "win32":
return join(process.env.APPDATA || "", REPLUGGED_FOLDER_NAME);
case "darwin":
return join(process.env.HOME || "", "Library", "Application Support", REPLUGGED_FOLDER_NAME);
default:
if (process.env.XDG_CONFIG_HOME) {
return join(process.env.XDG_CONFIG_HOME, REPLUGGED_FOLDER_NAME);
}
return join(process.env.HOME || "", ".config", REPLUGGED_FOLDER_NAME);
}
})();
async function install() {
if (!process.env.NO_INSTALL) {
const dest = join(CONFIG_PATH, "themes", manifest.id);
if (existsSync(dest)) {
rmSync(dest, { recursive: true });
}
cpSync("dist", dest, { recursive: true });
console.log("Installed updated version");
}
}
async function build() {
try {
const { bundleGraph, buildTime } = await bundler.run();
let bundles = bundleGraph.getBundles();
console.log(`✨ Built ${bundles.length} bundles in ${buildTime}ms!`);
await install();
} catch (err) {
console.log(err.diagnostics);
}
}
async function watch() {
const subscription = await bundler.watch(async (err, event) => {
if (err) {
// fatal error
throw err;
}
if (!event) return;
if (event.type === "buildSuccess") {
let bundles = event.bundleGraph.getBundles();
console.log(`✨ Built ${bundles.length} bundles in ${event.buildTime}ms!`);
await install();
} else if (event.type === "buildFailure") {
console.log(event.diagnostics);
}
});
}
const shouldWatch = process.argv.includes("--watch");
if (shouldWatch) {
watch();
} else {
build();
}
manifest.main = main?.replace(/\.scss$/, ".css");
manifest.splash = splash?.replace(/\.scss$/, ".css");
if (!existsSync("dist")) {
mkdirSync("dist");
}
writeFileSync("dist/manifest.json", JSON.stringify(manifest));

8
scripts/bundle.ts Normal file
View file

@ -0,0 +1,8 @@
import asar from "@electron/asar";
import { readFileSync } from "fs";
import { Plugin } from "replugged/dist/types/addon";
const manifest = JSON.parse(readFileSync("manifest.json", "utf-8")) as Plugin;
const outputName = `${manifest.id}.asar`;
asar.createPackage("dist", outputName);