@robsun/create-keystone-app 0.2.13 → 0.4.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/README.md +46 -43
- package/dist/create-keystone-app.js +347 -10
- package/dist/create-module.js +1219 -607
- package/package.json +22 -23
- package/template/.claude/skills/keystone-implement/SKILL.md +113 -0
- package/template/.claude/skills/keystone-implement/references/CHECKLIST.md +91 -0
- package/template/.claude/skills/keystone-implement/references/PATTERNS.md +1088 -0
- package/template/.claude/skills/keystone-implement/references/SCHEMA.md +135 -0
- package/template/.claude/skills/keystone-implement/references/TESTING.md +231 -0
- package/template/.claude/skills/keystone-requirements/SKILL.md +296 -0
- package/template/.claude/skills/keystone-requirements/references/CONFIRM_TEMPLATE.md +170 -0
- package/template/.claude/skills/keystone-requirements/references/SCHEMA.md +135 -0
- package/template/.eslintrc.js +3 -0
- package/template/.github/workflows/ci.yml +30 -0
- package/template/.github/workflows/release.yml +32 -0
- package/template/.golangci.yml +11 -0
- package/template/README.md +81 -73
- package/template/apps/server/README.md +8 -0
- package/template/apps/server/cmd/server/main.go +27 -185
- package/template/apps/server/config.example.yaml +31 -1
- package/template/apps/server/config.yaml +31 -1
- package/template/apps/server/go.mod +60 -18
- package/template/apps/server/go.sum +183 -31
- package/template/apps/server/internal/frontend/embed.go +3 -8
- package/template/apps/server/internal/modules/example/README.md +18 -0
- package/template/apps/server/internal/modules/example/api/handler/handler_test.go +9 -0
- package/template/apps/server/internal/modules/example/api/handler/item_handler.go +468 -165
- package/template/apps/server/internal/modules/example/bootstrap/seeds/item.go +217 -8
- package/template/apps/server/internal/modules/example/domain/models/item.go +40 -7
- package/template/apps/server/internal/modules/example/domain/service/approval_callback.go +68 -0
- package/template/apps/server/internal/modules/example/domain/service/approval_schema.go +41 -0
- package/template/apps/server/internal/modules/example/domain/service/errors.go +20 -22
- package/template/apps/server/internal/modules/example/domain/service/item_service.go +267 -7
- package/template/apps/server/internal/modules/example/domain/service/item_service_test.go +281 -0
- package/template/apps/server/internal/modules/example/i18n/keys.go +32 -20
- package/template/apps/server/internal/modules/example/i18n/locales/en-US.json +30 -18
- package/template/apps/server/internal/modules/example/i18n/locales/zh-CN.json +30 -18
- package/template/apps/server/internal/modules/example/infra/exporter/item_exporter.go +119 -0
- package/template/apps/server/internal/modules/example/infra/importer/item_importer.go +77 -0
- package/template/apps/server/internal/modules/example/infra/repository/item_repository.go +99 -49
- package/template/apps/server/internal/modules/example/module.go +171 -97
- package/template/apps/server/internal/modules/example/tests/integration_test.go +7 -0
- package/template/apps/server/internal/modules/manifest.go +7 -7
- package/template/apps/web/README.md +4 -2
- package/template/apps/web/package.json +1 -1
- package/template/apps/web/src/app.config.ts +8 -6
- package/template/apps/web/src/index.css +7 -3
- package/template/apps/web/src/main.tsx +2 -5
- package/template/apps/web/src/modules/example/help/en-US/faq.md +27 -0
- package/template/apps/web/src/modules/example/help/en-US/items.md +30 -0
- package/template/apps/web/src/modules/example/help/en-US/overview.md +31 -0
- package/template/apps/web/src/modules/example/help/zh-CN/faq.md +27 -0
- package/template/apps/web/src/modules/example/help/zh-CN/items.md +31 -0
- package/template/apps/web/src/modules/example/help/zh-CN/overview.md +32 -0
- package/template/apps/web/src/modules/example/locales/en-US/example.json +99 -32
- package/template/apps/web/src/modules/example/locales/zh-CN/example.json +85 -18
- package/template/apps/web/src/modules/example/pages/ExampleItemsPage.tsx +840 -237
- package/template/apps/web/src/modules/example/services/exampleItems.ts +79 -8
- package/template/apps/web/src/modules/example/types.ts +14 -1
- package/template/apps/web/src/modules/index.ts +1 -0
- package/template/apps/web/vite.config.ts +9 -3
- package/template/docs/CONVENTIONS.md +10 -7
- package/template/package.json +4 -5
- package/template/pnpm-lock.yaml +76 -5
- package/template/scripts/build.bat +15 -3
- package/template/scripts/build.sh +9 -3
- package/template/scripts/check-help.js +249 -0
- package/template/scripts/compress-assets.js +89 -0
- package/template/scripts/test.bat +23 -0
- package/template/scripts/test.sh +16 -0
- package/template/.claude/skills/keystone-dev/SKILL.md +0 -103
- package/template/.claude/skills/keystone-dev/references/APPROVAL.md +0 -121
- package/template/.claude/skills/keystone-dev/references/CAPABILITIES.md +0 -261
- package/template/.claude/skills/keystone-dev/references/TEMPLATES.md +0 -532
- package/template/.claude/skills/keystone-dev/references/TESTING.md +0 -44
- package/template/.codex/skills/keystone-dev/SKILL.md +0 -103
- package/template/.codex/skills/keystone-dev/references/APPROVAL.md +0 -121
- package/template/.codex/skills/keystone-dev/references/CAPABILITIES.md +0 -261
- package/template/.codex/skills/keystone-dev/references/TEMPLATES.md +0 -532
- package/template/.codex/skills/keystone-dev/references/TESTING.md +0 -44
- package/template/apps/server/internal/app/routes/module_routes.go +0 -16
- package/template/apps/server/internal/app/routes/routes.go +0 -226
- package/template/apps/server/internal/app/startup/startup.go +0 -74
- package/template/apps/server/internal/frontend/handler.go +0 -122
- package/template/apps/server/internal/modules/registry.go +0 -145
- package/template/apps/web/src/modules/example/help/faq.md +0 -23
- package/template/apps/web/src/modules/example/help/items.md +0 -26
- package/template/apps/web/src/modules/example/help/overview.md +0 -25
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# 需求确认模板
|
|
2
|
+
|
|
3
|
+
**用途**:在用户确认需求前,必须按此模板完整展示所有收集到的信息。
|
|
4
|
+
|
|
5
|
+
**重要**:每次确认必须严格按此模板展示,确保信息完整一致,不可遗漏任何部分。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 模板格式
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
📋 需求确认单
|
|
13
|
+
|
|
14
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
15
|
+
|
|
16
|
+
## 1. 元信息
|
|
17
|
+
|
|
18
|
+
| 项目 | 值 |
|
|
19
|
+
|------|-----|
|
|
20
|
+
| 模块名称 | {metadata.chinese_name} |
|
|
21
|
+
| 资源标识 | {module.resource.singular} / {module.resource.plural} |
|
|
22
|
+
| 作者 | {metadata.author} |
|
|
23
|
+
| 优先级 | {metadata.priority} |
|
|
24
|
+
| 创建日期 | {metadata.created_at} |
|
|
25
|
+
|
|
26
|
+
## 2. 业务背景
|
|
27
|
+
|
|
28
|
+
**解决的问题**:{narrative.problem}
|
|
29
|
+
|
|
30
|
+
**业务背景**:{narrative.background}
|
|
31
|
+
|
|
32
|
+
**目标用户**:{从 user_story 提取角色}
|
|
33
|
+
|
|
34
|
+
**预期价值**:
|
|
35
|
+
- {narrative.goals[0]}
|
|
36
|
+
- {narrative.goals[1]}
|
|
37
|
+
- ...
|
|
38
|
+
|
|
39
|
+
## 3. 数据模型
|
|
40
|
+
|
|
41
|
+
**实体**:{entities[0].name} ({entities[0].chinese_name})
|
|
42
|
+
|
|
43
|
+
| 字段名 | 中文名 | 类型 | 必填 | 说明 |
|
|
44
|
+
|--------|--------|------|------|------|
|
|
45
|
+
| {field.name} | {field.chinese_name} | {field.type} | {field.required ? "是" : "否"} | {枚举值或备注} |
|
|
46
|
+
| ... | ... | ... | ... | ... |
|
|
47
|
+
|
|
48
|
+
## 4. 功能范围
|
|
49
|
+
|
|
50
|
+
- [x/空] 基础 CRUD(增删改查列表)
|
|
51
|
+
- [x/空] 审批流程(提交、审批、拒绝)
|
|
52
|
+
- [x/空] 批量导入(Excel 导入)
|
|
53
|
+
- [x/空] 数据导出(导出为 Excel)
|
|
54
|
+
|
|
55
|
+
## 5. 验收标准
|
|
56
|
+
|
|
57
|
+
1. {narrative.acceptance_criteria[0]}
|
|
58
|
+
2. {narrative.acceptance_criteria[1]}
|
|
59
|
+
3. ...
|
|
60
|
+
|
|
61
|
+
## 6. 关联信息(如有)
|
|
62
|
+
|
|
63
|
+
- 关联模块:{如果发现与现有模块有关联,列出}
|
|
64
|
+
- 关联字段:{外键关系}
|
|
65
|
+
|
|
66
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
67
|
+
|
|
68
|
+
✅ 确认无误 → 回复"确认",我将生成 YAML 并保存
|
|
69
|
+
❌ 需要修改 → 告诉我哪里需要调整
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 字段说明
|
|
75
|
+
|
|
76
|
+
### 1. 元信息
|
|
77
|
+
- **模块名称**:用户定义的中文名称,如"客户管理"
|
|
78
|
+
- **资源标识**:英文单复数,如 customer / customers
|
|
79
|
+
- **作者**:需求提出者姓名
|
|
80
|
+
- **优先级**:high / medium / low
|
|
81
|
+
- **创建日期**:自动填充当前日期 YYYY-MM-DD
|
|
82
|
+
|
|
83
|
+
### 2. 业务背景
|
|
84
|
+
- **解决的问题**:从 Q1 收集的核心痛点
|
|
85
|
+
- **业务背景**:智能推测或从对话中提取
|
|
86
|
+
- **目标用户**:从 Q2 收集的用户角色
|
|
87
|
+
- **预期价值**:根据功能范围智能推导
|
|
88
|
+
|
|
89
|
+
### 3. 数据模型
|
|
90
|
+
- 必须列出所有从 Q4 收集的字段
|
|
91
|
+
- 每个字段包含:名称、中文名、类型、是否必填、说明
|
|
92
|
+
- 枚举类型需要在说明中列出可选值
|
|
93
|
+
|
|
94
|
+
### 4. 功能范围
|
|
95
|
+
- 从 Q5 收集的多选结果
|
|
96
|
+
- 使用 `[x]` 表示选中,`[ ]` 表示未选
|
|
97
|
+
|
|
98
|
+
### 5. 验收标准
|
|
99
|
+
- 从 Q6 收集的验收条件
|
|
100
|
+
- 每条标准独立编号
|
|
101
|
+
|
|
102
|
+
### 6. 关联信息
|
|
103
|
+
- 从准备阶段发现的关联关系
|
|
104
|
+
- 如果没有关联,可以省略此部分或标注"无"
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 使用示例
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
📋 需求确认单
|
|
112
|
+
|
|
113
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
114
|
+
|
|
115
|
+
## 1. 元信息
|
|
116
|
+
|
|
117
|
+
| 项目 | 值 |
|
|
118
|
+
|------|-----|
|
|
119
|
+
| 模块名称 | 客户管理 |
|
|
120
|
+
| 资源标识 | customer / customers |
|
|
121
|
+
| 作者 | 张三 |
|
|
122
|
+
| 优先级 | medium |
|
|
123
|
+
| 创建日期 | 2025-01-06 |
|
|
124
|
+
|
|
125
|
+
## 2. 业务背景
|
|
126
|
+
|
|
127
|
+
**解决的问题**:客户信息分散在 Excel 中,难以统一管理和查询
|
|
128
|
+
|
|
129
|
+
**业务背景**:销售团队需要统一管理客户资料,目前使用 Excel 导致信息不同步
|
|
130
|
+
|
|
131
|
+
**目标用户**:业务人员
|
|
132
|
+
|
|
133
|
+
**预期价值**:
|
|
134
|
+
- 集中管理客户信息
|
|
135
|
+
- 提高客户查询效率
|
|
136
|
+
- 支持数据导出分析
|
|
137
|
+
|
|
138
|
+
## 3. 数据模型
|
|
139
|
+
|
|
140
|
+
**实体**:Customer (客户)
|
|
141
|
+
|
|
142
|
+
| 字段名 | 中文名 | 类型 | 必填 | 说明 |
|
|
143
|
+
|--------|--------|------|------|------|
|
|
144
|
+
| name | 客户名称 | string | 是 | - |
|
|
145
|
+
| phone | 联系电话 | string | 否 | - |
|
|
146
|
+
| email | 邮箱地址 | string | 否 | - |
|
|
147
|
+
| status | 客户状态 | enum | 是 | 潜在客户/正式客户/流失客户 |
|
|
148
|
+
|
|
149
|
+
## 4. 功能范围
|
|
150
|
+
|
|
151
|
+
- [x] 基础 CRUD(增删改查列表)
|
|
152
|
+
- [ ] 审批流程(提交、审批、拒绝)
|
|
153
|
+
- [ ] 批量导入(Excel 导入)
|
|
154
|
+
- [x] 数据导出(导出为 Excel)
|
|
155
|
+
|
|
156
|
+
## 5. 验收标准
|
|
157
|
+
|
|
158
|
+
1. 能成功创建并查看客户信息
|
|
159
|
+
2. 能导出客户列表为 Excel
|
|
160
|
+
|
|
161
|
+
## 6. 关联信息
|
|
162
|
+
|
|
163
|
+
- 关联模块:订单管理
|
|
164
|
+
- 关联字段:订单表中有 customer_id 外键
|
|
165
|
+
|
|
166
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
167
|
+
|
|
168
|
+
✅ 确认无误 → 回复"确认",我将生成 YAML 并保存
|
|
169
|
+
❌ 需要修改 → 告诉我哪里需要调整
|
|
170
|
+
```
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Keystone Requirement Document Schema v1.1
|
|
2
|
+
|
|
3
|
+
> 需求收集与开发实现之间的交接契约。
|
|
4
|
+
> 此格式是两个 skill 之间唯一的交接文件标准。
|
|
5
|
+
|
|
6
|
+
## 文件命名
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
requirements/REQ-{序号}-{module-name}.yaml
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
示例: `requirements/REQ-002-order-management.yaml`
|
|
13
|
+
|
|
14
|
+
## 完整 Schema
|
|
15
|
+
|
|
16
|
+
```yaml
|
|
17
|
+
version: "1.1" # 必需: Schema 版本
|
|
18
|
+
type: module # 必需: 文档类型 (module | feature | bugfix)
|
|
19
|
+
completeness: "draft" # 必需: draft | review | approved
|
|
20
|
+
|
|
21
|
+
metadata:
|
|
22
|
+
name: "module-name" # 必需: kebab-case 模块名
|
|
23
|
+
chinese_name: "模块中文名" # 必需: 用于 UI 显示
|
|
24
|
+
description: "模块描述" # 必需: 一句话描述
|
|
25
|
+
author: "作者" # 必需: 需求提出者
|
|
26
|
+
created_at: "YYYY-MM-DD" # 必需: 创建日期
|
|
27
|
+
priority: "medium" # 必需: low | medium | high | critical
|
|
28
|
+
|
|
29
|
+
narrative:
|
|
30
|
+
summary: "业务摘要" # 必需: 1-2 句话概述
|
|
31
|
+
background: "背景说明" # 必需: 现状和痛点
|
|
32
|
+
problem: "问题陈述" # 必需: 需要解决的核心问题
|
|
33
|
+
goals: # 必需: 期望达成的目标
|
|
34
|
+
- "目标 1"
|
|
35
|
+
- "目标 2"
|
|
36
|
+
non_goals: # 可选: 明确不做的事项
|
|
37
|
+
- "不做的事项 1"
|
|
38
|
+
user_story: "As a..., I want..., so that..." # 必需: 用户故事
|
|
39
|
+
workflow: "操作流程描述" # 必需: 用户操作流程
|
|
40
|
+
acceptance_criteria: # 必需: 验收标准
|
|
41
|
+
- "验收条件 1"
|
|
42
|
+
- "验收条件 2"
|
|
43
|
+
open_questions: # 可选: 待确认问题
|
|
44
|
+
- "待确认问题 1"
|
|
45
|
+
|
|
46
|
+
module:
|
|
47
|
+
name: "module" # 必需: Go package 名 (小写, 无连字符)
|
|
48
|
+
resource:
|
|
49
|
+
singular: "entity" # 必需: 单数资源名 (小写)
|
|
50
|
+
plural: "entities" # 必需: 复数资源名 (小写)
|
|
51
|
+
|
|
52
|
+
entities: # 必需: 实体定义列表
|
|
53
|
+
- name: "EntityName" # 必需: PascalCase 实体名
|
|
54
|
+
chinese_name: "实体中文名" # 必需: 用于 UI 显示
|
|
55
|
+
description: "实体描述" # 可选: 实体说明
|
|
56
|
+
fields: # 必需: 字段列表
|
|
57
|
+
- name: "fieldName" # 必需: camelCase 或 snake_case
|
|
58
|
+
type: "string" # 必需: 见下方类型说明
|
|
59
|
+
chinese_name: "字段中文名" # 必需: 用于表单/表格标签
|
|
60
|
+
required: true # 必需: 是否必填
|
|
61
|
+
unique: false # 可选: 是否唯一
|
|
62
|
+
default: null # 可选: 默认值
|
|
63
|
+
values: [] # 条件: type=enum 时必需
|
|
64
|
+
validation: # 可选: 验证规则
|
|
65
|
+
min_length: null
|
|
66
|
+
max_length: null
|
|
67
|
+
min: null
|
|
68
|
+
max: null
|
|
69
|
+
pattern: ""
|
|
70
|
+
|
|
71
|
+
features:
|
|
72
|
+
with_crud: true # 必需: 基础 CRUD 功能
|
|
73
|
+
with_approval: false # 必需: 审批流程
|
|
74
|
+
with_import: false # 必需: 批量导入
|
|
75
|
+
with_export: false # 必需: 批量导出
|
|
76
|
+
|
|
77
|
+
assumptions: # 可选: 开发假设
|
|
78
|
+
- "假设说明 1"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 字段类型
|
|
82
|
+
|
|
83
|
+
| 类型 | Go 类型 | TS 类型 | GORM 标签 | 说明 |
|
|
84
|
+
|------|---------|---------|-----------|------|
|
|
85
|
+
| `string` | `string` | `string` | `gorm:"size:200"` | 短文本 |
|
|
86
|
+
| `text` | `string` | `string` | `gorm:"type:text"` | 长文本 |
|
|
87
|
+
| `int` | `int` | `number` | - | 整数 |
|
|
88
|
+
| `uint` | `uint` | `number` | - | 无符号整数 |
|
|
89
|
+
| `float` | `float64` | `number` | - | 浮点数 |
|
|
90
|
+
| `bool` | `bool` | `boolean` | - | 布尔值 |
|
|
91
|
+
| `enum` | `string` (自定义类型) | `string` 联合类型 | `gorm:"size:20"` | 枚举 |
|
|
92
|
+
| `datetime` | `time.Time` | `string` | - | 日期时间 |
|
|
93
|
+
| `date` | `time.Time` | `string` | - | 仅日期 |
|
|
94
|
+
| `json` | `datatypes.JSON` | `object` | `gorm:"type:json"` | JSON 对象 |
|
|
95
|
+
|
|
96
|
+
## 特殊字段约定
|
|
97
|
+
|
|
98
|
+
以下字段由框架自动处理,无需在 entities 中定义:
|
|
99
|
+
|
|
100
|
+
| 字段 | 说明 |
|
|
101
|
+
|------|------|
|
|
102
|
+
| `id` | 主键,自动生成 |
|
|
103
|
+
| `tenant_id` | 租户 ID,自动注入 |
|
|
104
|
+
| `created_at` | 创建时间,自动设置 |
|
|
105
|
+
| `updated_at` | 更新时间,自动更新 |
|
|
106
|
+
| `created_by` | 创建人 ID(可选) |
|
|
107
|
+
| `updated_by` | 更新人 ID(可选) |
|
|
108
|
+
|
|
109
|
+
## 审批流特殊字段
|
|
110
|
+
|
|
111
|
+
当 `features.with_approval: true` 时,自动添加:
|
|
112
|
+
|
|
113
|
+
| 字段 | 说明 |
|
|
114
|
+
|------|------|
|
|
115
|
+
| `status` | 扩展为 draft/pending/approved/rejected |
|
|
116
|
+
| `approval_instance_id` | 审批实例 ID |
|
|
117
|
+
| `reject_reason` | 拒绝原因 |
|
|
118
|
+
|
|
119
|
+
## Completeness 状态说明
|
|
120
|
+
|
|
121
|
+
| 状态 | 说明 | 允许操作 |
|
|
122
|
+
|------|------|----------|
|
|
123
|
+
| `draft` | 草稿,需求收集中 | 可继续编辑完善 |
|
|
124
|
+
| `review` | 评审中,等待确认 | 仅允许小修改 |
|
|
125
|
+
| `approved` | 已批准,可进入开发 | keystone-implement 可执行 |
|
|
126
|
+
|
|
127
|
+
## 验证规则
|
|
128
|
+
|
|
129
|
+
需求文档必须满足以下条件才能进入开发:
|
|
130
|
+
|
|
131
|
+
1. `completeness` 必须为 `approved`
|
|
132
|
+
2. 所有 `必需` 字段必须有值
|
|
133
|
+
3. 每个 entity 至少有一个业务字段(不含 id/tenant_id 等)
|
|
134
|
+
4. `values` 数组在 `type: enum` 时必须非空
|
|
135
|
+
5. `open_questions` 应为空或已全部解决
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
- master
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: pnpm/action-setup@v4
|
|
16
|
+
with:
|
|
17
|
+
version: 9
|
|
18
|
+
- uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: 20
|
|
21
|
+
cache: pnpm
|
|
22
|
+
- uses: actions/setup-go@v5
|
|
23
|
+
with:
|
|
24
|
+
go-version-file: apps/server/go.mod
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: pnpm install
|
|
27
|
+
- name: Build web app
|
|
28
|
+
run: pnpm -C apps/web build
|
|
29
|
+
- name: Run Go tests
|
|
30
|
+
run: go -C apps/server test ./...
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
tags:
|
|
7
|
+
- "v*"
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: pnpm/action-setup@v4
|
|
15
|
+
with:
|
|
16
|
+
version: 9
|
|
17
|
+
- uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
node-version: 20
|
|
20
|
+
cache: pnpm
|
|
21
|
+
- uses: actions/setup-go@v5
|
|
22
|
+
with:
|
|
23
|
+
go-version-file: apps/server/go.mod
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: pnpm install
|
|
26
|
+
- name: Build release artifacts
|
|
27
|
+
run: pnpm build
|
|
28
|
+
- name: Upload dist
|
|
29
|
+
uses: actions/upload-artifact@v4
|
|
30
|
+
with:
|
|
31
|
+
name: keystone-dist
|
|
32
|
+
path: dist
|
package/template/README.md
CHANGED
|
@@ -1,77 +1,85 @@
|
|
|
1
|
-
# __RAW_NAME__
|
|
2
|
-
|
|
3
|
-
Keystone 平台脚手架项目(Web + Server)。
|
|
4
|
-
|
|
5
|
-
## 快速开始
|
|
6
|
-
1) 安装依赖
|
|
7
|
-
```bash
|
|
8
|
-
pnpm install
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
2) 启动开发环境(前后端一起)
|
|
12
|
-
```bash
|
|
1
|
+
# __RAW_NAME__
|
|
2
|
+
|
|
3
|
+
Keystone 平台脚手架项目(Web + Server)。
|
|
4
|
+
|
|
5
|
+
## 快速开始
|
|
6
|
+
1) 安装依赖
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
2) 启动开发环境(前后端一起)
|
|
12
|
+
```bash
|
|
13
|
+
pnpm dev
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
3) 单独启动
|
|
17
|
+
```bash
|
|
18
|
+
pnpm server:dev
|
|
13
19
|
pnpm dev
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
##
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
##
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 初始化后建议
|
|
23
|
+
- 复制 `apps/web/.env.example` 为 `apps/web/.env`(Vite 会读取)。
|
|
24
|
+
- 检查 `apps/server/config.yaml`(Go 运行配置)。
|
|
25
|
+
- 需要外部依赖时参考 `docker-compose.yml`。
|
|
26
|
+
- 建议阅读:`docs/GETTING_STARTED.md`、`docs/CONVENTIONS.md`、`docs/CODE_STYLE.md`、`apps/web/README.md`、`apps/server/README.md`。
|
|
27
|
+
|
|
28
|
+
## 常用命令
|
|
29
|
+
- `pnpm dev`:跨平台开发启动(Air + Vite)。
|
|
30
|
+
- `pnpm build`:构建并嵌入前端,生成可执行后端产物。
|
|
31
|
+
- `pnpm test`:Web 类型检查 + Lint + Vitest + Go 测试。
|
|
32
|
+
- `pnpm clean`:清理构建产物。
|
|
33
|
+
|
|
34
|
+
## 模块生成器
|
|
35
|
+
```bash
|
|
36
|
+
pnpm create:module <module-name> [options]
|
|
37
|
+
```
|
|
38
|
+
不传 options 会进入交互式向导。
|
|
39
|
+
|
|
40
|
+
选项:
|
|
41
|
+
- `--frontend-only`:只生成前端模块。
|
|
42
|
+
- `--backend-only`:只生成后端模块。
|
|
43
|
+
- `--with-crud`:包含 CRUD 示例代码。
|
|
44
|
+
- `--with-approval`:包含审批流代码(自动启用 `--with-crud`)。
|
|
45
|
+
- `--skip-register`:跳过自动注册步骤。
|
|
46
|
+
|
|
47
|
+
使用 `--with-approval` 时生成:
|
|
48
|
+
- 后端:`domain/service/approval.go`、`domain/service/callback.go`、`api/handler/approval.go`
|
|
49
|
+
- 前端:`components/ApprovalActions.tsx`
|
|
50
|
+
- 模型:添加 `draft/pending/approved/rejected` 状态和审批字段
|
|
51
|
+
- 路由:`POST /:id/submit`、`POST /:id/cancel`
|
|
52
|
+
|
|
46
53
|
## AI Skills
|
|
47
|
-
- Codex
|
|
48
|
-
- Claude
|
|
49
|
-
|
|
50
|
-
## 目录结构
|
|
51
|
-
- `apps/web/`:React + Vite 壳与业务模块(`src/modules/*`)。
|
|
52
|
-
- `apps/server/`:Go API + 模块注册/迁移/种子数据(含 `config.yaml`)。
|
|
53
|
-
- `apps/server/internal/frontend/`:嵌入式前端目录(`dist/`)。
|
|
54
|
-
- `docs/CONVENTIONS.md`:项目规范与最佳实践。
|
|
55
|
-
- `apps/web/README.md`:前端壳与模块开发说明。
|
|
56
|
-
- `apps/server/README.md`:后端模块与运行说明。
|
|
57
|
-
- `scripts/`:跨平台 dev/build/test/clean。
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
.
|
|
61
|
-
├─ apps/
|
|
62
|
-
│ ├─ web/ # 前端壳与模块
|
|
63
|
-
│ └─ server/ # Go 服务与模块
|
|
64
|
-
├─ docs/ # 开发规范与说明
|
|
65
|
-
└─ scripts/ # 跨平台脚本
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Example
|
|
54
|
+
- Codex: `.codex/skills/keystone-requirements`, `.codex/skills/keystone-app-dev`
|
|
55
|
+
- Claude: `.claude/skills/keystone-requirements`, `.claude/skills/keystone-app-dev`
|
|
56
|
+
|
|
57
|
+
## 目录结构
|
|
58
|
+
- `apps/web/`:React + Vite 壳与业务模块(`src/modules/*`)。
|
|
59
|
+
- `apps/server/`:Go API + 模块注册/迁移/种子数据(含 `config.yaml`)。
|
|
60
|
+
- `apps/server/internal/frontend/`:嵌入式前端目录(`dist/`)。
|
|
61
|
+
- `docs/CONVENTIONS.md`:项目规范与最佳实践。
|
|
62
|
+
- `apps/web/README.md`:前端壳与模块开发说明。
|
|
63
|
+
- `apps/server/README.md`:后端模块与运行说明。
|
|
64
|
+
- `scripts/`:跨平台 dev/build/test/clean。
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
.
|
|
68
|
+
├─ apps/
|
|
69
|
+
│ ├─ web/ # 前端壳与模块
|
|
70
|
+
│ └─ server/ # Go 服务与模块
|
|
71
|
+
├─ docs/ # 开发规范与说明
|
|
72
|
+
└─ scripts/ # 跨平台脚本
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Example 模块(可选)
|
|
69
76
|
Example 模块展示完整的 CRUD 模式、权限命名与 DDD 分层结构。
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
-
|
|
77
|
+
使用 `create-keystone-app --with-example` 生成。
|
|
78
|
+
- 菜单:Example Items
|
|
79
|
+
- API:`/api/v1/example/items`
|
|
80
|
+
- 权限:`example:item:view`、`example:item:manage`
|
|
81
|
+
|
|
82
|
+
## 默认登录
|
|
83
|
+
- Tenant code: `default`
|
|
84
|
+
- Identifier: `admin`
|
|
77
85
|
- Password: `Admin123!`
|
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
## 定位
|
|
4
4
|
- Go 后端应用入口在 `cmd/server/main.go`。
|
|
5
5
|
- 业务模块统一放在 `internal/modules/*`。
|
|
6
|
+
- 核心组装由 `server.NewBuilder` 完成,应用只负责注册模块与嵌入式前端。
|
|
6
7
|
|
|
7
8
|
## 配置
|
|
8
9
|
- 主配置:`apps/server/config.yaml`。
|
|
9
10
|
- 模板配置:`apps/server/config.example.yaml`。
|
|
10
11
|
- 环境变量:需通过 Shell/工具注入(服务端不读取 `.env`)。
|
|
11
12
|
|
|
13
|
+
## API 文档
|
|
14
|
+
- Swagger UI:`/api/docs`
|
|
15
|
+
- 生成 OpenAPI:`pnpm contracts:docs`
|
|
16
|
+
|
|
17
|
+
## 可观测性
|
|
18
|
+
- 指标端点:`/metrics`(默认关闭,需开启 `telemetry.enabled`)
|
|
19
|
+
|
|
12
20
|
## 数据与存储
|
|
13
21
|
- SQLite:`apps/server/data/keystone-local.db`。
|
|
14
22
|
- 本地存储:`apps/server/storage/`(`storage.driver=local`)。
|