generated from ubiquity-os/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f055856
Showing
43 changed files
with
7,763 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", | ||
"version": "0.2", | ||
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "./src/adapters/supabase/**/**.ts"], | ||
"useGitignore": true, | ||
"language": "en", | ||
"words": ["Nektos", "dataurl", "devpool", "outdir", "servedir", "Supabase", "SUPABASE", "typebox", "ubiquibot", "Smee"], | ||
"dictionaries": ["typescript", "node", "software-terms"], | ||
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"], | ||
"ignoreRegExpList": ["[0-9a-fA-F]{6}"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MY_SECRET="MY_SECRET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MY_SECRET="MY_SECRET" |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { KnipConfig } from "knip"; | ||
|
||
const config: KnipConfig = { | ||
entry: ["build/index.ts"], | ||
project: ["src/**/*.ts"], | ||
ignore: ["src/types/config.ts", "**/__mocks__/**", "**/__fixtures__/**"], | ||
ignoreExportsUsedInFile: true, | ||
// eslint can also be safely ignored as per the docs: https://knip.dev/guides/handling-issues#eslint--jest | ||
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "@mswjs/data"], | ||
eslint: true, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Resolves # | ||
|
||
<!-- | ||
- You must link the issue number e.g. "Resolves #1234" | ||
- Please do not replace the keyword "Resolves" https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: "the name of the plugin" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
stateId: | ||
description: "State Id" | ||
eventName: | ||
description: "Event Name" | ||
eventPayload: | ||
description: "Event Payload" | ||
settings: | ||
description: "Settings" | ||
authToken: | ||
description: "Auth Token" | ||
ref: | ||
description: "Ref" | ||
|
||
jobs: | ||
compute: | ||
name: "plugin name" | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
env: | ||
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.10.0" | ||
|
||
- name: install dependencies | ||
run: yarn | ||
|
||
- name: execute directive | ||
run: npx tsx ./src/main.ts | ||
id: plugin-name | ||
env: | ||
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Conventional Commits | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
conventional-commits: | ||
name: Conventional Commits | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ubiquity/action-conventional-commits@master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Spell Check | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
spellcheck: | ||
name: Check for spelling errors | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.10.0" | ||
|
||
- name: Install cspell | ||
run: yarn add cspell | ||
|
||
- name: Run cspell | ||
run: yarn format:cspell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Run Jest testing suite | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
env: | ||
NODE_ENV: "test" | ||
|
||
jobs: | ||
testing: | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.10.0" | ||
|
||
- uses: actions/checkout@master | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Jest With Coverage | ||
run: yarn install --immutable --immutable-cache --check-cache && yarn test | ||
|
||
- name: Add Jest Report to Summary | ||
if: always() | ||
run: echo "$(cat test-dashboard.md)" >> $GITHUB_STEP_SUMMARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Knip-reporter | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Knip"] | ||
types: | ||
- completed | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
knip-reporter: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion != 'success' }} | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: knip-results | ||
run-id: ${{ github.event.workflow_run.id }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Read pr number | ||
id: pr-number | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./pr-number.txt | ||
trim: true | ||
|
||
- name: Report knip results to pull request | ||
uses: gitcoindev/knip-reporter@main | ||
with: | ||
verbose: true | ||
comment_id: ${{ github.workflow }}-reporter | ||
command_script_name: knip-ci | ||
annotations: true | ||
ignore_results: false | ||
json_input: true | ||
json_input_file_name: knip-results.json | ||
pull_request_number: ${{ steps.pr-number.outputs.content }} | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Knip | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
run-knip: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.10.0 | ||
|
||
- name: Install toolchain | ||
run: yarn install | ||
|
||
- name: Store PR number | ||
run: echo ${{ github.event.number }} > pr-number.txt | ||
|
||
- name: Run Knip | ||
run: yarn knip || yarn knip --reporter json > knip-results.json | ||
|
||
- name: Upload knip result | ||
if: failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: knip-results | ||
path: | | ||
knip-results.json | ||
pr-number.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: release-please | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: googleapis/release-please-action@v4 | ||
with: | ||
release-type: simple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# macOS | ||
.DS_Store | ||
# node | ||
node_modules | ||
# yarn2 | ||
.yarn | ||
.pnp.cjs | ||
.pnp.loader.mjs | ||
.env | ||
.env.dev | ||
.dev.vars | ||
static/dist | ||
coverage | ||
junit.xml | ||
cypress/screenshots | ||
script.ts | ||
.wrangler | ||
test-dashboard.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn commitlint --edit "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v20.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": false, | ||
"printWidth": 160, | ||
"htmlWhitespaceSensitivity": "strict", | ||
"plugins": [], | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodeLinker: node-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# `@ubiquibot/plugin-template` | ||
|
||
## Prerequisites | ||
|
||
- A good understanding of how the [kernel](https://github.com/ubiquity/ubiquibot-kernel) works and how to interact with it. | ||
- A basic understanding of the Ubiquibot configuration and how to define your plugin's settings. | ||
|
||
## Getting Started | ||
|
||
1. Create a new repository using this template. | ||
2. Clone the repository to your local machine. | ||
3. Install the dependencies preferably using `yarn` or `bun`. | ||
|
||
## Creating a new plugin | ||
|
||
- If your plugin is to be used as a slash command which should have faster response times as opposed to longer running GitHub action tasks, you should use the `worker` type. | ||
|
||
1. Ensure you understand and have setup the [kernel](https://github.com/ubiquity/ubiquibot-kernel). | ||
2. Update [compute.yml](./.github/workflows/compute.yml) with your plugin's name and update the `id`. | ||
3. Update [context.ts](./src/types/context.ts) with the events that your plugin will fire on. | ||
4. Update [plugin-inputs.ts](./src/types/plugin-inputs.ts) to match the `with:` settings in your org or repo level configuration. | ||
|
||
- Your plugin config should look similar to this: | ||
|
||
```yml | ||
- plugin: <plugin-org/owner>/<plugin-repo-name>:compute.yml@development | ||
name: plugin-name | ||
id: plugin-name-command | ||
description: "Plugin description" # small description of what the plugin does | ||
command: "<regex for command>" # if you are creating a plugin with a slash command | ||
example: "<example usage>" # how to invoke the slash command | ||
with: # these are the example settings, the kernel passes these to the plugin. | ||
disabledCommands: [] | ||
timers: | ||
reviewDelayTolerance: 86000 | ||
taskStaleTimeoutDuration: 2580000 | ||
miscellaneous: | ||
maxConcurrentTasks: 3 | ||
labels: | ||
time: [] | ||
priority: [] | ||
``` | ||
###### At this stage, your plugin will fire on your defined events with the required settings passed in from the kernel. You can now start writing your plugin's logic. | ||
5. Start building your plugin by adding your logic to the [plugin.ts](./src/plugin.ts) file. | ||
## Testing a plugin | ||
### Worker Plugins | ||
- `yarn/bun worker` - to run the worker locally. | ||
- To trigger the worker, `POST` requests to http://localhost:4000/ with an event payload similar to: | ||
|
||
```ts | ||
await fetch("http://localhost:4000/", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
stateId: "", | ||
eventName: "", | ||
eventPayload: "", | ||
settings: "", | ||
ref: "", | ||
authToken: "", | ||
}), | ||
}); | ||
``` | ||
|
||
A full example can be found [here](https://github.com/ubiquibot/assistive-pricing/blob/623ea3f950f04842f2d003bda3fc7b7684e41378/tests/http/request.http). | ||
|
||
### Action Plugins | ||
|
||
- Ensure the kernel is running and listening for events. | ||
- Fire an event in/to the repo where the kernel is installed. This can be done in a number of ways, the easiest being via the GitHub UI or using the GitHub API, such as posting a comment, opening an issue, etc in the org/repo where the kernel is installed. | ||
- The kernel will process the event and dispatch it using the settings defined in your `.ubiquibot-config.yml`. | ||
- The `compute.yml` workflow will run and execute your plugin's logic. | ||
- You can view the logs in the Actions tab of your repo. | ||
|
||
[Nektos Act](https://github.com/nektos/act) - a tool for running GitHub Actions locally. | ||
|
||
## More information | ||
|
||
- [Full Ubiquibot Configuration](https://github.com/ubiquity/ubiquibot/blob/0fde7551585499b1e0618ec8ea5e826f11271c9c/src/types/configuration-types.ts#L62) - helpful for defining your plugin's settings as they are strongly typed and will be validated by the kernel. | ||
- [Ubiquibot V1](https://github.com/ubiquity/ubiquibot) - helpful for porting V1 functionality to V2, helper/utility functions, types, etc. Everything is based on the V1 codebase but with a more modular approach. When using V1 code, keep in mind that most all code will need refactored to work with the new V2 architecture. | ||
|
||
## Examples | ||
|
||
- [Start/Stop Slash Command](https://github.com/ubq-testing/start-stop-module) - simple | ||
- [Assistive Pricing Plugin](https://github.com/ubiquibot/assistive-pricing) - complex | ||
- [Conversation Rewards](https://github.com/ubiquibot/conversation-rewards) - really complex |
Oops, something went wrong.