@teamix-evo/registry 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Teamix Evo Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # @teamix-evo/registry
2
+
3
+ > Teamix Evo 协议包 — 提供 Schema、类型、加载器、校验器和策略决策引擎。
4
+
5
+ ## 定位
6
+
7
+ registry 是整个 Teamix Evo 架构的**协议层**,负责定义:
8
+
9
+ - 资源清单(VariantManifest)的结构约束
10
+ - 项目配置(ProjectConfig)的 Schema
11
+ - 安装状态(InstalledManifest)的追踪格式
12
+ - 三种更新策略(frozen / regenerable / managed)的决策逻辑
13
+ - Managed Regions 标记的解析与替换
14
+
15
+ CLI 包和 design 包都依赖本包的协议定义工作。
16
+
17
+ ## 目录结构
18
+
19
+ ```
20
+ packages/registry/
21
+ ├── src/
22
+ │ ├── schema/
23
+ │ │ ├── index.ts # Schema 统一导出
24
+ │ │ ├── manifest.ts # VariantManifest Zod Schema
25
+ │ │ ├── config.ts # ProjectConfig Zod Schema
26
+ │ │ └── installed.ts # InstalledManifest Zod Schema
27
+ │ ├── types.ts # 从 Schema 推导的 TypeScript 类型
28
+ │ ├── loader.ts # 从文件系统加载 manifest
29
+ │ ├── validator.ts # 校验封装 + 友好错误消息
30
+ │ ├── strategy.ts # updateStrategy 决策函数
31
+ │ ├── managed-regions.ts # HTML 标记区解析与替换
32
+ │ ├── index.ts # 公共导出入口
33
+ │ └── __tests__/ # 单元测试
34
+ ├── tsup.config.ts # 构建配置(ESM + CJS + DTS)
35
+ ├── tsconfig.json
36
+ └── package.json
37
+ ```
38
+
39
+ ## 研发流程
40
+
41
+ ### 1. 环境准备
42
+
43
+ ```bash
44
+ # 在仓库根目录
45
+ pnpm install
46
+ ```
47
+
48
+ ### 2. 开发
49
+
50
+ ```bash
51
+ # 监听模式构建(修改即时编译)
52
+ pnpm --filter @teamix-evo/registry dev
53
+ ```
54
+
55
+ ### 3. 新增 / 修改 Schema
56
+
57
+ 1. 在 `src/schema/` 中使用 Zod 定义或修改 Schema
58
+ 2. 在 `src/types.ts` 中通过 `z.infer<typeof XxxSchema>` 导出对应类型
59
+ 3. 在 `src/index.ts` 中确保新增的 Schema 和类型被导出
60
+ 4. 如需新增校验函数,在 `src/validator.ts` 中添加
61
+
62
+ ### 4. 修改策略逻辑
63
+
64
+ - `src/strategy.ts` — 修改 `shouldUpdate` 或 `getUpdateAction`
65
+ - `src/managed-regions.ts` — 修改标记解析或替换逻辑
66
+
67
+ ### 5. 测试
68
+
69
+ ```bash
70
+ # 运行全部测试
71
+ pnpm --filter @teamix-evo/registry test
72
+
73
+ # 监听模式
74
+ pnpm --filter @teamix-evo/registry test:watch
75
+ ```
76
+
77
+ 测试文件位于 `src/__tests__/`,覆盖:
78
+
79
+ - `manifest.test.ts` — VariantManifest Schema 校验
80
+ - `config.test.ts` — ProjectConfig Schema 校验
81
+ - `installed.test.ts` — InstalledManifest Schema 校验
82
+ - `validator.test.ts` — 友好错误消息格式化
83
+ - `strategy.test.ts` — 三种策略决策逻辑
84
+ - `managed-regions.test.ts` — 标记解析、替换、错误检测
85
+
86
+ ### 6. 类型检查
87
+
88
+ ```bash
89
+ pnpm --filter @teamix-evo/registry typecheck
90
+ ```
91
+
92
+ ### 7. 构建
93
+
94
+ ```bash
95
+ pnpm --filter @teamix-evo/registry build
96
+ ```
97
+
98
+ 产物输出到 `dist/`,包含:
99
+
100
+ - `index.js` — ESM 格式
101
+ - `index.cjs` — CommonJS 格式
102
+ - `index.d.ts` — TypeScript 声明
103
+
104
+ ### 8. 发布前检查
105
+
106
+ - 确保所有测试通过
107
+ - 确保类型检查通过
108
+ - 本包与 `teamix-evo`(CLI)使用 **linked** 版本策略,需一起发布
109
+
110
+ ## 关键约定
111
+
112
+ - 所有 Schema 使用 [Zod](https://zod.dev/) 定义,运行时校验 + 编译时类型推导一体
113
+ - `Result<T>` 类型用于校验返回,避免 throw(除 loader 和 managed-regions 外)
114
+ - managed regions 标记格式:`<!-- teamix-evo:managed:start id="xxx" -->...<!-- teamix-evo:managed:end id="xxx" -->`
115
+ - 同一文件中 region id 不得重复
116
+
117
+ ## 依赖关系
118
+
119
+ ```
120
+ 本包无内部包依赖
121
+ CLI 包 → 依赖本包
122
+ design 包 → devDependencies 引用本包(验证脚本)
123
+ ```