chore: migrate package manager from npm to bun

This commit is contained in:
RhenCloud 2026-08-13 20:34:52 +08:00
parent cf65111e4e
commit 41ad1a036b
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
14 changed files with 1903 additions and 16113 deletions

View file

@ -5,7 +5,7 @@
### 1. Create KV Namespace
```bash
npx wrangler kv namespace create KV
bunx wrangler kv namespace create KV
```
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
```bash
npx wrangler secret put GITHUB_WEBHOOK_SECRET
npx wrangler secret put GITHUB_CLIENT_ID
npx wrangler secret put GITHUB_CLIENT_SECRET
npx wrangler secret put DISCORD_TOKEN
npx 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
npx wrangler secret put ADMIN_USER_IDS # comma-separated GitHub IDs/logins allowed into the Web UI
bunx wrangler secret put GITHUB_WEBHOOK_SECRET
bunx wrangler secret put GITHUB_CLIENT_ID
bunx wrangler secret put GITHUB_CLIENT_SECRET
bunx wrangler secret put DISCORD_TOKEN
bunx wrangler secret put DISCORD_PUBLIC_KEY # Discord app public key (Developer Portal) — required for interactions
bunx wrangler secret put TELEGRAM_TOKEN # Telegram bot token (BotFather) — required for Telegram routes
bunx wrangler secret put ADMIN_USER_IDS # comma-separated GitHub IDs/logins allowed into the Web UI
```
::: 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
```bash
npx wrangler d1 create webhooker
bunx wrangler d1 create webhooker
```
Copy the returned database ID into `wrangler.jsonc`:
@ -68,8 +68,8 @@ Copy the returned database ID into `wrangler.jsonc`:
Then apply the migrations:
```bash
npm 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:prod # apply migrations to the remote D1 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.
@ -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:
```bash
npx wrangler d1 execute webhooker --remote --file ./migrations/0001_init.sql
npx wrangler d1 execute webhooker --remote --file ./migrations/0002_log_detail.sql
npx wrangler d1 execute webhooker --remote --file ./migrations/0003_telegram_links.sql
npx 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/0001_init.sql
bunx wrangler d1 execute webhooker --remote --file ./migrations/0002_log_detail.sql
bunx wrangler d1 execute webhooker --remote --file ./migrations/0003_telegram_links.sql
bunx wrangler d1 execute webhooker --remote --file ./migrations/0004_add_group_id.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
```bash
npx wrangler deploy
bunx wrangler deploy
```
Your worker is now live at `https://webhooker.<your-subdomain>.workers.dev`.

View file

@ -2,7 +2,7 @@
## 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 [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))
@ -12,7 +12,7 @@
```bash
git clone https://github.com/ReCloudStudio/WebHooker.git
cd WebHooker
npm install
bun install
```
## Local Development
@ -48,7 +48,7 @@ BASE_URL=http://localhost:8787
### 2. Start Dev Server
```bash
npm run dev
bun run dev
```
This starts a local Miniflare environment at `http://localhost:8787`.
@ -62,14 +62,16 @@ curl http://localhost:8787/health
## Available Scripts
| Script | Description |
| ---------------------- | --------------------------------- |
| `npm run dev` | Start local dev server (wrangler) |
| `npm run deploy` | Deploy to Cloudflare |
| `npm run typecheck` | TypeScript type checking |
| `npm run lint` | ESLint |
| `npm run lint:md` | Markdownlint |
| `npm run format` | Format with Prettier |
| `npm run format:check` | Check Prettier formatting |
| `npm run docs:dev` | Start docs dev server |
| `npm run docs:build` | Build docs site |
| Script | Description |
|------------------------|---------------------------------------------|
| `bun run dev` | Start Nuxt dev server (HMR) |
| `bun run build` | Production build (cloudflare_module preset) |
| `bun run deploy` | Deploy to Cloudflare |
| `bun run typecheck` | TypeScript type checking |
| `bun run lint` | ESLint |
| `bun run lint:md` | Markdownlint |
| `bun run format` | Format with Prettier |
| `bun run format:check` | Check Prettier formatting |
| `bun test` | Unit tests |
| `bun run docs:dev` | Start docs dev server |
| `bun run docs:build` | Build docs site |