feat: 新增 cloud-artifacts 包(Cloudflare Worker HTML artifact 托管)

POST /upload 鉴权上传 HTML 到 R2 返回 hash URL,GET /<7d|30d>/<id>.html
由 Worker 代理读取并直出 text/html。R2 lifecycle rule 自动 7/30 天删除。
独立服务,不被主 CLI 引用(类似 packages/remote-control-server/ 定位)。

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>
This commit is contained in:
claude-code-best
2026-06-20 13:34:39 +08:00
parent 5d74071ebf
commit 617254b2b5
10 changed files with 791 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail
BUCKET="${BUCKET:-cloud-artifacts}"
echo "==> Creating R2 bucket: $BUCKET"
npx wrangler r2 bucket create "$BUCKET" || echo "(already exists or creation deferred)"
echo "==> Adding lifecycle rule: prefix '7d/' -> expire after 7 days"
npx wrangler r2 bucket lifecycle add "$BUCKET" delete-7d "7d/" --expire-days 7 --force
echo "==> Adding lifecycle rule: prefix '30d/' -> expire after 30 days"
npx wrangler r2 bucket lifecycle add "$BUCKET" delete-30d "30d/" --expire-days 30 --force
echo "==> Setting secret TOKEN (paste value, then Enter)"
npx wrangler secret put TOKEN
cat <<'NEXT'
==> Done. Remaining manual steps:
1. Bind a custom domain to the Worker (POST + GET 都走 Worker单一域名):
Dashboard: Workers & Pages > cloud-artifacts > Settings > Domains & Routes > Add > Custom Domain
填入你的 domain如 artifacts.example.comCloudflare 会自动加 DNS 记录和 SSL。
2. Update wrangler.toml [vars] PUBLIC_URL 为上一步的 domain带 https://,如 https://artifacts.example.com
3. Deploy:
bun run deploy
NEXT