贡献指南
evjs 单仓库的内部开发指南。
项目信息
- 名称:evjs,包 scope
@evjs/* - 仓库:afx-team/evjs
- CLI:
@evjs/cli提供的ev - Linter:Biome
- 模块:仅 ESM
设置
git clone https://github.com/afx-team/evjs.git
cd evjs
npm install
命令
npm run build
npm run test
npm run test:e2e
npm run check-types
npm run lint
npx biome check --write
编码规则
- Import 放在文件顶部,纯类型使用
import type。 - 使用 Biome formatting/linting。没有具体理由时避免
any与宽泛 namespace import。 - 新应用只使用一种 Page-and-Route 模型:
src/pages/**/page.*、可选构建期page.config.ts、目录派生 URL 与routing.mode。 - Page 私有组件、hook、model、service、测试、样式放入 Page 目录,不需要
_。 - canonical client route 目录使用
$param、终止$...splat与(group)。Server request Route 使用严格的src/apis/**/api.*positive anchor,URL 由目录派生。 - 新示例使用 canonical
page.*、page.config.ts与routing.mode;显式application.routes只用于覆盖 config-route normalizer 的聚焦 fixture。 - Server function 以
"use server";开头,只导出命名 callable。 - Config/build import 保留在
@evjs/ev;应用源码使用@evjs/ev/route、/navigation、/query、/server-context、/transport。Standalone runtime 直接导入@evjs/client/@evjs/server。 - 框架语义位于
@evjs/evbuild internal,normalized contract 位于@evjs/shared/manifest;bundler adapter 只消费 BuildPlan 并返回事实。 .ev、dist、.turbo、node_modules与 route-type declaration 都是 生成物。
常见任务
添加 Page 路由
- 创建
src/pages/<url-segments>/page.tsx。 - 默认导出 Page component。
- 需要时使用
$param、终止$...splat或(group)目录。 - Page 私有源码放在同一目录,不需要
_前缀。 - Page 需要静态标题、受支持的 named metadata、core rendering 字段或已安装插件的
Page settings 时添加
page.config.ts;plugin settings 供 runtime 消费时需要插件 显式投影。
添加服务端函数
- 在调用方或领域代码旁创建 reachable
[name].server.ts。 - 顶部添加
"use server";。 - 导出命名 async callable。
- 通过
@evjs/ev/query消费。
添加服务端文件路由
- 在
src/apis下创建 URL 目录并添加api.ts锚点。 - 从锚点导出
GET、POST等大写 HTTP handler。 - Helper 保持为普通 colocated 非
api.*module。 - Middleware 使用
src/middleware.ts或src/apis/**/middleware.ts。
添加示例
- 在
examples/下添加 private workspace package。 - 使用 canonical
routing.mode与page.*route directory。 - 添加
index.html和所需 workspace dependency。 - 只有作为支持的用户模板时才新增/更新 create-app mapping。
- 添加聚焦 unit/e2e validation。
- 显式 route-tree 方言放在名称清晰的 config-route fixture,不进入 canonical template。
修改 Page 或 Route 约定
- 先更新 config resolution 与 graph normalization。
- 同时更新中英文
project-structure、file-conventions、config 与相关 example。 - 补充 graph、diagnostic、scaffold 与 config-route coverage。
- 运行仓库 validation gate。
发布新版本
- 使用待发布版本的
vX.Y.Ztag 创建 GitHub Release。 - Release automation 同步内部 package version 并发布。
- 不要在本地修改 workspace internal
"*"dependency。