Files
claude-code/packages/cloud-artifacts/scripts/setup.sh
claude-code-best 617254b2b5 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>
2026-06-20 13:34:39 +08:00

31 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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