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

feat: query user command #1

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
2f0040e
chore: setup wrangler
gentlementlegen May 20, 2024
3f1dd19
chore: removed unused code
gentlementlegen May 21, 2024
cdd285c
chore: cloudflare build
gentlementlegen May 21, 2024
cf8c61a
chore: cloudflare build
gentlementlegen May 21, 2024
db6fd26
chore: cloudflare action change
gentlementlegen May 21, 2024
8d60fea
chore: added error posting
gentlementlegen May 22, 2024
1f0c7ff
chore: wallet and access query
gentlementlegen May 22, 2024
bbe52ba
chore: proper formatting for comment
gentlementlegen May 22, 2024
59355b8
chore: removed log
gentlementlegen May 22, 2024
43355fd
chore: test for membership in org
gentlementlegen May 22, 2024
6dcbd2f
chore: fix cloudflare deploy
gentlementlegen May 22, 2024
412368b
chore: fix cloudflare deploy
gentlementlegen May 22, 2024
18f11cf
chore: fix cloudflare deploy
gentlementlegen May 22, 2024
18cca30
chore: fixed knip workflow
gentlementlegen May 22, 2024
c202a99
chore: fixed cloudflare workflow
gentlementlegen May 22, 2024
11fbf03
chore: fixed cloudflare workflow
gentlementlegen May 22, 2024
d98524c
chore: fixed cloudflare workflow
gentlementlegen May 22, 2024
9d6da48
chore: fixed cloudflare workflow
gentlementlegen May 22, 2024
27a210b
chore: renamed token env var
gentlementlegen May 22, 2024
14d2210
chore: added tests for run
gentlementlegen May 22, 2024
129aa44
chore: fix cspell
gentlementlegen May 22, 2024
cdf8449
chore: fix knip
gentlementlegen May 22, 2024
7f47965
chore: improved docs
gentlementlegen May 22, 2024
302ef17
chore: improved docs
gentlementlegen May 22, 2024
ceb9a68
chore: changed logger and rest repo target
gentlementlegen May 22, 2024
de36110
chore: only POST method are now valid
gentlementlegen May 23, 2024
50769c4
chore: added POST request example and docs
gentlementlegen May 24, 2024
178fad1
Merge branch 'refs/heads/meniole-development' into development
gentlementlegen May 24, 2024
062d04e
chore: error is posted to the issue if fatal
gentlementlegen May 26, 2024
5238fea
chore: remove type from README.md
gentlementlegen May 26, 2024
a40e83a
chore: added Supabase types
gentlementlegen May 26, 2024
50a43b7
chore: use authToken for Octokit auth
gentlementlegen May 26, 2024
1bce8f8
chore: check invoking user instead of comment
gentlementlegen May 26, 2024
a8ac10c
Merge pull request #1 from Meniole/development
gentlementlegen May 26, 2024
ab95ee1
Merge branch 'refs/heads/meniole-development' into meniole-main
gentlementlegen May 26, 2024
7e67ad7
chore: update deploy
gentlementlegen May 26, 2024
3d0b2b0
chore: cspell ignore conf files
gentlementlegen May 26, 2024
66f57c4
chore: fixed formatting
gentlementlegen May 26, 2024
35727b2
chore: improved formatting
gentlementlegen May 26, 2024
e7fcf11
chore: test log
gentlementlegen May 26, 2024
2d45a41
chore: test log
gentlementlegen May 26, 2024
8a47b36
chore: changed fatal error
gentlementlegen May 26, 2024
bb4f0b7
chore: test fix async
gentlementlegen May 26, 2024
1723430
chore: added db for knip
gentlementlegen May 26, 2024
cbff911
chore: display only labels for access
gentlementlegen May 27, 2024
745f445
chore: always use logger for logs
gentlementlegen May 28, 2024
6eff715
chore: removed unused UBIQUIBOT_TOKEN
gentlementlegen May 29, 2024
1b99593
chore: removed unused env loading
gentlementlegen May 29, 2024
083f06d
chore: removed unused dep dotenv
gentlementlegen May 30, 2024
a6921ae
chore: changed check for members to checkCollaborator
gentlementlegen May 30, 2024
566c04c
chore: log status
gentlementlegen May 30, 2024
595023a
chore: log status
gentlementlegen May 31, 2024
212e9c0
chore: removed org check
gentlementlegen May 31, 2024
2fc0a44
chore: add log
gentlementlegen May 31, 2024
fb895f4
chore: add log
gentlementlegen May 31, 2024
046fc63
chore: add try catch
gentlementlegen May 31, 2024
7f15df7
chore: add try catch
gentlementlegen May 31, 2024
0c58c30
chore: fix log
gentlementlegen May 31, 2024
74913e6
chore: removed debug
gentlementlegen May 31, 2024
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
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