Skip to content

Commit

Permalink
Merge branch 'main' into dummysheet
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchemmc authored Sep 21, 2023
2 parents 8a3b407 + 8120385 commit b12592a
Show file tree
Hide file tree
Showing 10 changed files with 757 additions and 5 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/submit-verification-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Submit Verification Request
on:
issue_comment:
types: [created, edited]
jobs:
submit:
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- name: Install Node
uses: actions/setup-node@v3
if: contains(github.event.comment.body, '/verify')
with:
node-version: 16
- uses: actions/github-script@v6
id: process-comment
with:
script: |
const body = context.payload.comment.body
return body
- uses: actions/checkout@v3
- name: Install Packages
run: yarn --cwd ./scripts install --frozen-lockfile
- name: Submit Request to Discord
run: node --no-warnings ./scripts/verify/index.js
env:
DISCORD_VERIFY_WEBHOOK: ${{ secrets.DISCORD_VERIFY_WEBHOOK }}
EXTENSION_KEY: ${{ steps.process-comment.outputs.result }}
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Verification has been submitted'
})
19 changes: 16 additions & 3 deletions .github/workflows/update-extension-store.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: Update Extention Store
on:
on:
push:
paths:
- "extensions.json"
branches:
- main
workflow_dispatch:
branches:
- main

jobs:
regenerate:
Expand Down Expand Up @@ -43,3 +41,18 @@ jobs:
run: yarn --cwd ./scripts run trigger
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Your extension is now available on the Extension Store! 🎉
You can now submit your extension for verification. To start the verification process respond to your pull request with the message `/verify <extension name>` where `<extension-name>` is the key used in the `extensions.json` file in your pull request.
Once this has been done a thread will be created on the [Owlbear Rodeo Discord](https://discord.gg/u5RYMkV98s) tracking the status of all the above guidelines.
Once the community has verified that all the guidelines have been passed the Owlbear Rodeo team will add the verified badge to your extension.`
})
7 changes: 7 additions & 0 deletions extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,12 @@
"rumble": "https://raw.githubusercontent.com/ManuelLovell/rumble/master/docs/store.md",
"ticker": "https://www.battle-system.com/owlbear/ticker-docs/store.md",
"witchdice": "https://witchdice.com/owlbear_ext/store.md",
"aoe-shapes": "https://owlbear-aoe.davidsev.co.uk/store.md",
"pdf-reader": "https://www.battle-system.com/owlbear/pdfd-docs/store.md",
"sit": "https://sit.manuelpoell.at/assets/store.md",
"marked": "https://www.battle-system.com/owlbear/marked-docs/store.md",
"hp-tracker": "https://raw.githubusercontent.com/kamejosh/owlbear-hp-tracker/master/docs/store.md",
"last-fable": "https://fabula-ultima-extension.onrender.com/store.md",
"ultimate-story": "https://fabula-ultima-character-extension.onrender.com/store.md",
"dummysheet": "https://www.dummysheet.com/store.md"
}
79 changes: 79 additions & 0 deletions scripts/__tests__/validation.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { expect, test } from "vitest";
import { validateManifest } from "../validation/manifest";

test("successfully validates valid manifest", () => {
const validManifest = {
title: "Example Extension Manifest",
description: "An example manifest for testing",
author: "Extension Tests",
image: "https://example.com/",
icon: "https://example.com/",
tags: ["combat", "tool", "automation"],
manifest: "https://example.com/manifest.json",
"learn-more": "[email protected]",
};

const expectedResult = [];

expect(validateManifest(validManifest)).toStrictEqual(expectedResult);
});

test("throws error on invalid tag", () => {
const invalidTagInManifest = {
title: "Example Extension Manifest",
description: "An example manifest for testing",
author: "Extension Tests",
image: "https://example.com/",
icon: "https://example.com/",
tags: ["combat", "tool", "automation", "built-by-owlbear"],
manifest: "https://example.com/manifest.json",
"learn-more": "[email protected]",
};

const expectedResult = ['"tags[3]" contains an excluded value'];

expect(validateManifest(invalidTagInManifest)).toStrictEqual(expectedResult);
});

test("should return all validation errors in one message", () => {
const mulitpleValidationIssues = {
description: "An example manifest for testing",
author: "Extension Tests",
icon: "example.com/",
tags: [],
manifest: "https://example.com/manifest.json",
};

const expectedResult = [
'"title" is required',
'"image" is required',
'"icon" failed custom validation because Invalid URL',
'"tags" must contain at least 1 items',
'"learn-more" is required',
];

expect(validateManifest(mulitpleValidationIssues)).toStrictEqual(
expectedResult
);
});

test("should return issue when learn-more is invalid", () => {
const learnMoreInvalidationIssue = {
title: "Example Extension Manifest",
description: "An example manifest for testing",
author: "Extension Tests",
image: "https://example.com/",
icon: "https://example.com/",
tags: ["combat", "tool", "automation"],
manifest: "https://example.com/manifest.json",
"learn-more": "learn-more.com",
};

const expectedResult = [
'"learn-more" does not match any of the allowed types',
];

expect(validateManifest(learnMoreInvalidationIssue)).toStrictEqual(
expectedResult
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@ export async function getExtensionDetails() {
return { id, data };
}
}

export async function getExtensionDetailsFromKey(key) {
const item = data[key];

const result = await fetch(item);

if (result.ok) {
const markdown = await result.text();
const data = matter(markdown)["data"];

return { key, data };
}
}
2 changes: 1 addition & 1 deletion scripts/discord-webhook/webhook.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetch from "node-fetch";

import { getExtensionDetails } from "./extensionDetails.js";
import { getExtensionDetails } from "../common/extensionDetails.js";

function createDiscordEmbed(id, title, description, url, image, author, tags) {
const embed = {
Expand Down
8 changes: 7 additions & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
"type": "module",
"license": "MIT",
"scripts": {
"test": "vitest",
"trigger": "node ./discord-webhook/index.js",
"deploy": "node ./extension-store-deploy/index.js"
"deploy": "node ./extension-store-deploy/index.js",
"verification": "node --no-warnings ./verify/index.js"
},
"dependencies": {
"fetch": "^1.1.0",
"gray-matter": "^4.0.3",
"joi": "^17.10.2",
"node-fetch": "^3.3.1"
},
"devDependencies": {
"vitest": "^0.34.4"
}
}
42 changes: 42 additions & 0 deletions scripts/verify/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import fetch from "node-fetch";
import { getExtensionDetailsFromKey } from "../common/extensionDetails.js";

function createDiscordVerificationPost(id, data) {
const text = `## Extension Verfication Request\n\n${data.title} would like to be verified.\n\nIt can be installed via this [store page](https://extensions.owlbear.rodeo/${id}).\n\nTo be verified the extension must meet these criteria:\n\n- Extension design uses accessible colors :art:\n- Extension design uses accessible font sizes :blue_book:\n- Extension is legible with Owlbear Rodeo’s light and dark theme :ghost:\n- Extension is fully functional on mobile devices (1) :mobile_phone:\n- Extension is fully functional across all major browsers (2) :computer:\n- Extension requires no other extensions to be installed :link: \n- Extension functions in a private browsing window or with cookies disabled :lock:\n- Extension makes proper use of the Owlbear Rodeo APIs (3) :jigsaw: \n- Extension functions in all configurations of an Owlbear Rodeo Room (4) :house:\n- Extension provides user support for queries, issues and requests :question:\n- Extension has no known bugs :bug: \n- Extension manifest is hosted on a custom domain controlled by the extension developer :pencil:\n\nNotes:\n\n1) This includes iPhone’s, Android devices as well as tablets such as an iPad.\n\n2) Major browsers include Chrome, Firefox and Safari\n\n3) For example the Scene API is only used to store data that shares the Scene lifecycle\n\n4) Valid configurations include a Room with a Scene open and no Scene open\n\nAlso note that the term “fully functional” above means all extension functionally works correctly whereas the term “functional” means the extension still functions but some features may not be available.\n\n### To help verify this extension react to this message with the criteria that are met! (i.e. react :bug: if it has no known bugs)`;

const post = {
thread_name: `${data.title} wants to be verified`,
content: text,
};

return post;
}

export async function sendDiscordWebhook(value) {
const values = value.replaceAll('"', "").split(" ");
if (values.length !== 2) {
console.log(values);
throw Error("invalid submission");
}

const key = values[1];
const { key: id, data } = await getExtensionDetailsFromKey(key);

const embed = createDiscordVerificationPost(id, data);

const response = await fetch(process.env.DISCORD_VERIFY_WEBHOOK, {
method: "POST",
body: JSON.stringify(embed),
headers: {
"Content-Type": "application/json",
},
});

if (response.ok) {
console.log("Success!!");
} else {
console.log(JSON.stringify(await response.text(), null, 2));
}
}

await sendDiscordWebhook(process.env.EXTENSION_KEY);
Loading

0 comments on commit b12592a

Please sign in to comment.