Skip to content

Commit

Permalink
Merge pull request #1 from gentlementlegen/development
Browse files Browse the repository at this point in the history
feat: query user command
  • Loading branch information
whilefoo authored Jun 4, 2024
2 parents 04ce3b2 + 74913e6 commit 1f5fd83
Show file tree
Hide file tree
Showing 45 changed files with 2,694 additions and 1,361 deletions.
4 changes: 2 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "**/*.http", "**/*.toml"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir"],
"words": ["dataurl", "devpool", "outdir", "servedir", "typebox", "supabase", "ubiquibot", "mswjs"],
"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}"]
Expand Down
3 changes: 3 additions & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUPABASE_URL=
SUPABASE_KEY=
GITHUB_TOKEN=
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
},
plugins: ["@typescript-eslint", "sonarjs", "filename-rules"],
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"],
ignorePatterns: ["**/*.js"],
ignorePatterns: ["**/*.js", "src/types/database.ts"],
rules: {
"filename-rules/match": [2, /^(e2e\.ts$|.*\/e2e\.ts$|[a-z]+(?:[-._a-z]+)*\.ts|\.[a-z]+)$/],
"prefer-arrow-callback": ["warn", { allowNamedFunctions: true }],
Expand Down
4 changes: 2 additions & 2 deletions .github/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ 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", "@types/jest", "@mswjs/data"],
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "@types/jest"],
eslint: true,
};

Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/build.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/cypress-testing.yml

This file was deleted.

35 changes: 19 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
name: Deploy to Cloudflare Pages

on:
workflow_run:
workflows: ["Build"]
types:
- completed
workflow_dispatch:
push:
branches:
- main
- development

jobs:
deploy-to-cloudflare:
name: Automatic Cloudflare Deploy
runs-on: ubuntu-22.04
steps:
- name: Deploy to Cloudflare
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ubiquity/cloudflare-deploy-action@main
- name: Setup Node
uses: actions/setup-node@v4
with:
repository: ${{ github.repository }}
production_branch: ${{ github.event.repository.default_branch }}
build_artifact_name: "static"
output_directory: "static"
current_branch: ${{ github.event.workflow_run.head_branch }}
cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
commit_sha: ${{ github.event.workflow_run.head_sha }}
workflow_run_id: ${{ github.event.workflow_run.id }}
node-version: "20"
- uses: actions/checkout@v4
- uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: '3.57.0'
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
secrets: |
SUPABASE_URL
SUPABASE_KEY
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
40 changes: 40 additions & 0 deletions .github/workflows/knip-reporter.yml
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
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
if: ${{ github.event.workflow_run.conclusion != 'success' }}
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 }}
24 changes: 14 additions & 10 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Knip

on:
pull_request_target:
pull_request:
workflow_dispatch:

permissions: write-all

jobs:
run-knip:
runs-on: ubuntu-latest
Expand All @@ -21,11 +19,17 @@ jobs:
- name: Install toolchain
run: yarn install

- name: Report knip results to pull request
uses: Codex-/knip-reporter@v2
- 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:
verbose: true
comment_id: ${{ github.workflow }}-reporter
command_script_name: knip-ci
annotations: true
ignore_results: false
name: knip-results
path: |
knip-results.json
pr-number.txt
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ static/dist
coverage
junit.xml
cypress/screenshots
.dev.vars
/tests/http/http-client.private.env.json
54 changes: 41 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,56 @@
# `@ubiquity/ts-template`
# `@ubiquibot/command-query-user`

This template repository includes support for the following:
This package helps users querying their information, from they wallet address, label access control or current XP.

- TypeScript
- Environment Variables
- Conventional Commits
- Automatic deployment to Cloudflare Pages
## Usage

## Testing
The following commands are allowed:

### Cypress
```shell
/query @user
```

To test with Cypress Studio UI, run
## Running locally
### Supabase types
You can run the type generations against a local database with
```shell
yarn supabase:generate:local
```
Or against an instance by setting the `SUPABASE_ACCESS_TOKEN` and `SUPABASE_PROJECT_ID` in your `.env` file
```shell
yarn prebuild
```

### Worker
Start the Worker by running
```shell
yarn cy:open
yarn dev
```

Otherwise to simply run the tests through the console, run
### Make requests
To trigger the worker, `POST` requests should be made to http://localhost:4000 with a `Content-Type: application/json`
header and a body looking like
```json
{
"stateId": "",
"eventName": "",
"eventPayload": "",
"settings": "",
"ref": ""
}
```
For convenience, you can find an `.http` file with a valid request [here](/tests/http/request.http).

```shell
yarn cy:run
## Configuration
A valid configuration can be like:

```yaml
- plugin: https://ubiquibot-command-query-user.ubq.fi
with:
allowPublicQuery: true
```
## Testing
### Jest
To start Jest tests, run
Expand Down
33 changes: 0 additions & 33 deletions build/esbuild-build.ts

This file was deleted.

18 changes: 0 additions & 18 deletions build/esbuild-server.ts

This file was deleted.

4 changes: 0 additions & 4 deletions build/index.ts

This file was deleted.

11 changes: 0 additions & 11 deletions cypress.config.ts

This file was deleted.

11 changes: 0 additions & 11 deletions cypress/e2e/main.cy.ts

This file was deleted.

5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

Loading

0 comments on commit 1f5fd83

Please sign in to comment.