mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
chore: migrate package manager from npm to bun
This commit is contained in:
parent
cf65111e4e
commit
41ad1a036b
14 changed files with 1903 additions and 16113 deletions
2
.github/workflows/lint-format.yml
vendored
2
.github/workflows/lint-format.yml
vendored
|
|
@ -36,7 +36,7 @@ jobs:
|
||||||
|
|
||||||
- name: Apply fixes
|
- name: Apply fixes
|
||||||
run: |
|
run: |
|
||||||
bunx eslint src/ --fix
|
bunx eslint . --fix
|
||||||
bunx prettier --write .
|
bunx prettier --write .
|
||||||
bunx markdownlint "**/*.md" --ignore node_modules --ignore dist --fix
|
bunx markdownlint "**/*.md" --ignore node_modules --ignore dist --fix
|
||||||
|
|
||||||
|
|
|
||||||
31
AGENTS.md
31
AGENTS.md
|
|
@ -143,7 +143,8 @@ tests/ # bun test unit tests (webhook, formatter, discord, tel
|
||||||
`splitMessageTitle`/`repoUrlFromMessage` (`server/lib/formatters/helpers.ts`): the Discord
|
`splitMessageTitle`/`repoUrlFromMessage` (`server/lib/formatters/helpers.ts`): the Discord
|
||||||
embed title is `{repo}{#number}` linked to the repository URL and `: {subject}` renders as
|
embed title is `{repo}{#number}` linked to the repository URL and `: {subject}` renders as
|
||||||
the first description line; Telegram keeps the one-line title with an inline repo link and
|
the first description line; Telegram keeps the one-line title with an inline repo link and
|
||||||
a plain subject. Messages without a `: ` separator keep the legacy whole-title link.
|
a plain subject. Messages without a colon separator (a `:` followed by a space) keep the
|
||||||
|
legacy whole-title link — use colon-free wording for such titles.
|
||||||
- Do NOT use `"Comment on org/repo"` / `"Review on org/repo"` prefixes. Comments, reviews
|
- Do NOT use `"Comment on org/repo"` / `"Review on org/repo"` prefixes. Comments, reviews
|
||||||
and inline comments use the same `{repo}{#number}: {title}` title as their parent object.
|
and inline comments use the same `{repo}{#number}: {title}` title as their parent object.
|
||||||
- All event-specific emoji live in `server/lib/formatters/` (via the `emojiPrefix` helper), never in
|
- All event-specific emoji live in `server/lib/formatters/` (via the `emojiPrefix` helper), never in
|
||||||
|
|
@ -159,12 +160,16 @@ tests/ # bun test unit tests (webhook, formatter, discord, tel
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
Package manager is **bun** — never use `npm`/`npx` (no `package-lock.json`, lockfile is `bun.lock`; CI runs `bun install --frozen-lockfile`).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev # Nuxt dev (HMR + Nitro dev server)
|
bun install # Install dependencies (updates bun.lock)
|
||||||
npx wrangler dev # Miniflare preview of a built worker (npm run build first)
|
bun run dev # Nuxt dev (HMR + Nitro dev server)
|
||||||
npm run typecheck # Type checking (nuxt typecheck)
|
bun run build # Production build (nuxt build, cloudflare_module preset)
|
||||||
npm run lint # ESLint
|
bunx wrangler dev # Miniflare preview of a built worker (bun run build first)
|
||||||
npm test # Unit tests (bun test, under tests/)
|
bun run typecheck # Type checking (nuxt typecheck)
|
||||||
|
bun run lint # ESLint
|
||||||
|
bun test # Unit tests (under tests/)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
@ -194,15 +199,15 @@ Rule: no functional change ships without its documentation; docs and code must n
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler secret put GITHUB_WEBHOOK_SECRET
|
bunx wrangler secret put GITHUB_WEBHOOK_SECRET
|
||||||
npx wrangler secret put DISCORD_TOKEN
|
bunx wrangler secret put DISCORD_TOKEN
|
||||||
npx wrangler secret put DISCORD_PUBLIC_KEY
|
bunx wrangler secret put DISCORD_PUBLIC_KEY
|
||||||
npx wrangler kv namespace create KV
|
bunx wrangler kv namespace create KV
|
||||||
# Update wrangler.jsonc with KV ID
|
# Update wrangler.jsonc with KV ID
|
||||||
npx wrangler d1 create webhooker
|
bunx wrangler d1 create webhooker
|
||||||
# Update wrangler.jsonc d1_databases with the database ID
|
# Update wrangler.jsonc d1_databases with the database ID
|
||||||
npm run db:migrate:prod # wrangler d1 migrations apply webhooker --remote (migrations/0001..0005)
|
bun run db:migrate:prod # wrangler d1 migrations apply webhooker --remote (migrations/0001..0005)
|
||||||
npx wrangler deploy
|
bunx wrangler deploy
|
||||||
```
|
```
|
||||||
|
|
||||||
Full list of secrets used: `GITHUB_WEBHOOK_SECRET`, `GITEA_WEBHOOK_SECRET`,
|
Full list of secrets used: `GITHUB_WEBHOOK_SECRET`, `GITEA_WEBHOOK_SECRET`,
|
||||||
|
|
|
||||||
35
README.md
35
README.md
|
|
@ -43,9 +43,10 @@ GitHub Webhook → Cloudflare Worker (Nuxt 4 / Nitro)
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install # or bun install
|
bun install # package manager is bun (lockfile: bun.lock)
|
||||||
cp .env.example .dev.vars # Fill in secrets for local dev
|
cp .env.example .dev.vars # Fill in secrets for local dev
|
||||||
npx wrangler dev # Start local dev server
|
bun run build # Production build first (wrangler dev serves the built worker)
|
||||||
|
bunx wrangler dev # Start local dev server
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
@ -293,34 +294,34 @@ Avatars are rendered as a link-preview card using the built-in `GET /api/richhea
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Set secrets in Cloudflare
|
# Set secrets in Cloudflare
|
||||||
npx wrangler secret put GITHUB_WEBHOOK_SECRET
|
bunx wrangler secret put GITHUB_WEBHOOK_SECRET
|
||||||
npx wrangler secret put GITHUB_CLIENT_ID
|
bunx wrangler secret put GITHUB_CLIENT_ID
|
||||||
npx wrangler secret put GITHUB_CLIENT_SECRET
|
bunx wrangler secret put GITHUB_CLIENT_SECRET
|
||||||
npx wrangler secret put DISCORD_TOKEN
|
bunx wrangler secret put DISCORD_TOKEN
|
||||||
npx wrangler secret put DISCORD_PUBLIC_KEY
|
bunx wrangler secret put DISCORD_PUBLIC_KEY
|
||||||
npx wrangler secret put TELEGRAM_TOKEN
|
bunx wrangler secret put TELEGRAM_TOKEN
|
||||||
npx wrangler secret put ADMIN_USER_IDS
|
bunx wrangler secret put ADMIN_USER_IDS
|
||||||
|
|
||||||
# Create KV namespace
|
# Create KV namespace
|
||||||
npx wrangler kv namespace create KV
|
bunx wrangler kv namespace create KV
|
||||||
# Update wrangler.jsonc with the KV namespace ID
|
# Update wrangler.jsonc with the KV namespace ID
|
||||||
|
|
||||||
# Create D1 database and run migrations
|
# Create D1 database and run migrations
|
||||||
npx wrangler d1 create webhooker
|
bunx wrangler d1 create webhooker
|
||||||
# Update wrangler.jsonc d1_databases with the database ID
|
# Update wrangler.jsonc d1_databases with the database ID
|
||||||
npm run db:migrate:prod # apply migrations to the remote D1 database
|
bun run db:migrate:prod # apply migrations to the remote D1 database
|
||||||
|
|
||||||
# Deploy
|
# Deploy
|
||||||
npx wrangler deploy
|
bunx wrangler deploy
|
||||||
```
|
```
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler dev # Local dev server (Miniflare)
|
bun run dev # Nuxt dev server (HMR)
|
||||||
npm run typecheck # Type checking
|
bun run typecheck # Type checking
|
||||||
npm run lint # ESLint
|
bun run lint # ESLint
|
||||||
npm test # Unit tests (bun test)
|
bun test # Unit tests
|
||||||
```
|
```
|
||||||
|
|
||||||
## Supported Events
|
## Supported Events
|
||||||
|
|
|
||||||
35
README.zh.md
35
README.zh.md
|
|
@ -43,9 +43,10 @@ GitHub Webhook → Cloudflare Worker (Nuxt 4 / Nitro)
|
||||||
## 快速开始
|
## 快速开始
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install # 或 bun install
|
bun install # 包管理器为 bun(锁文件:bun.lock)
|
||||||
cp .env.example .dev.vars # 填写本地开发密钥
|
cp .env.example .dev.vars # 填写本地开发密钥
|
||||||
npx wrangler dev # 启动本地开发服务器
|
bun run build # 先构建生产产物(wrangler dev 运行的是构建产物)
|
||||||
|
bunx wrangler dev # 启动本地开发服务器
|
||||||
```
|
```
|
||||||
|
|
||||||
## 配置
|
## 配置
|
||||||
|
|
@ -292,34 +293,34 @@ bot 通过定时任务(每 5 分钟)同步注册原生的**斜杠命令**与
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 在 Cloudflare 设置密钥
|
# 在 Cloudflare 设置密钥
|
||||||
npx wrangler secret put GITHUB_WEBHOOK_SECRET
|
bunx wrangler secret put GITHUB_WEBHOOK_SECRET
|
||||||
npx wrangler secret put GITHUB_CLIENT_ID
|
bunx wrangler secret put GITHUB_CLIENT_ID
|
||||||
npx wrangler secret put GITHUB_CLIENT_SECRET
|
bunx wrangler secret put GITHUB_CLIENT_SECRET
|
||||||
npx wrangler secret put DISCORD_TOKEN
|
bunx wrangler secret put DISCORD_TOKEN
|
||||||
npx wrangler secret put DISCORD_PUBLIC_KEY
|
bunx wrangler secret put DISCORD_PUBLIC_KEY
|
||||||
npx wrangler secret put TELEGRAM_TOKEN
|
bunx wrangler secret put TELEGRAM_TOKEN
|
||||||
npx wrangler secret put ADMIN_USER_IDS
|
bunx wrangler secret put ADMIN_USER_IDS
|
||||||
|
|
||||||
# 创建 KV 命名空间
|
# 创建 KV 命名空间
|
||||||
npx wrangler kv namespace create KV
|
bunx wrangler kv namespace create KV
|
||||||
# 更新 wrangler.jsonc 中的 KV namespace ID
|
# 更新 wrangler.jsonc 中的 KV namespace ID
|
||||||
|
|
||||||
# 创建 D1 数据库并执行迁移
|
# 创建 D1 数据库并执行迁移
|
||||||
npx wrangler d1 create webhooker
|
bunx wrangler d1 create webhooker
|
||||||
# 更新 wrangler.jsonc d1_databases 中的数据库 ID
|
# 更新 wrangler.jsonc d1_databases 中的数据库 ID
|
||||||
npm run db:migrate:prod # 将迁移应用到远端 D1 数据库
|
bun run db:migrate:prod # 将迁移应用到远端 D1 数据库
|
||||||
|
|
||||||
# 部署
|
# 部署
|
||||||
npx wrangler deploy
|
bunx wrangler deploy
|
||||||
```
|
```
|
||||||
|
|
||||||
## 开发命令
|
## 开发命令
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler dev # 本地开发服务器(Miniflare)
|
bunx wrangler dev # 本地开发服务器(Miniflare)
|
||||||
npm run typecheck # 类型检查
|
bun run typecheck # 类型检查
|
||||||
npm run lint # ESLint
|
bun run lint # ESLint
|
||||||
npm test # 单元测试(bun test)
|
bun test # 单元测试
|
||||||
```
|
```
|
||||||
|
|
||||||
## 支持的事件
|
## 支持的事件
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/ReCloudStudio/WebHooker.git
|
git clone https://github.com/ReCloudStudio/WebHooker.git
|
||||||
cd WebHooker
|
cd WebHooker
|
||||||
npm install
|
bun install
|
||||||
cp .env.example .dev.vars # Fill in secrets
|
cp .env.example .dev.vars # Fill in secrets
|
||||||
npm run dev # Start local dev server
|
bun run dev # Start local dev server
|
||||||
```
|
```
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
@ -81,15 +81,15 @@ tests/ # Unit tests (bun test)
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| ---------------------- | ------------------------------- |
|
| ---------------------- | ------------------------------- |
|
||||||
| `npm run dev` | Start Nuxt dev server (HMR) |
|
| `bun run dev` | Start Nuxt dev server (HMR) |
|
||||||
| `npm run typecheck` | TypeScript type checking |
|
| `bun run typecheck` | TypeScript type checking |
|
||||||
| `npm run lint` | ESLint (TypeScript) |
|
| `bun run lint` | ESLint (TypeScript) |
|
||||||
| `npm run lint:md` | Markdownlint (Markdown) |
|
| `bun run lint:md` | Markdownlint (Markdown) |
|
||||||
| `npm test` | Run unit tests (bun test) |
|
| `bun test` | Run unit tests (bun test) |
|
||||||
| `npm run format` | Format all files with Prettier |
|
| `bun run format` | Format all files with Prettier |
|
||||||
| `npm run format:check` | Check Prettier formatting |
|
| `bun run format:check` | Check Prettier formatting |
|
||||||
| `npm run docs:dev` | Start VitePress docs dev server |
|
| `bun run docs:dev` | Start VitePress docs dev server |
|
||||||
| `npm run docs:build` | Build docs site |
|
| `bun run docs:build` | Build docs site |
|
||||||
|
|
||||||
## Code Style
|
## Code Style
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ tests/ # Unit tests (bun test)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Run the unit test suite (bun test)
|
# Run the unit test suite (bun test)
|
||||||
npm test
|
bun test
|
||||||
|
|
||||||
# Or manually check the health endpoint
|
# Or manually check the health endpoint
|
||||||
curl http://localhost:8787/health
|
curl http://localhost:8787/health
|
||||||
|
|
@ -127,5 +127,5 @@ curl http://localhost:8787/health
|
||||||
|
|
||||||
- Keep changes focused and atomic
|
- Keep changes focused and atomic
|
||||||
- Include type annotations for all function returns
|
- Include type annotations for all function returns
|
||||||
- Run `npm run typecheck && npm run lint && npm run format:check` before submitting
|
- Run `bun run typecheck && bun run lint && bun run format:check` before submitting
|
||||||
- Update documentation if adding features (see the checklist in `AGENTS.md` → Documentation): README (`README.md` / `README.zh.md`), VitePress docs (`docs/` and `docs/zh/`), and example config files
|
- Update documentation if adding features (see the checklist in `AGENTS.md` → Documentation): README (`README.md` / `README.zh.md`), VitePress docs (`docs/` and `docs/zh/`), and example config files
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
### 1. Create KV Namespace
|
### 1. Create KV Namespace
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler kv namespace create KV
|
bunx wrangler kv namespace create KV
|
||||||
```
|
```
|
||||||
|
|
||||||
This outputs a namespace ID. Update `wrangler.jsonc` with the ID:
|
This outputs a namespace ID. Update `wrangler.jsonc` with the ID:
|
||||||
|
|
@ -24,13 +24,13 @@ This outputs a namespace ID. Update `wrangler.jsonc` with the ID:
|
||||||
### 2. Set Secrets
|
### 2. Set Secrets
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler secret put GITHUB_WEBHOOK_SECRET
|
bunx wrangler secret put GITHUB_WEBHOOK_SECRET
|
||||||
npx wrangler secret put GITHUB_CLIENT_ID
|
bunx wrangler secret put GITHUB_CLIENT_ID
|
||||||
npx wrangler secret put GITHUB_CLIENT_SECRET
|
bunx wrangler secret put GITHUB_CLIENT_SECRET
|
||||||
npx wrangler secret put DISCORD_TOKEN
|
bunx wrangler secret put DISCORD_TOKEN
|
||||||
npx wrangler secret put DISCORD_PUBLIC_KEY # Discord app public key (Developer Portal) — required for interactions
|
bunx wrangler secret put DISCORD_PUBLIC_KEY # Discord app public key (Developer Portal) — required for interactions
|
||||||
npx wrangler secret put TELEGRAM_TOKEN # Telegram bot token (BotFather) — required for Telegram routes
|
bunx wrangler secret put TELEGRAM_TOKEN # Telegram bot token (BotFather) — required for Telegram routes
|
||||||
npx wrangler secret put ADMIN_USER_IDS # comma-separated GitHub IDs/logins allowed into the Web UI
|
bunx wrangler secret put ADMIN_USER_IDS # comma-separated GitHub IDs/logins allowed into the Web UI
|
||||||
```
|
```
|
||||||
|
|
||||||
::: tip Target channels are configured per route
|
::: tip Target channels are configured per route
|
||||||
|
|
@ -48,7 +48,7 @@ Discord interactions arrive via the HTTPS Interactions Endpoint, so set `DISCORD
|
||||||
### 3. Create D1 Database and Run Migrations
|
### 3. Create D1 Database and Run Migrations
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler d1 create webhooker
|
bunx wrangler d1 create webhooker
|
||||||
```
|
```
|
||||||
|
|
||||||
Copy the returned database ID into `wrangler.jsonc`:
|
Copy the returned database ID into `wrangler.jsonc`:
|
||||||
|
|
@ -68,8 +68,8 @@ Copy the returned database ID into `wrangler.jsonc`:
|
||||||
Then apply the migrations:
|
Then apply the migrations:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run db:migrate:prod # apply migrations to the remote D1 database
|
bun run db:migrate:prod # apply migrations to the remote D1 database
|
||||||
npm run db:migrate # apply migrations to the local (Miniflare) database
|
bun run db:migrate # apply migrations to the local (Miniflare) database
|
||||||
```
|
```
|
||||||
|
|
||||||
The `db:migrate` scripts run `wrangler d1 migrations apply webhooker` (see `package.json`), which applies each SQL file in `migrations/` and records applied versions in the `d1_migrations` table.
|
The `db:migrate` scripts run `wrangler d1 migrations apply webhooker` (see `package.json`), which applies each SQL file in `migrations/` and records applied versions in the `d1_migrations` table.
|
||||||
|
|
@ -78,11 +78,11 @@ The `db:migrate` scripts run `wrangler d1 migrations apply webhooker` (see `pack
|
||||||
If the database already has these tables/columns (e.g. previously migrated with `wrangler d1 execute --file`), the `d1_migrations` tracking table may be missing and `db:migrate:prod` will try to re-run every migration. The `ALTER TABLE ... ADD COLUMN` statements in `0002_log_detail.sql` then fail because the columns already exist. In that case run the files directly instead:
|
If the database already has these tables/columns (e.g. previously migrated with `wrangler d1 execute --file`), the `d1_migrations` tracking table may be missing and `db:migrate:prod` will try to re-run every migration. The `ALTER TABLE ... ADD COLUMN` statements in `0002_log_detail.sql` then fail because the columns already exist. In that case run the files directly instead:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler d1 execute webhooker --remote --file ./migrations/0001_init.sql
|
bunx wrangler d1 execute webhooker --remote --file ./migrations/0001_init.sql
|
||||||
npx wrangler d1 execute webhooker --remote --file ./migrations/0002_log_detail.sql
|
bunx wrangler d1 execute webhooker --remote --file ./migrations/0002_log_detail.sql
|
||||||
npx wrangler d1 execute webhooker --remote --file ./migrations/0003_telegram_links.sql
|
bunx wrangler d1 execute webhooker --remote --file ./migrations/0003_telegram_links.sql
|
||||||
npx wrangler d1 execute webhooker --remote --file ./migrations/0004_add_group_id.sql
|
bunx wrangler d1 execute webhooker --remote --file ./migrations/0004_add_group_id.sql
|
||||||
npx wrangler d1 execute webhooker --remote --file ./migrations/0005_audit_logs.sql
|
bunx wrangler d1 execute webhooker --remote --file ./migrations/0005_audit_logs.sql
|
||||||
```
|
```
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
@ -90,7 +90,7 @@ npx wrangler d1 execute webhooker --remote --file ./migrations/0005_audit_logs.s
|
||||||
### 4. Deploy
|
### 4. Deploy
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler deploy
|
bunx wrangler deploy
|
||||||
```
|
```
|
||||||
|
|
||||||
Your worker is now live at `https://webhooker.<your-subdomain>.workers.dev`.
|
Your worker is now live at `https://webhooker.<your-subdomain>.workers.dev`.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
- [Node.js](https://nodejs.org/) 18+
|
- [Bun](https://bun.sh/) 1.x (the only package manager; never use npm)
|
||||||
- A [Cloudflare account](https://dash.cloudflare.com/) (free tier works)
|
- A [Cloudflare account](https://dash.cloudflare.com/) (free tier works)
|
||||||
- A [GitHub App](https://github.com/settings/apps/new) (see [GitHub App Setup](/guide/deployment#github-app-setup))
|
- A [GitHub App](https://github.com/settings/apps/new) (see [GitHub App Setup](/guide/deployment#github-app-setup))
|
||||||
- A Discord bot token (see [Discord Bot Setup](/guide/deployment#discord-bot-setup))
|
- A Discord bot token (see [Discord Bot Setup](/guide/deployment#discord-bot-setup))
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/ReCloudStudio/WebHooker.git
|
git clone https://github.com/ReCloudStudio/WebHooker.git
|
||||||
cd WebHooker
|
cd WebHooker
|
||||||
npm install
|
bun install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Local Development
|
## Local Development
|
||||||
|
|
@ -48,7 +48,7 @@ BASE_URL=http://localhost:8787
|
||||||
### 2. Start Dev Server
|
### 2. Start Dev Server
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev
|
bun run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
This starts a local Miniflare environment at `http://localhost:8787`.
|
This starts a local Miniflare environment at `http://localhost:8787`.
|
||||||
|
|
@ -62,14 +62,16 @@ curl http://localhost:8787/health
|
||||||
|
|
||||||
## Available Scripts
|
## Available Scripts
|
||||||
|
|
||||||
| Script | Description |
|
| Script | Description |
|
||||||
| ---------------------- | --------------------------------- |
|
|------------------------|---------------------------------------------|
|
||||||
| `npm run dev` | Start local dev server (wrangler) |
|
| `bun run dev` | Start Nuxt dev server (HMR) |
|
||||||
| `npm run deploy` | Deploy to Cloudflare |
|
| `bun run build` | Production build (cloudflare_module preset) |
|
||||||
| `npm run typecheck` | TypeScript type checking |
|
| `bun run deploy` | Deploy to Cloudflare |
|
||||||
| `npm run lint` | ESLint |
|
| `bun run typecheck` | TypeScript type checking |
|
||||||
| `npm run lint:md` | Markdownlint |
|
| `bun run lint` | ESLint |
|
||||||
| `npm run format` | Format with Prettier |
|
| `bun run lint:md` | Markdownlint |
|
||||||
| `npm run format:check` | Check Prettier formatting |
|
| `bun run format` | Format with Prettier |
|
||||||
| `npm run docs:dev` | Start docs dev server |
|
| `bun run format:check` | Check Prettier formatting |
|
||||||
| `npm run docs:build` | Build docs site |
|
| `bun test` | Unit tests |
|
||||||
|
| `bun run docs:dev` | Start docs dev server |
|
||||||
|
| `bun run docs:build` | Build docs site |
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/ReCloudStudio/WebHooker.git
|
git clone https://github.com/ReCloudStudio/WebHooker.git
|
||||||
cd WebHooker
|
cd WebHooker
|
||||||
npm install
|
bun install
|
||||||
cp .env.example .dev.vars # 填入密钥
|
cp .env.example .dev.vars # 填入密钥
|
||||||
npm run dev # 启动本地开发服务器
|
bun run dev # 启动本地开发服务器
|
||||||
```
|
```
|
||||||
|
|
||||||
## 项目结构
|
## 项目结构
|
||||||
|
|
@ -81,15 +81,15 @@ tests/ # 单元测试 (bun test)
|
||||||
|
|
||||||
| 命令 | 说明 |
|
| 命令 | 说明 |
|
||||||
| ---------------------- | ----------------------------- |
|
| ---------------------- | ----------------------------- |
|
||||||
| `npm run dev` | 启动 Nuxt 开发服务器 (HMR) |
|
| `bun run dev` | 启动 Nuxt 开发服务器 (HMR) |
|
||||||
| `npm run typecheck` | TypeScript 类型检查 |
|
| `bun run typecheck` | TypeScript 类型检查 |
|
||||||
| `npm run lint` | ESLint (TypeScript) |
|
| `bun run lint` | ESLint (TypeScript) |
|
||||||
| `npm run lint:md` | Markdownlint (Markdown) |
|
| `bun run lint:md` | Markdownlint (Markdown) |
|
||||||
| `npm test` | 运行单元测试 (bun test) |
|
| `bun test` | 运行单元测试 (bun test) |
|
||||||
| `npm run format` | 使用 Prettier 格式化所有文件 |
|
| `bun run format` | 使用 Prettier 格式化所有文件 |
|
||||||
| `npm run format:check` | 检查 Prettier 格式 |
|
| `bun run format:check` | 检查 Prettier 格式 |
|
||||||
| `npm run docs:dev` | 启动 VitePress 文档开发服务器 |
|
| `bun run docs:dev` | 启动 VitePress 文档开发服务器 |
|
||||||
| `npm run docs:build` | 构建文档站点 |
|
| `bun run docs:build` | 构建文档站点 |
|
||||||
|
|
||||||
## 代码风格
|
## 代码风格
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ tests/ # 单元测试 (bun test)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 运行单元测试套件 (bun test)
|
# 运行单元测试套件 (bun test)
|
||||||
npm test
|
bun test
|
||||||
|
|
||||||
# 或手动检查健康端点
|
# 或手动检查健康端点
|
||||||
curl http://localhost:8787/health
|
curl http://localhost:8787/health
|
||||||
|
|
@ -127,5 +127,5 @@ curl http://localhost:8787/health
|
||||||
|
|
||||||
- 保持变更聚焦且原子化
|
- 保持变更聚焦且原子化
|
||||||
- 为所有函数返回值包含类型注解
|
- 为所有函数返回值包含类型注解
|
||||||
- 提交前运行 `npm run typecheck && npm run lint && npm run format:check`
|
- 提交前运行 `bun run typecheck && bun run lint && bun run format:check`
|
||||||
- 添加功能时更新文档(见 `AGENTS.md` → Documentation 的清单):README(`README.md` / `README.zh.md`)、VitePress 文档(`docs/` 与 `docs/zh/`)以及示例配置文件
|
- 添加功能时更新文档(见 `AGENTS.md` → Documentation 的清单):README(`README.md` / `README.zh.md`)、VitePress 文档(`docs/` 与 `docs/zh/`)以及示例配置文件
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
### 1. 创建 KV 命名空间
|
### 1. 创建 KV 命名空间
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler kv namespace create KV
|
bunx wrangler kv namespace create KV
|
||||||
```
|
```
|
||||||
|
|
||||||
这会输出一个命名空间 ID。更新 `wrangler.jsonc`,填入 ID:
|
这会输出一个命名空间 ID。更新 `wrangler.jsonc`,填入 ID:
|
||||||
|
|
@ -24,13 +24,13 @@ npx wrangler kv namespace create KV
|
||||||
### 2. 设置密钥
|
### 2. 设置密钥
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler secret put GITHUB_WEBHOOK_SECRET
|
bunx wrangler secret put GITHUB_WEBHOOK_SECRET
|
||||||
npx wrangler secret put GITHUB_CLIENT_ID
|
bunx wrangler secret put GITHUB_CLIENT_ID
|
||||||
npx wrangler secret put GITHUB_CLIENT_SECRET
|
bunx wrangler secret put GITHUB_CLIENT_SECRET
|
||||||
npx wrangler secret put DISCORD_TOKEN
|
bunx wrangler secret put DISCORD_TOKEN
|
||||||
npx wrangler secret put DISCORD_PUBLIC_KEY # Discord 应用的公钥(开发者门户获取),交互功能必需
|
bunx wrangler secret put DISCORD_PUBLIC_KEY # Discord 应用的公钥(开发者门户获取),交互功能必需
|
||||||
npx wrangler secret put TELEGRAM_TOKEN # Telegram Bot Token(BotFather 获取)—— Telegram 路由必需
|
bunx wrangler secret put TELEGRAM_TOKEN # Telegram Bot Token(BotFather 获取)—— Telegram 路由必需
|
||||||
npx wrangler secret put ADMIN_USER_IDS # 逗号分隔的 GitHub ID/登录名,允许进入 Web UI
|
bunx wrangler secret put ADMIN_USER_IDS # 逗号分隔的 GitHub ID/登录名,允许进入 Web UI
|
||||||
```
|
```
|
||||||
|
|
||||||
::: tip 目标频道按路由配置
|
::: tip 目标频道按路由配置
|
||||||
|
|
@ -47,7 +47,7 @@ Discord 交互通过 HTTPS Interactions Endpoint 送达,需要设置 `DISCORD_
|
||||||
### 3. 创建 D1 数据库并执行迁移
|
### 3. 创建 D1 数据库并执行迁移
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler d1 create webhooker
|
bunx wrangler d1 create webhooker
|
||||||
```
|
```
|
||||||
|
|
||||||
将返回的数据库 ID 填入 `wrangler.jsonc`:
|
将返回的数据库 ID 填入 `wrangler.jsonc`:
|
||||||
|
|
@ -67,8 +67,8 @@ npx wrangler d1 create webhooker
|
||||||
然后执行迁移:
|
然后执行迁移:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run db:migrate:prod # 将迁移应用到远端 D1 数据库
|
bun run db:migrate:prod # 将迁移应用到远端 D1 数据库
|
||||||
npm run db:migrate # 将迁移应用到本地(Miniflare)数据库
|
bun run db:migrate # 将迁移应用到本地(Miniflare)数据库
|
||||||
```
|
```
|
||||||
|
|
||||||
`db:migrate` 脚本执行 `wrangler d1 migrations apply webhooker`(见 `package.json`),逐一应用 `migrations/` 下的 SQL 文件,并在 `d1_migrations` 表中记录已应用的版本。
|
`db:migrate` 脚本执行 `wrangler d1 migrations apply webhooker`(见 `package.json`),逐一应用 `migrations/` 下的 SQL 文件,并在 `d1_migrations` 表中记录已应用的版本。
|
||||||
|
|
@ -77,11 +77,11 @@ npm run db:migrate # 将迁移应用到本地(Miniflare)数据库
|
||||||
如果数据库已有这些表/列(例如之前用 `wrangler d1 execute --file` 迁移过),可能缺少 `d1_migrations` 追踪表,`db:migrate:prod` 会尝试重新执行所有迁移;`0002_log_detail.sql` 中的 `ALTER TABLE ... ADD COLUMN` 语句会因列已存在而失败。此时请直接执行文件:
|
如果数据库已有这些表/列(例如之前用 `wrangler d1 execute --file` 迁移过),可能缺少 `d1_migrations` 追踪表,`db:migrate:prod` 会尝试重新执行所有迁移;`0002_log_detail.sql` 中的 `ALTER TABLE ... ADD COLUMN` 语句会因列已存在而失败。此时请直接执行文件:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler d1 execute webhooker --remote --file ./migrations/0001_init.sql
|
bunx wrangler d1 execute webhooker --remote --file ./migrations/0001_init.sql
|
||||||
npx wrangler d1 execute webhooker --remote --file ./migrations/0002_log_detail.sql
|
bunx wrangler d1 execute webhooker --remote --file ./migrations/0002_log_detail.sql
|
||||||
npx wrangler d1 execute webhooker --remote --file ./migrations/0003_telegram_links.sql
|
bunx wrangler d1 execute webhooker --remote --file ./migrations/0003_telegram_links.sql
|
||||||
npx wrangler d1 execute webhooker --remote --file ./migrations/0004_add_group_id.sql
|
bunx wrangler d1 execute webhooker --remote --file ./migrations/0004_add_group_id.sql
|
||||||
npx wrangler d1 execute webhooker --remote --file ./migrations/0005_audit_logs.sql
|
bunx wrangler d1 execute webhooker --remote --file ./migrations/0005_audit_logs.sql
|
||||||
```
|
```
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
@ -89,7 +89,7 @@ npx wrangler d1 execute webhooker --remote --file ./migrations/0005_audit_logs.s
|
||||||
### 4. 部署
|
### 4. 部署
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx wrangler deploy
|
bunx wrangler deploy
|
||||||
```
|
```
|
||||||
|
|
||||||
Worker 现在可通过 `https://webhooker.<your-subdomain>.workers.dev` 访问。
|
Worker 现在可通过 `https://webhooker.<your-subdomain>.workers.dev` 访问。
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## 前置要求
|
## 前置要求
|
||||||
|
|
||||||
- [Node.js](https://nodejs.org/) 18+
|
- [Bun](https://bun.sh/) 1.x(唯一包管理器,不要使用 npm)
|
||||||
- [Cloudflare 账号](https://dash.cloudflare.com/)(免费套餐即可)
|
- [Cloudflare 账号](https://dash.cloudflare.com/)(免费套餐即可)
|
||||||
- [GitHub App](https://github.com/settings/apps/new)(参见 [GitHub App 设置](/zh/guide/deployment#github-app-设置))
|
- [GitHub App](https://github.com/settings/apps/new)(参见 [GitHub App 设置](/zh/guide/deployment#github-app-设置))
|
||||||
- Discord Bot Token(参见 [Discord Bot 设置](/zh/guide/deployment#discord-bot-设置))
|
- Discord Bot Token(参见 [Discord Bot 设置](/zh/guide/deployment#discord-bot-设置))
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/ReCloudStudio/WebHooker.git
|
git clone https://github.com/ReCloudStudio/WebHooker.git
|
||||||
cd WebHooker
|
cd WebHooker
|
||||||
npm install
|
bun install
|
||||||
```
|
```
|
||||||
|
|
||||||
## 本地开发
|
## 本地开发
|
||||||
|
|
@ -48,7 +48,7 @@ BASE_URL=http://localhost:8787
|
||||||
### 2. 启动开发服务器
|
### 2. 启动开发服务器
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev
|
bun run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
这将在 `http://localhost:8787` 启动本地 Miniflare 环境。
|
这将在 `http://localhost:8787` 启动本地 Miniflare 环境。
|
||||||
|
|
@ -64,12 +64,12 @@ curl http://localhost:8787/health
|
||||||
|
|
||||||
| 脚本 | 说明 |
|
| 脚本 | 说明 |
|
||||||
| ---------------------- | ----------------------------- |
|
| ---------------------- | ----------------------------- |
|
||||||
| `npm run dev` | 启动本地开发服务器 (wrangler) |
|
| `bun run dev` | 启动本地开发服务器 (wrangler) |
|
||||||
| `npm run deploy` | 部署到 Cloudflare |
|
| `bun run deploy` | 部署到 Cloudflare |
|
||||||
| `npm run typecheck` | TypeScript 类型检查 |
|
| `bun run typecheck` | TypeScript 类型检查 |
|
||||||
| `npm run lint` | ESLint |
|
| `bun run lint` | ESLint |
|
||||||
| `npm run lint:md` | Markdownlint |
|
| `bun run lint:md` | Markdownlint |
|
||||||
| `npm run format` | 使用 Prettier 格式化 |
|
| `bun run format` | 使用 Prettier 格式化 |
|
||||||
| `npm run format:check` | 检查 Prettier 格式 |
|
| `bun run format:check` | 检查 Prettier 格式 |
|
||||||
| `npm run docs:dev` | 启动文档开发服务器 |
|
| `bun run docs:dev` | 启动文档开发服务器 |
|
||||||
| `npm run docs:build` | 构建文档站点 |
|
| `bun run docs:build` | 构建文档站点 |
|
||||||
|
|
|
||||||
15964
package-lock.json
generated
15964
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -3,6 +3,7 @@
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"packageManager": "bun@1.3.14",
|
||||||
"description": "GitHub / Gitea webhook → Discord / Telegram dispatcher on Cloudflare Workers (Nuxt 4)",
|
"description": "GitHub / Gitea webhook → Discord / Telegram dispatcher on Cloudflare Workers (Nuxt 4)",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxt dev",
|
"dev": "nuxt dev",
|
||||||
|
|
@ -28,6 +29,9 @@
|
||||||
"octokit": "^4.1.0",
|
"octokit": "^4.1.0",
|
||||||
"vue": "^3.5.13"
|
"vue": "^3.5.13"
|
||||||
},
|
},
|
||||||
|
"overrides": {
|
||||||
|
"@nuxt/kit": "3.21.11"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cloudflare/workers-types": "^5.20260801.1",
|
"@cloudflare/workers-types": "^5.20260801.1",
|
||||||
"@nuxtjs/tailwindcss": "^6.14.0",
|
"@nuxtjs/tailwindcss": "^6.14.0",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"compatibility_date": "2025-01-01",
|
"compatibility_date": "2025-01-01",
|
||||||
"compatibility_flags": ["nodejs_compat"],
|
"compatibility_flags": ["nodejs_compat"],
|
||||||
"build": {
|
"build": {
|
||||||
"command": "npm run build"
|
"command": "bun run build"
|
||||||
},
|
},
|
||||||
"assets": {
|
"assets": {
|
||||||
"directory": "./.output/public",
|
"directory": "./.output/public",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue