Repository navigation
S1-A:Astro 脚手架与数据管线(schema 校验 + GitHub 抓取 + 缓存降级) - #1
Merged
Merged
Conversation
- Astro 7 + TypeScript 脚手架、Tailwind CSS 4、pnpm、Node 24(.nvmrc + engines) - src/data/projects/<slug>.yaml 人工字段 schema(§4.1/§4.2/§5/§6 全字段与枚举), strict 对象拒绝未知键、拒绝手写自动字段;Content Collections 与 CI 脚本共用同一 schema - GitHub 自动字段抓取(§9.2 白名单):stargazers/forks/language/license/pushed_at/ archived/latest release/open_graph_image,只读公开 API、不需 PAT - 缓存降级(§9.2 硬性):网络/超时/5xx/限流 → src/data/cache/github-meta.json 兜底; 无缓存则自动字段置空页面照常渲染;仓库 404 判为数据错误让 CI 失败 - pnpm build 一条命令产出 dist/;构建报告含抓取结局与 archive/久未更新异常清单 - 42 个测试(schema 全规则 + 抓取降级 + 进程级集成演练),CI 含降级与守卫演练作业 - 占位页仅证明管线可用,正式页面与组件留 S2-A
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
S1-A:脚手架与数据管线
父单 ONE-411(hub v1)子单 S1-A 交付。规格唯一来源:SPEC v1.4(父单描述内嵌)。
本 PR 做了什么
output: 'static')+ Tailwind CSS 4(@tailwindcss/vite),包管理 pnpm,Node 版本锁定为 24(.nvmrc+engines,CI 用node-version-file: .nvmrc)。src/data/projects/<slug>.yaml由 zod strict 对象定义,覆盖 §4.1 全部人工字段、§4.2 分类枚举、§5deploy.method枚举、§6tier枚举,外加全部条件必填规则。同一份 schema 同时被 Astro Content Collections(src/content.config.ts)与 CI 校验脚本(scripts/validate-data.ts)使用,两层都拦。字段非法 / 枚举越界 / 出现未知键 / 手写自动字段 → 构建失败并点名文件与字段。stargazers_count、forks_count、language、license.spdx_id、pushed_at、archived、releases/latest(tag + 日期)、open_graph_image。只读公开 API,CI 用工作流自带GITHUB_TOKEN,本地无 token 走未认证额度;不要求任何 PAT 入仓。src/data/cache/github-meta.json(随构建滚动更新,仓库维护者或部署子单提交);无缓存则自动字段留空、页面照常渲染。仓库 404(不存在或私有)判为数据错误,按 §7 让 CI 失败。pnpm build一条命令:校验数据 → 抓取并合并自动字段 →astro build→ 输出dist/;构建报告(github-meta-report.json,未入库)含每项抓取结局与 §6.3 archive / 超 12 个月未更新的异常清单。改动文件
自测证据(本地,Node 24.21.0 / pnpm 10.33.0)
pnpm install --frozen-lockfile && pnpm build→ 成功,产出dist/index.html+dist/_astro/*.css(Tailwind 生效)。pnpm lint(astro check类型检查 +prettier --check)→ 0 errors / 0 warnings,格式全绿。pnpm test→ 42 passed / 0 failed / 0 skipped(schema 全规则单测、抓取与缓存降级单测、进程级集成演练)。category: not-a-category+difficulty: 9的坏数据 →pnpm validate:data退出 1,输出✗ bad-one.yaml → 字段 category:Invalid option …、✗ bad-one.yaml → 字段 difficulty:Too big …pnpm build退出 1(同一报错)astro build也退出 1,InvalidContentEntryDataError点名category/difficultyGITHUB_API_BASE=http://127.0.0.1:9+ 有缓存 → 退出 0,报告fromCache: 2,缓存未被改写GITHUB_API_BASE=http://127.0.0.1:9+ 空缓存 → 退出 0,报告degradedToEmpty: 2,页面照常产出(star 列显示—)cloudflare/workers-sdk、maillab/cloud-mail)→ 退出 0,star/license/release 全部写入缓存给内容子单(S1-B)的对接说明
src/data/projects/<slug>.yaml,slug 必须与文件名一致;repo全站唯一(与 slug 双维度查重)。?的字段都是必填,tags也是必填(可以为[],不能省略)。source: official时repoowner 必须是WorkerHub、tier必须是official、不能用featured;tier: verified必须带verified_at+verified_note_url;free_tier非yes必须带pricing_note;status: coming-soon不得带deploy.url;deploy.method: deploy-button的url必须是官方 Deploy Button 格式。description_zh必须 2–4 句(以 。!? 计句),tagline_zh≤40 字,features3–5 条。说明 / 边界
main上先落了一条只含 README 的引导提交(无代码);全部交付在本 PR 分支。合并关口归你们,未自行合并、未部署。https://opengraph.githubassets.com/1/<owner>/<repo>(稳定地址),本地化缓存到public/属 §8.3 截图回退链,建议由 S2-A 一并落地。