Initial commit
This commit is contained in:
commit
f7f29d2b04
9 changed files with 159 additions and 0 deletions
47
.github/workflows/deploy.yml
vendored
Normal file
47
.github/workflows/deploy.yml
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
name: Build and deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Prepare environment
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: "16"
|
||||||
|
|
||||||
|
- run: npm install --global pnpm
|
||||||
|
|
||||||
|
- name: Install deps
|
||||||
|
run: pnpm m i
|
||||||
|
|
||||||
|
- name: Build plugin(s)
|
||||||
|
run: node ./build.mjs
|
||||||
|
|
||||||
|
# Foolproof feature:
|
||||||
|
# - Copies over README so that the root of the deployed website shows it
|
||||||
|
# - Changes 404 page to README so that you don't get lost while clicking links
|
||||||
|
# If you remove this step then you should probably remove the enable_jekyll option in the next one
|
||||||
|
- name: Copy additional files
|
||||||
|
run: |
|
||||||
|
cp README.md dist/README.md
|
||||||
|
printf -- "---\npermalink: /404.html\n---\n" > dist/404.md
|
||||||
|
printf -- "> **Note:** You accessed a link that returned a 404, probably by clicking one of the plugin links. You're supposed to copy the link address and add it into Vendetta.\n\n" >> dist/404.md
|
||||||
|
cat README.md >> dist/404.md
|
||||||
|
|
||||||
|
# Documentation: https://github.com/peaceiris/actions-gh-pages
|
||||||
|
- name: Deploy to GitHub Pages
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_dir: ./dist
|
||||||
|
# Makes it so the md files in the previous step get processed by GitHub Pages
|
||||||
|
enable_jekyll: true
|
||||||
|
# This creates the CNAME file required to host GitHub Pages on a custom domain
|
||||||
|
# cname: example.com
|
||||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
pnpm-lock.yaml
|
||||||
|
yarn.lock
|
||||||
|
package-lock.json
|
||||||
7
README.md
Normal file
7
README.md
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Vendetta Plugins Template
|
||||||
|
This repo contains a template for creating [Vendetta](https://github.com/vendetta-mod/Vendetta) plugins.
|
||||||
|
|
||||||
|
# How to install?
|
||||||
|
Paste a plugin URL into the Plugins page of Vendetta, following a basic format of:
|
||||||
|
|
||||||
|
https://`YOUR_GITHUB_USERNAME`.github.io/`REPO_NAME`/`PLUGIN_NAME`
|
||||||
53
build.mjs
Normal file
53
build.mjs
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
import { rollup } from "rollup";
|
||||||
|
import { readFile, writeFile, readdir } from "fs/promises";
|
||||||
|
import { createHash } from "crypto";
|
||||||
|
import esbuild from "rollup-plugin-esbuild";
|
||||||
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
||||||
|
import commonjs from "@rollup/plugin-commonjs";
|
||||||
|
|
||||||
|
for (let plug of await readdir("./plugins")) {
|
||||||
|
const manifest = JSON.parse(await readFile(`./plugins/${plug}/manifest.json`));
|
||||||
|
const outName = manifest.main.split("/").reverse()[0];
|
||||||
|
const outPath = `./dist/${plug}/${outName}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const bundle = await rollup({
|
||||||
|
input: `./plugins/${plug}/${manifest.main}`,
|
||||||
|
onwarn: () => {},
|
||||||
|
plugins: [
|
||||||
|
nodeResolve(),
|
||||||
|
commonjs(),
|
||||||
|
esbuild({
|
||||||
|
target: "esnext",
|
||||||
|
minify: true,
|
||||||
|
})
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await bundle.write({
|
||||||
|
file: outPath,
|
||||||
|
globals(id) {
|
||||||
|
if (id.startsWith("@vendetta")) return id.substring(1).replace(/\//g, ".");
|
||||||
|
const map = {
|
||||||
|
react: "window.React",
|
||||||
|
};
|
||||||
|
|
||||||
|
return map[id] || null;
|
||||||
|
},
|
||||||
|
format: "iife",
|
||||||
|
compact: true,
|
||||||
|
exports: "named",
|
||||||
|
});
|
||||||
|
await bundle.close();
|
||||||
|
|
||||||
|
const toHash = await readFile(outPath);
|
||||||
|
manifest.hash = createHash("sha256").update(toHash).digest("hex");
|
||||||
|
manifest.main = outName;
|
||||||
|
await writeFile(`./dist/${plug}/manifest.json`, JSON.stringify(manifest));
|
||||||
|
|
||||||
|
console.log(`Successfully built ${manifest.name}!`);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to build plugin...", e);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
package.json
Normal file
12
package.json
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"build": "node build.mjs"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-commonjs": "^24.0.0",
|
||||||
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||||
|
"esbuild": "^0.16.14",
|
||||||
|
"rollup": "^3.9.1",
|
||||||
|
"rollup-plugin-esbuild": "^5.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
14
plugins/template/manifest.json
Normal file
14
plugins/template/manifest.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "Template Plugin",
|
||||||
|
"description": "A plugin for use as a template.",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "You!",
|
||||||
|
"id": "YOUR_ID_HERE"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "src/index.js",
|
||||||
|
"vendetta": {
|
||||||
|
"icon": "ic_badge_staff"
|
||||||
|
}
|
||||||
|
}
|
||||||
7
plugins/template/src/Settings.jsx
Normal file
7
plugins/template/src/Settings.jsx
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { FormText } from "@vendetta/ui/components/Forms";
|
||||||
|
|
||||||
|
export default () => (
|
||||||
|
<FormText>
|
||||||
|
Hello, world!
|
||||||
|
</FormText>
|
||||||
|
)
|
||||||
12
plugins/template/src/index.js
Normal file
12
plugins/template/src/index.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { logger } from "@vendetta";
|
||||||
|
import Settings from "./Settings";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
onLoad: () => {
|
||||||
|
logger.log("Hello world!");
|
||||||
|
},
|
||||||
|
onUnload: () => {
|
||||||
|
logger.log("Goodbye, world.");
|
||||||
|
},
|
||||||
|
settings: Settings,
|
||||||
|
}
|
||||||
2
pnpm-workspace.yaml
Normal file
2
pnpm-workspace.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
packages:
|
||||||
|
- plugins/*
|
||||||
Loading…
Add table
Reference in a new issue