From b2a15b7e8f45759d9c624ac33f1d0fb658eb9ac4 Mon Sep 17 00:00:00 2001 From: Todos Date: Sun, 8 Nov 2026 23:37:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(hub):=20=E4=B8=8B=E7=BA=BF=E3=80=8C?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E6=BC=94=E7=A4=BA=E3=80=8Dhomepage=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=EF=BC=8CREADME=20=E6=94=B9=E4=B8=BA=E5=A4=96?= =?UTF-8?q?=E9=83=A8=E8=AE=BF=E5=AE=A2=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit homepage 从 schema、数据、视图、入口、投稿校验与链接巡检整类删除,卡片主入口统一为「查看仓库」;CONTRIBUTING、测试夹具与 CI 演练同步为新契约。README 重写为 6 节 47 行,清除 SPEC/§ 引用与内部工程细节。 Checkpoint: rnlexT3KLLg8uUPZhO9Qe --- .github/workflows/ci.yml | 6 +- CONTRIBUTING.md | 6 +- README.md | 269 ++---------------- scripts/link-health.ts | 2 +- scripts/validate-submission.ts | 2 +- src/data/projects/cloud-mail.yaml | 3 +- src/data/projects/edgechat.yaml | 2 - src/data/projects/edgeever.yaml | 1 - src/data/projects/enotify.yaml | 1 - src/data/projects/someday.yaml | 1 - src/data/projects/uptimeflare.yaml | 1 - src/lib/link-health.ts | 10 +- src/lib/project-entry.ts | 12 +- src/lib/project-schema.ts | 1 - src/lib/project-types.ts | 1 - src/lib/project-view.ts | 1 - src/lib/submission-checks.ts | 17 +- tests/build-summary.test.ts | 2 +- tests/contributing-docs.test.ts | 1 - ...e.yaml => drill-official-broken-docs.yaml} | 10 +- tests/link-health.test.ts | 17 +- tests/project-filter.test.ts | 39 ++- tests/project-schema.test.ts | 6 + tests/submission-checks.test.ts | 49 ++-- tests/submission-cli.test.ts | 10 +- 25 files changed, 122 insertions(+), 348 deletions(-) rename tests/fixtures/submission/links/official/{drill-official-broken-home.yaml => drill-official-broken-docs.yaml} (55%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4dffcfd..cfdc9de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,15 +120,15 @@ jobs: fi echo "repo 核验演练通过:不存在的仓库被拦下" - - name: 演练 4|第三方外链失败只警告,官方/演示站失败硬拦(§7) + - name: 演练 4|第三方外链失败只警告,自研项目外链失败硬拦(§7) run: | HUB_PROJECTS_DIR=tests/fixtures/submission/links/third-party pnpm check:links echo "第三方外链失败仅警告:CI 未失败,符合 §7" if HUB_PROJECTS_DIR=tests/fixtures/submission/links/official pnpm check:links; then - echo "::error::官方/演示站外链失败竟然放行了,§7 硬拦失效" + echo "::error::自研项目外链失败竟然放行了,§7 硬拦失效" exit 1 fi - echo "官方/演示站外链失败硬拦:符合 §7" + echo "自研项目外链失败硬拦:符合 §7" - name: 演练 5|不合规截图必须让 CI 失败并逐条点名(§7) run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc52778..8fbdaa5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,7 +89,6 @@ WorkerHub(hub)是 Cloudflare Workers 生态的中文精选应用目录:自 | `features` | string[] | ✓ | 特性 3–5 条(详情页列表);卡片只显示 tagline | | `category` | enum | ✓ | 主分类,取值见 4.4 | | `tags` | string[] | ✓ | 自由标签 ≤5 个,不得重复 | -| `homepage` | string(url) | ? | 项目官网 / 在线演示站(自研项目填各自 `oneboy.app` 域名);**演示站不可达会被 CI 硬拦** | | `docs_url` | string(url) | ? | 部署/使用文档链接;缺省时页面取仓库 README | | `deploy` | object | ✓ | 部署信息,见 4.3 | | `resources` | enum[] | ✓ | 部署所需 Cloudflare 资源,≥1 个且不重复,见 4.5 | @@ -177,7 +176,6 @@ tags: - 标签一 - 标签二 category: productivity -homepage: https://example.com docs_url: https://github.com/your-org/your-project/blob/main/docs/deploy.md deploy: method: git-integration @@ -209,7 +207,7 @@ pricing_note: 免费层每日 10 万次请求,超过需 Workers Paid($5/月 pnpm install pnpm validate:data # schema、枚举、slug 与文件名一致、slug/repo 查重 pnpm check:repos # repo 存在且为 public(调 GitHub API) -pnpm check:links # 外链可达性(自研与演示站链接失败会硬拦) +pnpm check:links # 外链可达性(自研项目外链失败会硬拦) pnpm check:screenshots # 截图规格 ``` @@ -259,7 +257,7 @@ pnpm check:screenshots # 截图规格 | `tier: verified` 的 `verified_at` + `verified_note_url` | 见第 3 节 | **失败** | | `free_tier != yes` 时 `pricing_note` | 见 4.2 | **失败** | | 外链可达性(`docs_url`、`deploy.url`、`deploy.guide_url`) | HTTP 探测 | **警告**(不硬拦,评审人人工确认) | -| 自研项目的全部外链、任何项目的 `homepage`(演示站) | HTTP 探测 | **失败** | +| 自研项目的全部外链 | HTTP 探测 | **失败** | | 截图规格(webp、宽 ≥1200px、≤300KB) | 见第 6 节 | **失败** | | 投稿 PR 变更范围 | 见第 7 节第 2 步 | **失败** | diff --git a/README.md b/README.md index f1424a9..41f677f 100644 --- a/README.md +++ b/README.md @@ -1,260 +1,47 @@ -# WorkerHub hub · 首页/目录站 +# WorkerHub -Cloudflare Workers 生态的中文精选应用目录:官方自研项目 + 经收录把关的第三方开源项目,每个项目标清部署方式、所需资源与验证等级。 +Cloudflare Workers 生态的中文精选应用目录:自研项目 + 经收录把关的第三方开源项目,每个项目标清部署方式、所需资源与验证等级。 -**本站是纯静态站点**:无后端、无数据库、无鉴权、无站点级 secret(SPEC v1.4 §0 明示例外项)。构建产物是纯静态 HTML,同时发布到主站 `hub.oneboy.app`(Cloudflare Pages)与镜像 `workerhub.github.io`(GitHub Pages),canonical 恒写主域名。 +## 在线访问 -> 当前进度:S1-A 脚手架与数据管线、S1-B 内容数据(官方 7 + 第三方 4)、S2-A 页面与组件(页面 / 统一卡片 / 搜索筛选排序 / 主题三档 / SEO)、S2-B 投稿基建(CONTRIBUTING / PR 模板 / 投稿数据校验)、S3 双线部署(GitHub Actions 工作流 + CF deploy hook + 每日重建 + 本文件两份核对表)均已交付;**上线关口(CF Pages 建项、域名绑定、GitHub Pages 启用)归用户**,团队交付停在 PR,见文末「范围」。 +- 主站: +- 镜像: -## 技术栈(SPEC §8.1) +## 收录什么 -- **Astro 7 + TypeScript**,`output: 'static'`(SSG),零默认 JS,interactive 部分后续用 Astro islands -- **Tailwind CSS 4**(`@tailwindcss/vite`) -- 包管理 **pnpm**;Node 版本由 `.nvmrc` + `engines` 锁定为 **24**,CI 与本地一致 +本站收录两类项目,条目一律指向上游原仓库;本站不托管、不代跑任何项目,部署入口只指向目标仓库的 Deploy Button、GitHub Actions 或其部署文档。 -## 常用命令 +- **自研项目**:WorkerHub 自研、自己维护的项目,仓库在 GitHub 的 WorkerHub 组织下。 +- **第三方项目**:别人开发、可自部署在 Cloudflare Workers / Pages 上的开源项目,经收录门槛审核后收录。 -```bash -pnpm install # 安装依赖 -pnpm dev # 本地开发(http://localhost:4321) -pnpm build # 构建:读数据 → schema 校验 → 抓取/合并自动字段 → 输出 dist/ -pnpm preview # 预览 dist/ -pnpm validate:data # 只跑数据文件 schema 校验 -pnpm validate:submission # 投稿校验三项:repo 存在且 public / 外链可达性 / 截图规格(§7) -pnpm check:repos # 只跑 repo 核验 -pnpm check:links # 只跑外链可达性 -pnpm check:screenshots # 只跑截图规格 -pnpm check:pr-scope # 投稿 PR 变更范围(只允许数据文件与截图) -pnpm fetch:meta # 只跑 GitHub 自动字段抓取 -pnpm health:links # 外链健康巡检(§9.3,每日重建跑的那一步;只出报告不硬拦) -pnpm summary:build # 生成构建摘要 Markdown(§9.2/§9.3,写进 GitHub Actions summary) -pnpm lint # astro check(类型检查)+ prettier --check -pnpm format # prettier 自动格式化 -pnpm test # 单元 + 集成测试(node:test) -``` - -- **构建产物目录:`dist/`**(双线部署都从这里取;CF Pages 构建命令 `pnpm build`,输出目录 `dist`) -- **构建命令:`pnpm build`**(本地与 CI 同一条命令、同一份产物,SPEC §9.1) - -## 数据管线(SPEC §4.1 / §9) - -``` -src/data/projects/.yaml 人工字段(唯一真源,内容子单维护) - │ schema 校验(zod,src/lib/project-schema.ts) - ▼ -scripts/fetch-github-meta.ts GitHub API 抓自动字段(§9.2 白名单) - │ 失败 → 回退缓存 → 无缓存则置空 - ▼ -src/data/cache/github-meta.json 自动字段缓存(随构建滚动更新并提交) - ▼ -astro build 每项目详情页 / 列表页读「人工字段 + 自动字段」 -``` - -- 数据文件是按 §4.1 定义的 `zod` strict 对象:**字段非法、枚举越界、出现未知键或手写自动字段 → 构建失败并点名文件与字段**,不会静默跳过坏数据上线。 -- 同一份 schema 同时被 Astro Content Collections(`src/content.config.ts`)与 CI 校验脚本使用,两层都拦,不会分叉。 -- 自动字段只取 §9.2 白名单:`stargazers_count`、`forks_count`、`language`、`license.spdx_id`、`pushed_at`、`archived`、`releases/latest`、`open_graph_image`。 - -### 自动字段容错(§9.2 硬性) +每个项目标注一个验证等级: -| 情况 | 行为 | -| ---------------------------- | ----------------------------------------------------------- | -| 抓取成功 | 写回缓存 | -| 网络故障 / 超时 / 5xx / 限流 | 用 `src/data/cache/github-meta.json` 上次结果兜底,构建继续 | -| 抓取失败且无缓存 | 该项目自动字段置空,页面正常渲染(排序降级为收录日期) | -| 仓库 404(不存在或私有) | **判为数据错误 → 构建失败**(§7 要求 CI 明确失败) | +- **自研**:WorkerHub 自研项目,由 WorkerHub 团队维护。 +- **已验证**:本站维护者按其文档实际完成过一次部署并留有验证记录。 +- **已收录**:仅通过收录门槛审核,未做部署实测。 -缓存文件只记录既有事实,缺失/损坏时按空缓存处理并打警告,不会阻塞构建。 +## 如何提交你的项目 -### 环境变量 +1. 读 [CONTRIBUTING.md](CONTRIBUTING.md) 的收录范围与五条门槛,确认项目符合。 +2. 在 `src/data/projects/.yaml` 新增一个数据文件,模板见 CONTRIBUTING.md 第 5 节。 +3. 可选:把截图放到 `public/screenshots/.webp`。 +4. 向本仓库提 Pull Request,按 PR 模板逐项勾选门槛并附证据链接。 +5. 等 CI 校验与人工评审,合并后自动上线。 -生产构建无需任何变量。以下只用于本地调试、演练与 CI: +字段说明、分类与部署方式枚举、截图规格、下架与异议通道都在 [CONTRIBUTING.md](CONTRIBUTING.md) 里,这里不重复。 -| 变量 | 默认 | 说明 | -| ------------------------ | --------------------------------- | ---------------------------------------------------------------------------------- | -| `GITHUB_TOKEN` | 空 | CI 用工作流自带只读 token;本地缺省走未认证额度。**不要求、也不允许任何 PAT 入仓** | -| `GITHUB_API_BASE` | `https://api.github.com` | 演练时指向不可达地址即可模拟 API 故障 | -| `HUB_SKIP_FETCH` | 空 | 置 `1` 完全跳过抓取,只用缓存/空值 | -| `HUB_PROJECTS_DIR` | `src/data/projects` | 数据文件目录(演练/测试用) | -| `HUB_META_CACHE` | `src/data/cache/github-meta.json` | 自动字段缓存位置 | -| `HUB_META_REPORT` | `github-meta-report.json` | 本次抓取报告(未入库,CI 可取用) | -| `HUB_VERSION` | 空 | 覆盖页脚版本号(回退链最优先一级);缺省按 `build-info.ts` 的回退链取值 | -| `HUB_SKIP_OG` | 空 | 置 `1` 跳过 OG 图本地化(离线构建/演练用;缺图自动回退首字图) | -| `HUB_OG_FORCE` | 空 | 置 `1` 强制重新抓取仓库 OG 图 | -| `HUB_OG_REPORT` | `og-report.json` | 本次 OG 图本地化报告(未入库) | -| `HUB_CF_ANALYTICS_TOKEN` | 空 | 配置后构建才注入 Cloudflare Web Analytics(无 cookie,§10);缺省不接统计 | +## 本地运行 -### 降级演练(SPEC §12 第 3 条) +需要 Node 24 与 pnpm: ```bash -# 演练 A:API 不可达 + 有缓存 → 走缓存兜底,构建成功 -GITHUB_API_BASE=http://127.0.0.1:9 HUB_PROJECTS_DIR=tests/fixtures/projects-run \ -HUB_META_CACHE=tests/.tmp/cache.json pnpm build - -# 演练 B:API 不可达 + 无缓存 → 自动字段置空,构建成功 -GITHUB_API_BASE=http://127.0.0.1:9 HUB_PROJECTS_DIR=tests/fixtures/projects-run \ -HUB_META_CACHE=tests/.tmp/empty.json pnpm build - -# 演练 C:非法数据 → 构建失败并点名字段 -HUB_PROJECTS_DIR=<放了一个坏文件的目录> pnpm build -``` - -`tests/fixtures/projects-run/` 是演练夹具(指向两个真实 public 仓库),`tests/fixtures/projects/` 是 schema 夹具。两者都不是正式内容。 - -## 页面与组件(SPEC §2 / §4.3 / §8.2 / §8.3 / §10) - -| 路径 | 说明 | -| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `/` | Hero(搜索框 + 官方/第三方/总数统计)、官方项目区(waker 预告位置末位)、精选推荐(第三方 ≤6)、分类快捷入口、最新收录(≤8) | -| `/projects/` | 全量目录:搜索 + 六维筛选 + 五种排序,全部在浏览器本地完成 | -| `/p//` | 项目详情:截图、长介绍、特性、部署信息全表、自动元数据、入口按钮组、同类推荐 ≤4 | -| `/categories//` | 分类页:预置并锁定分类过滤,复用 `Explorer` 与卡片 | -| `/submit/` | 构建时读取仓库根 `CONTRIBUTING.md` 同源渲染(文件缺失时显示占位说明,合入后自动接线) | -| `/about/` | 定位、官方与第三方区别、三级验证等级定义与免责声明、异议/下架通道 | -| `404` | 回首页与全部项目 | -| `/sitemap.xml` `/robots.txt` | 构建时生成,绝对地址恒写 `https://hub.oneboy.app` | - -- **统一卡片**:`src/components/project/project-card.tsx` 一套组件同时用于首页 / 列表(island 内)/ 分类页 / 详情页推荐;静态页里由 Astro 在构建期渲染成 HTML(不下发该组件的 JS),因此三处徽章与入口不可能分叉。 -- **徽章**:`src/components/project/badges.tsx` 统一渲染来源+等级(金/绿/灰,均带文字)、资源(>3 折叠为 `+n`)、难度、免费层、长期未更新 / 即将推出。 -- **截图回退链**:项目截图 → 仓库 OG 图(构建期抓取并本地化到 `public/og/github/-.png`,页面只引用站内路径,绝不热链 GitHub)→ 按分类着色的名称首字图。 -- **搜索/筛选/排序**(`src/lib/project-filter.ts`,纯函数,单测覆盖):搜索命中名称 / tagline / 长介绍 / 标签;六维筛选(分类 / 来源 / 验证等级 / 所需资源 / 难度 / 免费层);排序 = 默认(官方置顶 → 精选 → 收录日期倒序)/ star 降序 / 最近更新 / 名称 / 收录日期倒序,自动字段缺失时降级为收录日期、不报错。筛选状态写入 URL query:勾选与排序用 `pushState`(浏览器后退可还原),搜索输入防抖后 `replaceState`(不刷历史记录)。 -- **主题三档**(`src/components/site/theme-toggle.tsx` + `BaseLayout` 内联脚本):亮 / 暗 / 自动,默认自动;偏好只存 `localStorage`(无登录、无后端);首屏绘制前由 `` 内联脚本应用 `dark` class,防闪烁。 - -## 投稿基建(SPEC §7) - -投稿 = 向本仓库提 PR,只新增/修改 `src/data/projects/.yaml`(及可选截图)。相关文件: - -| 文件 | 作用 | -| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -| `CONTRIBUTING.md`(仓库根) | 收录门槛(五条)、字段说明、数据文件模板、验证等级、下架与异议通道。**与 `/submit/` 页同源**:页面构建时引入本文件,二者不得分叉 | -| `.github/PULL_REQUEST_TEMPLATE.md` | 逐项勾选五条门槛 + 证据链接 + 数据合规自查 + 变更范围声明 | -| `src/lib/submission-checks.ts` | repo 核验 / 外链可达性 / 截图规格的校验逻辑 | -| `src/lib/pr-scope.ts` | 投稿 PR 变更范围(只允许数据文件与截图) | - -投稿数据校验(`pnpm validate:submission`,CI 对投稿 PR 与官方数据 PR 同等适用): - -| 检查 | 失败后果 | -| -------------------------------------------------------------- | -------------------------------------------- | -| schema / 枚举 / 未知字段 / 手写自动字段 | 失败 | -| `slug` 与文件名一致、slug 与 repo 双维度查重 | 失败 | -| `repo` 真实存在且为 public(GitHub API) | 失败(不存在 / 私有 / 无法核验) | -| `tier=verified` 凭证书、`free_tier != yes` 时的 `pricing_note` | 失败 | -| 第三方外链(`docs_url` / `deploy.*`)不可达 | **警告**,评审人人工确认 | -| 官方项目全部外链、任何项目的 `homepage`(演示站)不可达 | 失败 | -| 截图(webp / 宽 ≥1200px / ≤300KB) | 失败 | -| 投稿 PR 改了数据文件与截图之外的文件 | 失败(PR 描述带 `hub-submission-pr` 标记时) | - -演练:`tests/fixtures/submission/` 是投稿校验夹具(不存在的 repo、不可达外链、不合规截图),CI 的 `drills` job 逐项验证「该拦的拦、该放的放」。 - -## 目录结构 - -``` -astro.config.mjs site = https://hub.oneboy.app(canonical 恒写主域名) -src/content.config.ts Content Collections 定义(glob loader + zod schema) -src/data/projects/ 项目数据文件(内容子单维护) -src/data/cache/ GitHub 自动字段缓存 -src/lib/project-schema.ts 数据字段/枚举定义(冻结契约) -src/lib/validate-projects.ts 集合级校验(slug 与文件名一致、slug/repo 查重) -src/lib/submission-checks.ts 投稿校验(repo public / 外链可达性 / 截图规格) -src/lib/pr-scope.ts 投稿 PR 变更范围判定 -src/lib/github-meta.ts 抓取、缓存、降级、异常清单 -src/lib/projects.ts 页面侧取数入口(人工字段 + 自动字段合并、默认排序) -src/lib/project-view.ts 构建期视图模型(解析截图/OG 图是否存在、过期标记) -src/lib/project-types.ts 展示字典与视图类型(客户端 island 也能安全引用) -src/lib/project-filter.ts 搜索 / 六维筛选 / 五种排序 / URL 状态同步 -src/lib/project-entry.ts 卡片主入口与详情页部署按钮(唯一真源) -src/lib/site.ts 站点常量与绝对地址(canonical 恒写主域名) -src/lib/build-info.ts 版本号 / 构建时间 -src/lib/link-health.ts 外链巡检 + 连续失败计数(§9.3) -src/lib/build-summary.ts 构建摘要渲染(§9.2 / §9.3,纯函数) -src/components/ui/ shadcn/ui 组件(Badge / Button / Input / Checkbox / Dialog / Dropdown / Separator) -src/components/project/ 统一卡片、徽章、截图回退 -src/components/site/ 页头页脚、主题切换 island、筛选 island -src/layouts/base-layout.astro SEO/OG/canonical、主题防闪烁、页头页脚 -src/pages/ 首页 / projects / p/ / categories/ / submit / about / 404 / sitemap.xml / robots.txt -public/og/github/ 构建期本地化的仓库 OG 图缓存(§8.3,抓取失败则走首字图) -scripts/ validate-data.ts / validate-submission.ts / check-pr-scope.ts / fetch-github-meta.ts / fetch-og-images.ts / link-health.ts / build-summary.ts -tests/ 单测 + 进程级集成测试 + 夹具 -.github/PULL_REQUEST_TEMPLATE.md 投稿 PR 模板(五条门槛逐项勾选 + 证据栏) -.github/workflows/ci.yml 校验与演练(不含发布) -.github/workflows/deploy.yml 双线部署(GitHub Pages 镜像 + CF Pages deploy hook + 每日重建) -``` - -## 双线部署(SPEC §0 / §8.1 / §9.2 / §9.3) - -同一个提交 → **同一份** `dist/` 产物 → 两条**互相独立**的发布通道: - -| 一线 | 托管 | 地址 | 怎么发 | -| ------------ | ------------------------------ | --------------------- | ------------------------------------------------------------------- | -| 主站 | Cloudflare Pages(Git 集成) | `hub.oneboy.app` | CF 自己从 `main` 构建;本工作流另用 **deploy hook** 触发同版重建 | -| 镜像(备用) | GitHub Pages(来源 = Actions) | `workerhub.github.io` | 本工作流构建后用官方 Pages 发布动作上线(不往仓库写 gh-pages 分支) | - -### 工作流 `.github/workflows/deploy.yml` - -``` -触发:push 到 main(有新提交)/ 每日 cron 19:17 UTC(北京 03:17)/ workflow_dispatch(含演练开关) - │ - ├─ build ──────────── pnpm install → 密钥红线自检 → pnpm build → 产物自检 → 上传 dist/ 与构建报告 - │ │ - │ ├─ link-health ── 仅在定时/手动时跑:全部外链可达性巡检(连续失败计数走 actions/cache,不写仓库) - │ │ - │ ├─ publish-github-pages ────── 官方 Pages 动作发布镜像(environment: github-pages) - │ └─ publish-cloudflare-pages ── POST CF Pages deploy hook(URL 只来自 Secrets) - │ - └─ summary ─────────── 汇总进 GitHub Actions summary + build-summary.md 产物 +pnpm install +pnpm dev # http://localhost:4321 +pnpm build ``` -- **一侧失败不阻塞另一侧**(§0 / §9.2):两个 publish job 只依赖 `build`,彼此**不互为 `needs`**,各自跑、各自红、各自在日志里报错;`summary` 用 `if: always()` 逐侧标注结果。 -- **构建摘要必含**(§9.2 / §9.3):自动字段刷新结果(成功 / 缓存兜底 / 降级置空 / 数据错误 + 逐项降级原因)、archive 与超过 365 天未更新的异常项目清单、外链巡检结果与**连续失败点名**(阈值:连续 2 次)、两侧发布结果。 -- **不自动改数据**:异常项目与坏链只进摘要,是否下架/修正走人工数据 PR;工作流**不向 `main` 写提交**(自动字段缓存如有变化,作为 `reports` 产物上传,由维护者随数据 PR 提交)。 -- **密钥红线**:CF Pages deploy hook URL 只放 GitHub Secrets,名为 `CLOUDFLARE_PAGES_DEPLOY_HOOK`;`build` 里有一道自检,扫到仓库文件里出现 deploy hook URL 直接失败;日志只打印 HTTP 状态码,不回显 URL。 -- **版本号一致性**(§12 第 10 条):页脚版本号由 `src/lib/build-info.ts` 一段代码统一取值,主站与镜像共用、优先级相同,回退链为 ① `HUB_VERSION` → ② `git describe --tags --always` → ③ `CF_PAGES_COMMIT_SHA` 截 7 位 → ④ `v0.0.0-dev`。镜像侧走 Actions 完整历史,命中 ②;主站侧 CF Pages 是浅克隆,`git describe` 必然失败,由 CF Pages 构建环境自带的 `CF_PAGES_COMMIT_SHA` 截 7 位接住,形态与 ② 的短 SHA 一致,两侧页脚可比对。**生产不需要也不应该在控制台手填 `HUB_VERSION`**(① 只留给本地/特殊覆盖)。刻意**不用 `--dirty`**:构建本身会改写自动字段缓存文件,带 `--dirty` 会让每次 CI 构建都得到 `-dirty`,两侧无法比较。 - -### 演练(不发出真实发布) - -`workflow_dispatch` 两个输入: - -| 输入 | 值 | 作用 | -| ------------------ | ---------------------- | --------------------------------------------------------------------------------------- | -| `dry_run` | `true` | 只构建 + 出摘要:**不调** Pages 发布动作、**不调** deploy hook(不读也不打印 hook URL) | -| `simulate_failure` | `pages` / `cloudflare` | 演练时故意让一侧失败,验证另一侧照常走完且有独立报错(仅 `dry_run=true` 下允许) | - -等价地可以从仓库里跑:`pnpm build && pnpm health:links && pnpm summary:build`(摘要直接看 `build-summary.md`)。 - -已知平台限制(不是工作流缺陷): - -1. `workflow_dispatch` 要求该工作流文件已存在于**默认分支**,所以合并进 `main` 之前无法从 UI/API 手动触发; -2. `publish-github-pages` 绑定了 `github-pages` 环境,该环境的部署分支策略只放行 `main`,非 `main` 分支跑真实发布会被环境拦下(演练用 `dry_run=true` 不触碰发布动作,因此不受影响)。 - -## 上线设置核对表(两平台,逐项确认) - -下面这些**全部是用户关口的操作**(团队不代建项目、不绑域名、不启 Pages、不动仓库设置),按顺序打勾即可。 - -### A. Cloudflare Pages(主站 `hub.oneboy.app`) - -- [ ] 创建 Pages 项目,连接 GitHub 仓库 `WorkerHub/workerhub.github.io` -- [ ] 生产分支 = `main`;PR 自动预览开启(预览部署不参与双线同版校验) -- [ ] 构建命令 = `pnpm build`,输出目录 = `dist`(构建镜像的 Node 版本需 ≥ 24,仓库 `.nvmrc` 为 24) -- [ ] 环境变量:无业务变量;如需避免 GitHub API 限流,可加只读 `GITHUB_TOKEN`(可选) -- [ ] Settings → Builds & deployments → **Deploy hooks 生成一条 hook**,把 URL 存进 GitHub Secrets:名称 `CLOUDFLARE_PAGES_DEPLOY_HOOK`(**只进 Secrets,不写进仓库文件、README、评论、工单**) -- [ ] 绑定自定义域名 `hub.oneboy.app`;`workerhub.oneboy.app` 做 301 到主域名 -- [ ] (可选,§10)Cloudflare Web Analytics 站点开启后,把 token 作为构建环境变量 `HUB_CF_ANALYTICS_TOKEN` 注入 - -### B. GitHub Pages(镜像 `workerhub.github.io`) - -- [ ] Settings → Pages → **Source = GitHub Actions**(不是 Deploy from a branch) -- [ ] Settings → Pages → **Custom domain 栏必须留空** ← 硬性项:填任何域名都会让镜像变成跳转站,双线即失效(§0) -- [ ] Settings → Environments → `github-pages` 的部署分支策略放行 `main` -- [ ] Actions 权限:仓库允许 Actions 创建 deployment(默认已允许) - -### C. 合并后的首次验证 - -- [ ] 合并本 PR 后,`main` 上触发一次「双线部署」,两侧均为 ✅(首次正式运行前 B 节若未做,Pages 侧会红——属预期,不是工作流问题) -- [ ] 两侧各抽查三页:页脚版本号一致;镜像侧 canonical 指向 `https://hub.oneboy.app` -- [ ] Actions summary 里能看到:自动字段刷新结果、异常项目清单、链接健康(连续失败点名)、两侧发布结果 -- [ ] 次日检查定时重建是否自动跑过一次(cron 19:17 UTC) +## 声明 -## 范围(防止顺带扩大,SPEC §11) +本站为独立项目,与 Cloudflare, Inc. 无隶属或背书关系;Cloudflare、Workers 为 Cloudflare, Inc. 的商标。第三方项目的版权与责任归其作者。 -- 已交付:S1-A 脚手架与数据管线(schema + 抓取 + 缓存降级 + CI 校验与演练)、S1-B 内容数据(官方 7 + 第三方 4)、S2-A 页面与组件(页面、统一卡片、搜索筛选排序、主题三档、SEO/分享与 sitemap)、S2-B 投稿基建(CONTRIBUTING、PR 模板、投稿数据校验与演练)、S3 双线部署(`.github/workflows/deploy.yml` + 链接健康 + 构建摘要 + 上文两份核对表)。 -- 不在这些单里:PR 合并与域名绑定 / Pages 建项 / Pages 启用 / deploy hook 入 Secrets(用户关口)。 -- 本站不加后端、不加 D1/KV/DO/R2、不加登录鉴权、不引入任何 secret(SPEC §0);唯一的 secret 是 CF Pages deploy hook URL,且只存于 GitHub Secrets。 +GitHub 组织: diff --git a/scripts/link-health.ts b/scripts/link-health.ts index 7777b99..c744d65 100644 --- a/scripts/link-health.ts +++ b/scripts/link-health.ts @@ -4,7 +4,7 @@ * * 用法:`pnpm health:links` * - * 输入:`src/data/projects/*.yaml` 里的全部外链(仓库入口 + homepage / docs_url / deploy url / guide)。 + * 输入:`src/data/projects/*.yaml` 里的全部外链(仓库入口 + docs_url / deploy url / guide)。 * 输出: * - `link-health-report.json`(默认,已在 .gitignore)—— 摘要报告,工作流写进 GitHub Actions summary * - `link-health-state.json`(默认,已在 .gitignore)—— 连续失败计数,CI 侧用 actions/cache 持久化 diff --git a/scripts/validate-submission.ts b/scripts/validate-submission.ts index 9ab47b0..2407b83 100644 --- a/scripts/validate-submission.ts +++ b/scripts/validate-submission.ts @@ -18,7 +18,7 @@ * * 退出码: * 0 没有硬拦问题(允许存在 warning) - * 1 有硬拦问题(§7:repo 不存在/私有、官方与演示站外链失败、截图不合规…) + * 1 有硬拦问题(§7:repo 不存在/私有、自研项目外链失败、截图不合规…) * 传入 --fail-on-warnings 时,warning 也会导致退出码 1 */ import { resolve } from 'node:path'; diff --git a/src/data/projects/cloud-mail.yaml b/src/data/projects/cloud-mail.yaml index d05c8bd..3bba50d 100644 --- a/src/data/projects/cloud-mail.yaml +++ b/src/data/projects/cloud-mail.yaml @@ -6,7 +6,7 @@ tagline_zh: 一个域名搭起自己的邮箱服务:多用户、附件收发 description_zh: >- 基于 Cloudflare 的一站式邮箱服务平台:只要一个自有域名,就能像常规邮箱平台那样创建多个邮箱账号、收发并管理邮件, 用 Workers 替掉常驻服务器。集成 Cloudflare Email 与 Resend 发信,附件存 R2、数据存 D1、缓存走 KV, - 还能用 Workers AI 自动识别邮件验证码,并带管理员后台与开放 API。演示站 skymail.ink,部署步骤见 docs.skymail.ink。 + 还能用 Workers AI 自动识别邮件验证码,并带管理员后台与开放 API。部署步骤见 docs.skymail.ink。 features: - 一个域名开多个邮箱账号,附件收发走 R2,邮件可转发到 Telegram 机器人或其他邮箱 - 发信支持 Cloudflare Email 与 Resend 两种方式,可群发 @@ -19,7 +19,6 @@ tags: - 自托管 - 邮件收发 - Email Workers -homepage: https://skymail.ink docs_url: https://docs.skymail.ink deploy: method: github-actions diff --git a/src/data/projects/edgechat.yaml b/src/data/projects/edgechat.yaml index 1a10c85..53123b6 100644 --- a/src/data/projects/edgechat.yaml +++ b/src/data/projects/edgechat.yaml @@ -7,7 +7,6 @@ description_zh: >- 完全运行在 Cloudflare Workers 上的自部署团队聊天系统:实时消息、公开/私有频道与私信、文件与语音消息, 并支持 Telegram 双向桥接和两个独立部署站点共享同一群的跨实例互联。新消息正文与附件使用 AES-256-GCM 服务端静态加密,应用与数据资源都落在自己的 Cloudflare 账号下,由 GitHub Actions 自动部署与更新。 - 上游的在线演示站是纯前端界面模拟(API、WebSocket、文件上传均在浏览器内存中模拟,无真实后端)。 features: - 实时消息、公开/私有频道与私信,附件存 R2、会话状态存 KV - Telegram 双向桥接:文字、图片、视频、语音、文件双向同步,TG 成员无需注册 @@ -20,7 +19,6 @@ tags: - 即时通讯 - Telegram - 加密 -homepage: https://echat.azora.top docs_url: https://echat.azora.top/guide/getting-started.html deploy: method: github-actions diff --git a/src/data/projects/edgeever.yaml b/src/data/projects/edgeever.yaml index 0fc2b9d..07f0c1f 100644 --- a/src/data/projects/edgeever.yaml +++ b/src/data/projects/edgeever.yaml @@ -19,7 +19,6 @@ tags: - 知识库 - 多端同步 - AI -homepage: https://demo.edgeever.org docs_url: https://github.com/tianma-if/edgeever/blob/main/docs/deploy-cloudflare-button.zh-CN.md deploy: method: git-integration diff --git a/src/data/projects/enotify.yaml b/src/data/projects/enotify.yaml index caff421..46f5a77 100644 --- a/src/data/projects/enotify.yaml +++ b/src/data/projects/enotify.yaml @@ -19,7 +19,6 @@ tags: - 通知 - 订阅管理 - 多渠道 -homepage: https://enotify.oneboy.app docs_url: https://github.com/WorkerHub/eNotify#部署指南 deploy: method: github-actions diff --git a/src/data/projects/someday.yaml b/src/data/projects/someday.yaml index 6369eed..10a52ef 100644 --- a/src/data/projects/someday.yaml +++ b/src/data/projects/someday.yaml @@ -17,7 +17,6 @@ tags: - 写信 - 定时投递 - 邮件 -homepage: https://someday.oneboy.app docs_url: https://github.com/WorkerHub/someday#部署 deploy: method: github-actions diff --git a/src/data/projects/uptimeflare.yaml b/src/data/projects/uptimeflare.yaml index 31280fa..8a1ebb3 100644 --- a/src/data/projects/uptimeflare.yaml +++ b/src/data/projects/uptimeflare.yaml @@ -19,7 +19,6 @@ tags: - 状态页 - 告警 - 免费 -homepage: https://uptimeflare.pages.dev/ docs_url: https://github.com/lyc8503/UptimeFlare/wiki/Setup deploy: method: github-actions diff --git a/src/lib/link-health.ts b/src/lib/link-health.ts index 7ffa5c3..e79e554 100644 --- a/src/lib/link-health.ts +++ b/src/lib/link-health.ts @@ -15,13 +15,7 @@ import { existsSync, readFileSync } from 'node:fs'; import { z } from 'zod'; /** 巡检的外链字段(§9.3「全部外链」:仓库入口 + 数据文件里的全部人工外链) */ -export const LINK_FIELDS = [ - 'repo', - 'homepage', - 'docs_url', - 'deploy.url', - 'deploy.guide_url', -] as const; +export const LINK_FIELDS = ['repo', 'docs_url', 'deploy.url', 'deploy.guide_url'] as const; export type LinkField = (typeof LINK_FIELDS)[number]; export const LINK_HEALTH_STATE_VERSION = 1; @@ -38,7 +32,6 @@ export interface LinkSourceProject { slug: string; data: { repo: string; - homepage?: string | undefined; docs_url?: string | undefined; deploy: { url?: string | undefined; guide_url?: string | undefined }; }; @@ -56,7 +49,6 @@ export function collectProjectLinks(projects: readonly LinkSourceProject[]): Pro for (const project of projects) { const { data } = project; refs.push({ slug: project.slug, field: 'repo', url: `https://github.com/${data.repo}` }); - if (data.homepage) refs.push({ slug: project.slug, field: 'homepage', url: data.homepage }); if (data.docs_url) refs.push({ slug: project.slug, field: 'docs_url', url: data.docs_url }); if (data.deploy.url) refs.push({ slug: project.slug, field: 'deploy.url', url: data.deploy.url }); diff --git a/src/lib/project-entry.ts b/src/lib/project-entry.ts index 68a80bf..c6803f8 100644 --- a/src/lib/project-entry.ts +++ b/src/lib/project-entry.ts @@ -2,7 +2,7 @@ * 入口按钮的唯一真源(SPEC §4.3 卡片主入口 + §5 详情页按钮呈现)。 * * 卡片与详情页都从这里取链接与文案,避免「同一项目在两个页面按钮不一致」。 - * 判定依据只有数据字段:第三方 = 仓库;官方 = 在线演示(有 homepage)或仓库; + * 判定依据只有数据字段:自研与第三方的主入口一律是仓库; * coming-soon(waker 预告位)= 不给部署入口,只给仓库。 */ import { DEPLOY_METHOD_META, type ProjectView } from './project-types'; @@ -10,7 +10,7 @@ import { DEPLOY_METHOD_META, type ProjectView } from './project-types'; export interface EntryLink { href: string; label: string; - kind: 'repo' | 'demo' | 'deploy' | 'docs'; + kind: 'repo' | 'deploy' | 'docs'; /** 外部链接(新标签打开) */ external: boolean; } @@ -24,11 +24,8 @@ const link = (href: string, label: string, kind: EntryLink['kind']): EntryLink = external: isExternal(href), }); -/** 卡片主入口(§4.3):官方=在线演示或仓库;第三方=仓库 */ +/** 卡片主入口(§4.3):一律「查看仓库」 */ export function primaryEntry(project: ProjectView): EntryLink { - if (project.source === 'official' && project.homepage) { - return link(project.homepage, '在线演示', 'demo'); - } return link(project.repoUrl, '查看仓库', 'repo'); } @@ -52,10 +49,9 @@ export function deployAction(project: ProjectView): EntryLink { } } -/** 详情页的补充入口:在线演示 / 部署文档 / 仓库(去重、去空) */ +/** 详情页的补充入口:部署文档 / 仓库(去重、去空) */ export function secondaryEntries(project: ProjectView): EntryLink[] { const candidates: EntryLink[] = []; - if (project.homepage) candidates.push(link(project.homepage, '在线演示', 'demo')); if (project.docsUrl) candidates.push(link(project.docsUrl, '部署文档', 'docs')); candidates.push(link(project.repoUrl, 'GitHub 仓库', 'repo')); diff --git a/src/lib/project-schema.ts b/src/lib/project-schema.ts index 40574d5..3286af7 100644 --- a/src/lib/project-schema.ts +++ b/src/lib/project-schema.ts @@ -145,7 +145,6 @@ export const projectSchema = z .array(z.string().min(1)) .max(5) .refine((v) => new Set(v).size === v.length, { message: 'tags 不得重复' }), - homepage: z.url().optional(), docs_url: z.url().optional(), deploy: deploySchema, resources: z diff --git a/src/lib/project-types.ts b/src/lib/project-types.ts index f2c1d1b..c2e2317 100644 --- a/src/lib/project-types.ts +++ b/src/lib/project-types.ts @@ -195,7 +195,6 @@ export interface ProjectView { repo: string; repoUrl: string; - homepage: string | null; docsUrl: string | null; deploy: { method: DeployMethod; url: string | null; guideUrl: string | null }; diff --git a/src/lib/project-view.ts b/src/lib/project-view.ts index f78c707..e029b51 100644 --- a/src/lib/project-view.ts +++ b/src/lib/project-view.ts @@ -67,7 +67,6 @@ export function toProjectView({ data, meta }: ProjectWithMeta): ProjectView { repo: data.repo, repoUrl: `https://github.com/${data.repo}`, - homepage: data.homepage ?? null, docsUrl: data.docs_url ?? null, deploy: { method: data.deploy.method, diff --git a/src/lib/submission-checks.ts b/src/lib/submission-checks.ts index 2ec3b8d..76a4551 100644 --- a/src/lib/submission-checks.ts +++ b/src/lib/submission-checks.ts @@ -2,13 +2,13 @@ * 投稿数据的三类必检项(SPEC §7「CI 自动校验」,投稿 PR 与官方数据 PR 同等适用): * * 1. `repo` 真实存在且为 public(GitHub REST API 核验) - * 2. 外链可达性(homepage / docs_url / deploy.url / deploy.guide_url) + * 2. 外链可达性(docs_url / deploy.url / deploy.guide_url) * 3. 截图规格(webp、宽 ≥1200px、体积 ≤300KB) * * 严重级别严格照抄 §7 原文: * - `repo` 不存在 / 私有 / 无法核验 → **硬拦**(error) * - 外链失败 → **默认只警告**,由评审人人工确认; - * 但「官方项目的全部外链」与「任何项目的演示站(homepage)」失败 → **硬拦**(error) + * 但「官方项目的全部外链」失败 → **硬拦**(error) * - 例外(返工口径,见 ONE-449):外链返回 **HTTP 403** 时一律降级为 warning。 * CDN(Cloudflare Pages 等)的 bot 防护会拒绝 CI runner 出口 IP,403 说明站点在线、 * 只是不许探针访问,不构成「不可达」结论;输出保留站点名与状态码供人眼复核。 @@ -228,17 +228,16 @@ export async function checkRepos( // 2. 外链可达性(§7) // --------------------------------------------------------------------------- -export type LinkField = 'homepage' | 'docs_url' | 'deploy.url' | 'deploy.guide_url'; +export type LinkField = 'docs_url' | 'deploy.url' | 'deploy.guide_url'; export interface ProjectLink { field: LinkField; url: string; } -/** 该项目的全部外链(§7 列举:homepage / docs / deploy url) */ +/** 该项目的全部外链(§7 列举:docs / deploy url) */ export function collectLinks(data: ProjectInput): ProjectLink[] { const links: ProjectLink[] = []; - if (data.homepage) links.push({ field: 'homepage', url: data.homepage }); if (data.docs_url) links.push({ field: 'docs_url', url: data.docs_url }); if (data.deploy.url) links.push({ field: 'deploy.url', url: data.deploy.url }); if (data.deploy.guide_url) links.push({ field: 'deploy.guide_url', url: data.deploy.guide_url }); @@ -247,13 +246,13 @@ export function collectLinks(data: ProjectInput): ProjectLink[] { /** * 外链失败时的严重级别(§7 原文): - * 「失败给 warning 不硬拦(评审人人工确认);官方项目与演示站链接失败则硬拦」。 - * 即:`source=official` 的任何外链、以及任何项目的 `homepage`(官网/演示站)→ error。 + * 「失败给 warning 不硬拦(评审人人工确认);官方项目链接失败则硬拦」。 + * 即:`source=official` 的任何外链 → error,第三方 → warning。 * * 注意:这只是基础分级;HTTP 403(bot 防护)的例外由 `resolveLinkFailureSeverity` 叠加。 */ -export const linkFailureSeverity = (data: ProjectInput, field: LinkField): Severity => - data.source === 'official' || field === 'homepage' ? 'error' : 'warning'; +export const linkFailureSeverity = (data: ProjectInput, _field: LinkField): Severity => + data.source === 'official' ? 'error' : 'warning'; export interface LinkProbeResult { url: string; diff --git a/tests/build-summary.test.ts b/tests/build-summary.test.ts index 6acd1f6..98ce913 100644 --- a/tests/build-summary.test.ts +++ b/tests/build-summary.test.ts @@ -65,7 +65,7 @@ const links: LinkHealthReport = { rows: [ { url: 'https://zeta.oneboy.app', - field: 'homepage', + field: 'docs_url', slugs: ['zeta'], outcome: 'failed', status: 502, diff --git a/tests/contributing-docs.test.ts b/tests/contributing-docs.test.ts index 6f1cc80..674c664 100644 --- a/tests/contributing-docs.test.ts +++ b/tests/contributing-docs.test.ts @@ -36,7 +36,6 @@ const MANUAL_FIELDS = [ 'features', 'category', 'tags', - 'homepage', 'docs_url', 'deploy', 'resources', diff --git a/tests/fixtures/submission/links/official/drill-official-broken-home.yaml b/tests/fixtures/submission/links/official/drill-official-broken-docs.yaml similarity index 55% rename from tests/fixtures/submission/links/official/drill-official-broken-home.yaml rename to tests/fixtures/submission/links/official/drill-official-broken-docs.yaml index 2c08eef..b8f94f6 100644 --- a/tests/fixtures/submission/links/official/drill-official-broken-home.yaml +++ b/tests/fixtures/submission/links/official/drill-official-broken-docs.yaml @@ -1,9 +1,9 @@ -# 演练夹具:官方项目的 homepage(演示站)不可达 → §7 要求 CI 硬拦 -slug: drill-official-broken-home -name: Drill Official Broken Home +# 演练夹具:自研条目的 docs_url 不可达 → §7 要求 CI 硬拦 +slug: drill-official-broken-docs +name: Drill Official Broken Docs repo: WorkerHub/hub-drill-official source: official -tagline_zh: 演练用官方条目,演示站地址不可达。 +tagline_zh: 演练用自研条目,文档地址不可达。 description_zh: 第一条说明句。第二条说明句。 features: - 特性一 @@ -12,7 +12,7 @@ features: tags: - drill category: notification -homepage: http://127.0.0.1:9/demo +docs_url: http://127.0.0.1:9/docs deploy: method: docs-only resources: diff --git a/tests/link-health.test.ts b/tests/link-health.test.ts index fa99a2f..b6c4d02 100644 --- a/tests/link-health.test.ts +++ b/tests/link-health.test.ts @@ -28,7 +28,6 @@ const project = (slug: string, overrides: Partial = { slug, data: { repo: `WorkerHub/${slug}`, - homepage: `https://${slug}.oneboy.app`, docs_url: `https://github.com/WorkerHub/${slug}#deploy`, deploy: { url: `https://deploy.workers.cloudflare.com/?url=https://github.com/WorkerHub/${slug}`, @@ -46,12 +45,12 @@ const fetchStub = (statuses: Record, fallback = 200): typeof fet test('collectProjectLinks 收集仓库入口与数据文件里的全部外链', () => { const refs = collectProjectLinks([ project('enotify'), - project('waker', { homepage: undefined, docs_url: undefined, deploy: {} }), + project('waker', { docs_url: undefined, deploy: {} }), ]); assert.deepEqual( refs.map((ref) => `${ref.slug}:${ref.field}`), - ['enotify:repo', 'enotify:homepage', 'enotify:docs_url', 'enotify:deploy.url', 'waker:repo'], + ['enotify:repo', 'enotify:docs_url', 'enotify:deploy.url', 'waker:repo'], ); assert.equal(refs[0]!.url, 'https://github.com/WorkerHub/enotify'); }); @@ -66,8 +65,8 @@ test('同一 URL 只检查一次,并合并引用它的项目', async () => { const { report } = await runLinkHealth( [ - { slug: 'alpha', field: 'homepage', url: shared }, - { slug: 'beta', field: 'homepage', url: shared }, + { slug: 'alpha', field: 'docs_url', url: shared }, + { slug: 'beta', field: 'docs_url', url: shared }, ], { fetchImpl }, ); @@ -81,8 +80,8 @@ test('连续失败累计到阈值后点名,恢复可达后计数清零', async const bad = 'https://broken.example.org'; const good = 'https://ok.example.org'; const refs = [ - { slug: 'alpha', field: 'homepage' as const, url: bad }, - { slug: 'beta', field: 'homepage' as const, url: good }, + { slug: 'alpha', field: 'docs_url' as const, url: bad }, + { slug: 'beta', field: 'docs_url' as const, url: good }, ]; const first = await runLinkHealth(refs, { @@ -115,7 +114,7 @@ test('连续失败累计到阈值后点名,恢复可达后计数清零', async test('反爬/限流类状态码归入「需人工确认」,不计入连续失败', async () => { const limited = 'https://protected.example.org'; const { report, state } = await runLinkHealth( - [{ slug: 'alpha', field: 'homepage', url: limited }], + [{ slug: 'alpha', field: 'docs_url', url: limited }], { fetchImpl: fetchStub({ [limited]: 403 }), previous: emptyLinkHealthState(), @@ -138,7 +137,7 @@ test('网络异常不会让巡检抛错,而是记为失败', async () => { throw new Error('ECONNREFUSED'); }) as typeof fetch; - const { report } = await runLinkHealth([{ slug: 'alpha', field: 'homepage', url: down }], { + const { report } = await runLinkHealth([{ slug: 'alpha', field: 'docs_url', url: down }], { fetchImpl, retries: 0, }); diff --git a/tests/project-filter.test.ts b/tests/project-filter.test.ts index 9d56dc3..0817cc9 100644 --- a/tests/project-filter.test.ts +++ b/tests/project-filter.test.ts @@ -43,7 +43,6 @@ function view(overrides: Partial = {}): ProjectView { featured: false, repo: 'demo/demo', repoUrl: 'https://github.com/demo/demo', - homepage: null, docsUrl: null, deploy: { method: 'github-actions', url: null, guideUrl: null }, screenshot: null, @@ -270,25 +269,16 @@ test('§8.2 已选数量与空状态判断', () => { ); }); -test('§4.3 卡片主入口:官方优先在线演示,第三方一律仓库', () => { - const official = view({ - source: 'official', - tier: 'official', - homepage: 'https://enotify.oneboy.app', - }); +test('§4.3 卡片主入口:自研与第三方一律「查看仓库」', () => { + const official = view({ source: 'official', tier: 'official' }); assert.deepEqual( { href: primaryEntry(official).href, label: primaryEntry(official).label }, - { href: 'https://enotify.oneboy.app', label: '在线演示' }, + { href: 'https://github.com/demo/demo', label: '查看仓库' }, ); - // 官方没有线上实例(Zeta / hop / lx-music-server / waker)→ 仓库 - const officialNoHome = view({ source: 'official', tier: 'official', homepage: null }); - assert.equal(primaryEntry(officialNoHome).label, '查看仓库'); - assert.equal(primaryEntry(officialNoHome).href, 'https://github.com/demo/demo'); - - // 第三方即使有 demo 也以仓库为主入口(§4.3) - const thirdParty = view({ homepage: 'https://demo.example.org' }); + const thirdParty = view(); assert.equal(primaryEntry(thirdParty).label, '查看仓库'); + assert.equal(primaryEntry(thirdParty).href, 'https://github.com/demo/demo'); }); test('§5 详情页部署按钮:按 deploy.method 如实呈现,不承诺一键部署', () => { @@ -324,14 +314,23 @@ test('§5 详情页部署按钮:按 deploy.method 如实呈现,不承诺一 }); test('§5 详情页补充入口:与主按钮去重,空链接不出现', () => { - const project = view({ - homepage: 'https://demo.example.org', + // 主按钮已用 docs(git-integration 指向 guide_url)→ 补充入口只剩仓库 + const deduped = view({ docsUrl: 'https://demo.example.org/docs', deploy: { method: 'git-integration', url: null, guideUrl: 'https://demo.example.org/docs' }, }); - const entries = secondaryEntries(project); - const hrefs = entries.map((entry) => entry.href); - assert.deepEqual(hrefs, ['https://demo.example.org', 'https://github.com/demo/demo']); + assert.deepEqual( + secondaryEntries(deduped).map((entry) => entry.href), + ['https://github.com/demo/demo'], + ); + + // docs 与主按钮不同 → docs + 仓库两条 + const both = view({ + docsUrl: 'https://demo.example.org/guide', + deploy: { method: 'git-integration', url: null, guideUrl: 'https://demo.example.org/docs' }, + }); + const hrefs = secondaryEntries(both).map((entry) => entry.href); + assert.deepEqual(hrefs, ['https://demo.example.org/guide', 'https://github.com/demo/demo']); assert.equal(new Set(hrefs).size, hrefs.length); }); diff --git a/tests/project-schema.test.ts b/tests/project-schema.test.ts index f411f80..718b053 100644 --- a/tests/project-schema.test.ts +++ b/tests/project-schema.test.ts @@ -170,6 +170,12 @@ test('§4.1 未知字段直接失败(防拼写错误静默丢字段)', () => assert.match(issueMessages(result), /tagline/); }); +test('已下线的 homepage 字段被拒收(防被重新挂回)', () => { + const result = run({ ...baseProject(), homepage: 'https://example.com' }); + assert.equal(result.ok, false, '数据文件里写 homepage 应当校验失败'); + assertFieldFlagged(result, 'homepage'); +}); + test('§5 deploy.method 枚举与 Deploy Button URL 规范', () => { assertFieldFlagged(run({ ...baseProject(), deploy: { method: 'nope' } }), 'deploy'); diff --git a/tests/submission-checks.test.ts b/tests/submission-checks.test.ts index 24afbb3..dec4259 100644 --- a/tests/submission-checks.test.ts +++ b/tests/submission-checks.test.ts @@ -150,12 +150,11 @@ test('repo 全部通过时不产出 findings', async () => { // 外链可达性与严重级别 // --------------------------------------------------------------------------- -test('§7 外链分级:官方项目全部硬拦、任何项目的演示站(homepage)硬拦、其余仅警告', () => { +test('§7 外链分级:官方项目全部硬拦、第三方仅警告', () => { const thirdParty = baseProject(); assert.equal(linkFailureSeverity(thirdParty, 'docs_url'), 'warning'); assert.equal(linkFailureSeverity(thirdParty, 'deploy.url'), 'warning'); assert.equal(linkFailureSeverity(thirdParty, 'deploy.guide_url'), 'warning'); - assert.equal(linkFailureSeverity(thirdParty, 'homepage'), 'error'); const official = baseProject({ source: 'official', @@ -163,13 +162,12 @@ test('§7 外链分级:官方项目全部硬拦、任何项目的演示站(h tier: 'official', }); assert.equal(linkFailureSeverity(official, 'docs_url'), 'error'); - assert.equal(linkFailureSeverity(official, 'homepage'), 'error'); + assert.equal(linkFailureSeverity(official, 'deploy.url'), 'error'); }); test('§7 只收集实际填写的字段(含 deploy.url / guide_url)', () => { const links = collectLinks( baseProject({ - homepage: 'https://example.com', docs_url: 'https://example.com/docs', deploy: { method: 'deploy-button', @@ -180,7 +178,7 @@ test('§7 只收集实际填写的字段(含 deploy.url / guide_url)', () => ); assert.deepEqual( links.map((link) => link.field), - ['homepage', 'docs_url', 'deploy.url', 'deploy.guide_url'], + ['docs_url', 'deploy.url', 'deploy.guide_url'], ); assert.deepEqual(collectLinks(baseProject()), []); }); @@ -217,17 +215,22 @@ test('§7 第三方外链失败 → warning(不阻断 CI)', async () => { assert.equal(summarize(findings).errors.length, 0); }); -test('§7 官方项目 / 演示站链接失败 → error(硬拦)', async () => { +test('§7 官方项目外链失败 → error(硬拦)', async () => { const findings = await checkLinks( [ - target({ slug: 'demo-official', homepage: 'https://demo.example.com' }), target({ - slug: 'demo-official-2', + slug: 'demo-official', repo: 'WorkerHub/eNotify', source: 'official', tier: 'official', docs_url: 'https://docs.example.com', - homepage: undefined, + }), + target({ + slug: 'demo-official-2', + repo: 'WorkerHub/someday', + source: 'official', + tier: 'official', + deploy: { method: 'github-actions', guide_url: 'https://guide.example.com' }, }), ], { @@ -239,7 +242,7 @@ test('§7 官方项目 / 演示站链接失败 → error(硬拦)', async () assert.ok(findings.every((finding) => finding.severity === 'error')); }); -test('ONE-449 HTTP 403(bot 防护)→ 官方演示站也降级为 warning,不判 fail', async () => { +test('ONE-449 HTTP 403(bot 防护)→ 官方外链也降级为 warning,不判 fail', async () => { const findings = await checkLinks( [ target({ @@ -248,7 +251,7 @@ test('ONE-449 HTTP 403(bot 防护)→ 官方演示站也降级为 warning, repo: 'WorkerHub/eNotify', source: 'official', tier: 'official', - homepage: 'https://enotify.oneboy.app', + docs_url: 'https://enotify.example.com/docs', }), target({ slug: 'post', @@ -256,7 +259,7 @@ test('ONE-449 HTTP 403(bot 防护)→ 官方演示站也降级为 warning, repo: 'WorkerHub/post', source: 'official', tier: 'official', - homepage: 'https://post.oneboy.app', + docs_url: 'https://post.example.com/docs', }), ], { @@ -276,9 +279,15 @@ test('ONE-449 HTTP 403(bot 防护)→ 官方演示站也降级为 warning, }); test('ONE-449 403 例外只针对 403:真不可达与 404 依旧判 fail(fail 分支未被放宽)', async () => { - const officialHome = { slug: 'dead-home', homepage: 'https://dead.example.com' }; + const officialDocs = { + slug: 'dead-docs', + repo: 'WorkerHub/eNotify', + source: 'official', + tier: 'official', + docs_url: 'https://dead.example.com/docs', + }; - const refused = await checkLinks([target(officialHome)], { + const refused = await checkLinks([target(officialDocs)], { retries: 0, fetchImpl: async () => { throw new TypeError('fetch failed'); @@ -288,7 +297,7 @@ test('ONE-449 403 例外只针对 403:真不可达与 404 依旧判 fail(fai assert.equal(refused[0]!.severity, 'error'); assert.match(refused[0]!.message, /请求失败/); - const notFound = await checkLinks([target(officialHome)], { + const notFound = await checkLinks([target(officialDocs)], { retries: 0, fetchImpl: async () => new Response('nope', { status: 404 }), }); @@ -296,7 +305,7 @@ test('ONE-449 403 例外只针对 403:真不可达与 404 依旧判 fail(fai assert.equal(notFound[0]!.severity, 'error'); assert.match(notFound[0]!.message, /404/); - const serverError = await checkLinks([target(officialHome)], { + const serverError = await checkLinks([target(officialDocs)], { retries: 0, fetchImpl: async () => new Response('boom', { status: 500 }), }); @@ -314,14 +323,14 @@ test('resolveLinkFailureSeverity:仅 403 降级,其余沿用 §7 基础分 assert.equal(isBotProtectionStatus(404), false); assert.equal(isBotProtectionStatus(undefined), false); - assert.equal(resolveLinkFailureSeverity(official, 'homepage', 403), 'warning'); - assert.equal(resolveLinkFailureSeverity(official, 'homepage', 404), 'error'); - assert.equal(resolveLinkFailureSeverity(official, 'homepage'), 'error'); + assert.equal(resolveLinkFailureSeverity(official, 'docs_url', 403), 'warning'); + assert.equal(resolveLinkFailureSeverity(official, 'docs_url', 404), 'error'); + assert.equal(resolveLinkFailureSeverity(official, 'docs_url'), 'error'); assert.equal(resolveLinkFailureSeverity(baseProject(), 'docs_url', 403), 'warning'); assert.equal(resolveLinkFailureSeverity(baseProject(), 'docs_url', 503), 'warning'); // 基础分级本身不变(§7 原文口径) - assert.equal(linkFailureSeverity(official, 'homepage'), 'error'); + assert.equal(linkFailureSeverity(official, 'docs_url'), 'error'); }); test('probeUrl:403 视为不可达但带上状态码,供上层降级判断', async () => { diff --git a/tests/submission-cli.test.ts b/tests/submission-cli.test.ts index d1ddd8e..03be253 100644 --- a/tests/submission-cli.test.ts +++ b/tests/submission-cli.test.ts @@ -75,12 +75,12 @@ test('§7 第三方外链失败 → 警告不阻断(退出码 0)', () => { assert.match(result.output, /docs_url/); }); -test('§7 官方 / 演示站外链失败 → CLI 失败(硬拦)', () => { +test('§7 官方外链失败 → CLI 失败(硬拦)', () => { const result = run(['--checks=links'], { HUB_PROJECTS_DIR: join(FIXTURES, 'submission', 'links', 'official'), }); assert.equal(result.status, 1, result.output); - assert.match(result.output, /homepage/); + assert.match(result.output, /docs_url/); }); test('§7 GitHub API 不可达 → repo 核验失败(无法核验也硬拦并提示重跑)', () => { @@ -102,7 +102,7 @@ test('§7 --fail-on-warnings 把外链警告升级为失败(维护者本地复 assert.match(result.output, /警告 2 项/); }); -test('ONE-449 官方演示站 403(bot 防护)→ CLI 退出码 0,日志可见站点名与 403', async () => { +test('ONE-449 官方外链 403(bot 防护)→ CLI 退出码 0,日志可见站点名与 403', async () => { // 本地服务固定回 403,模拟 Cloudflare bot 防护对 CI runner 出口 IP 的拒绝 const server = createServer((_request, response) => { response.writeHead(403, { 'content-type': 'text/html; charset=utf-8' }); @@ -121,7 +121,7 @@ test('ONE-449 官方演示站 403(bot 防护)→ CLI 退出码 0,日志可 'name: Drill Bot Protected', 'repo: WorkerHub/hub-drill-official', 'source: official', - 'tagline_zh: 演练用官方条目,演示站被 bot 防护拦截。', + 'tagline_zh: 演练用自研条目,文档地址被 bot 防护拦截。', 'description_zh: 第一条说明句。第二条说明句。', 'features:', ' - 特性一', @@ -130,7 +130,7 @@ test('ONE-449 官方演示站 403(bot 防护)→ CLI 退出码 0,日志可 'tags:', ' - drill', 'category: notification', - `homepage: http://127.0.0.1:${port}/demo`, + `docs_url: http://127.0.0.1:${port}/docs`, 'deploy:', ' method: docs-only', 'resources:',