Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge development into main #1

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "./src/adapters/supabase/**/**.ts"],
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "**/*.http", "**/*.toml", "src/types/database.ts"],
"useGitignore": true,
"language": "en",
"words": ["Nektos", "dataurl", "devpool", "outdir", "servedir", "Supabase", "SUPABASE", "typebox", "ubiquibot", "Smee"],
Expand Down
3 changes: 2 additions & 1 deletion .dev.vars.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
MY_SECRET="MY_SECRET"
SUPABASE_URL=
SUPABASE_KEY=
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
MY_SECRET="MY_SECRET"
SUPABASE_URL=
SUPABASE_KEY=
2 changes: 1 addition & 1 deletion .github/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { KnipConfig } from "knip";
const config: KnipConfig = {
entry: ["build/index.ts"],
project: ["src/**/*.ts"],
ignore: ["src/types/config.ts", "**/__mocks__/**", "**/__fixtures__/**"],
ignore: ["**/__mocks__/**", "**/__fixtures__/**", "src/types/database.ts"],
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"],
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "the name of the plugin"
name: "command-wallet"

on:
workflow_dispatch:
Expand All @@ -18,7 +18,7 @@ on:

jobs:
compute:
name: "plugin name"
name: "command-wallet"
runs-on: ubuntu-latest
permissions: write-all
env:
Expand All @@ -38,7 +38,7 @@ jobs:

- name: execute directive
run: npx tsx ./src/main.ts
id: plugin-name
id: command-wallet
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ jobs:
name: Conventional Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ubiquity/action-conventional-commits@master
46 changes: 46 additions & 0 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Database

on:
push:
branches:
- main

env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}

jobs:
generate_types:
runs-on: ubuntu-latest
needs:
- run-migration
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.10.0"

- name: Generate Supabase Types
run: |
yarn install
yarn run "supabase:generate:remote"

- name: Commit and Push generated types
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add src/types/database.ts
if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then
git commit -m "chore: updated generated Supabase types" || echo "Lint-staged check failed"
git push origin main
else
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deploy to Cloudflare Pages

on:
workflow_dispatch:
push:
branches:
- main

jobs:
deploy-to-cloudflare:
name: Automatic Cloudflare Deploy
runs-on: ubuntu-22.04
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- uses: actions/checkout@v4
- uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: '3.61.0'
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
secrets: |
SUPABASE_URL
SUPABASE_KEY
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ coverage
junit.xml
cypress/screenshots
script.ts
.wrangler
.wrangler
http-client.private.env.json
47 changes: 17 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# `@ubiquibot/plugin-template`
# `@ubiquibot/command-wallet`

Helps users retrieving their wallet, or setting it to collect subsequent task rewards.

## Prerequisites

Expand All @@ -7,38 +9,23 @@

## 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.
1. Install the dependencies preferably using `yarn` or `bun`.
2. Copy `env.example` and `.dev.vars.example` to `.env` and `.dev.vars` respectively, and fill the variables
3. Generate Supabase types by running
```shell
yarn prebuild
```
4. Run the project with `yarn wrangler`

- Your plugin config should look similar to this:
## Example configuration

```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: []
- plugin: ubiquibot/command-wallet
name: command-wallet
id: command-wallet
description: "Helps users retrieving their wallet, or setting it to collect subsequent task rewards."
command: "/wallet"
example: "/wallet @user"
```

###### 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.
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default tsEslint.config({
"@typescript-eslint": tsEslint.plugin,
"check-file": checkFile,
},
ignores: [".github/knip.ts"],
ignores: [".github/knip.ts", "src/types/database.ts"],
extends: [eslint.configs.recommended, ...tsEslint.configs.recommended, sonarjs.configs.recommended],
languageOptions: {
parser: tsEslint.parser,
Expand Down
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "plugin-template",
"name": "command-wallet",
"version": "1.0.0",
"description": "Ubiquibot plugin template repository with TypeScript support.",
"description": "Helps users retrieving their wallet, or setting it to collect subsequent task rewards.",
"author": "Ubiquity DAO",
"license": "MIT",
"main": "src/worker.ts",
"engines": {
"node": ">=20.10.0"
},
"scripts": {
"prebuild": "dotenv -- cross-env yarn supabase:generate:remote",
"format": "run-p format:*",
"format:lint": "eslint --fix .",
"format:prettier": "prettier --write .",
Expand All @@ -17,7 +18,9 @@
"knip-ci": "knip --no-exit-code --reporter json --config .github/knip.ts",
"prepare": "husky install",
"test": "jest --setupFiles dotenv/config --coverage",
"worker": "wrangler dev --env dev --port 4000"
"worker": "wrangler dev --env dev --port 4000",
"supabase:generate:local": "supabase gen types typescript --local > src/types/database.ts",
"supabase:generate:remote": "cross-env-shell \"supabase gen types typescript --project-id $SUPABASE_PROJECT_ID --schema public > src/types/database.ts\""
},
"keywords": [
"typescript",
Expand All @@ -33,7 +36,9 @@
"@octokit/webhooks": "13.2.7",
"@sinclair/typebox": "0.32.33",
"@supabase/supabase-js": "2.43.5",
"commander": "12.1.0",
"dotenv": "16.4.5",
"ethers": "6.13.1",
"typebox-validators": "0.3.5"
},
"devDependencies": {
Expand All @@ -46,7 +51,9 @@
"@jest/globals": "29.7.0",
"@mswjs/data": "0.16.1",
"@types/node": "20.14.5",
"cross-env": "7.0.3",
"cspell": "8.9.0",
"dotenv-cli": "7.4.2",
"eslint": "9.5.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-check-file": "2.8.0",
Expand All @@ -60,11 +67,12 @@
"lint-staged": "15.2.7",
"npm-run-all": "4.1.5",
"prettier": "3.3.2",
"supabase": "1.178.2",
"ts-jest": "29.1.5",
"tsx": "4.15.6",
"typescript": "5.4.5",
"typescript-eslint": "7.13.1",
"wrangler": "3.60.3"
"wrangler": "3.61.0"
},
"lint-staged": {
"*.ts": [
Expand Down
12 changes: 3 additions & 9 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Context } from "../types/context";
import { Access } from "./supabase/helpers/access";
import { User } from "./supabase/helpers/user";
import { Label } from "./supabase/helpers/label";
import { Super } from "./supabase/helpers/supabase";
import { Context } from "../types";
import { Wallet } from "./supabase/helpers/wallet";

export function createAdapters(supabaseClient: SupabaseClient, context: Context) {
return {
supabase: {
access: new Access(supabaseClient, context),
user: new User(supabaseClient, context),
label: new Label(supabaseClient, context),
super: new Super(supabaseClient, context),
wallet: new Wallet(supabaseClient, context),
},
};
}
49 changes: 0 additions & 49 deletions src/adapters/supabase/helpers/access.ts

This file was deleted.

52 changes: 0 additions & 52 deletions src/adapters/supabase/helpers/label.ts

This file was deleted.

Loading