@robsun/create-keystone-app 0.2.15 → 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 -44
- package/dist/create-keystone-app.js +347 -10
- package/dist/create-module.js +1217 -1187
- package/package.json +1 -1
- 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 +82 -81
- 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 +17 -17
- 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 -90
- package/template/.claude/skills/keystone-dev/references/ADVANCED_PATTERNS.md +0 -716
- 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/CHECKLIST.md +0 -285
- package/template/.claude/skills/keystone-dev/references/GOTCHAS.md +0 -390
- package/template/.claude/skills/keystone-dev/references/PATTERNS.md +0 -605
- package/template/.claude/skills/keystone-dev/references/TEMPLATES.md +0 -2710
- package/template/.claude/skills/keystone-dev/references/TESTING.md +0 -44
- package/template/.codex/skills/keystone-dev/SKILL.md +0 -90
- package/template/.codex/skills/keystone-dev/references/ADVANCED_PATTERNS.md +0 -716
- 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/CHECKLIST.md +0 -285
- package/template/.codex/skills/keystone-dev/references/GOTCHAS.md +0 -390
- package/template/.codex/skills/keystone-dev/references/PATTERNS.md +0 -605
- package/template/.codex/skills/keystone-dev/references/TEMPLATES.md +0 -2710
- 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
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# Keystone 开发测试清单
|
|
2
|
-
|
|
3
|
-
## 快速入口
|
|
4
|
-
- 仓库根目录:`pnpm test`(模板测试 + `go test ./...`)
|
|
5
|
-
- 仅 Go:`go test ./...`
|
|
6
|
-
- 模板项目:`pnpm -C packages/create-keystone-app/template test`
|
|
7
|
-
|
|
8
|
-
## 按改动范围选择
|
|
9
|
-
后端(api/domain/infra/bootstrap/server)
|
|
10
|
-
- `go test ./...`
|
|
11
|
-
- 若改动较大可补 `go vet ./...`
|
|
12
|
-
|
|
13
|
-
模板前端(packages/create-keystone-app/template/apps/web)
|
|
14
|
-
- `pnpm -C packages/create-keystone-app/template/apps/web typecheck`
|
|
15
|
-
- `pnpm -C packages/create-keystone-app/template/apps/web lint`
|
|
16
|
-
- `pnpm -C packages/create-keystone-app/template/apps/web test`
|
|
17
|
-
|
|
18
|
-
前端核心包(packages/keystone-web-core)
|
|
19
|
-
- `pnpm -C packages/keystone-web-core build`
|
|
20
|
-
|
|
21
|
-
脚手架/模板变更
|
|
22
|
-
- `pnpm scaffold:verify`
|
|
23
|
-
|
|
24
|
-
合同变更
|
|
25
|
-
- `pnpm contracts:check`
|
|
26
|
-
- 如更新了合同内容,执行 `pnpm contracts:sync`
|
|
27
|
-
|
|
28
|
-
## 写测试(必做)
|
|
29
|
-
后端
|
|
30
|
-
- 领域/服务逻辑新增或改动:在 `tests/unit/platform/service` 或对应 domain 下补单测。
|
|
31
|
-
- Repository 变更:在 `tests/unit/platform/repository` 补单测。
|
|
32
|
-
- 新增/调整 API:在 `tests/integration/platform/api` 补集成测试。
|
|
33
|
-
- 参考用例:`tests/unit/platform/approval/service_test.go`、`tests/integration/platform/api/approval_schema_test.go`。
|
|
34
|
-
|
|
35
|
-
前端(模板 web)
|
|
36
|
-
- 新增页面/交互:在 `packages/create-keystone-app/template/apps/web/tests` 新增 `*.test.tsx`。
|
|
37
|
-
- 使用 vitest + Testing Library(已在 `vite.config.ts` 配好 test 配置)。
|
|
38
|
-
|
|
39
|
-
前端核心包(keystone-web-core)
|
|
40
|
-
- 新增核心组件/逻辑:优先在模板 web 侧写集成测试覆盖。
|
|
41
|
-
- 如必须在包内写单测,需要补齐包内测试配置后再添加用例。
|
|
42
|
-
|
|
43
|
-
## 最小通过标准
|
|
44
|
-
- 单点改动跑对应子项;跨域改动直接跑 `pnpm test`。
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: keystone-dev
|
|
3
|
-
description: Build and extend Keystone modules and features (frontend + backend) with consistent structure, permissions, i18n, help docs, and OpenAPI contracts. Use when adding new modules, routes, APIs, migrations, or updating the scaffold template in this repo.
|
|
4
|
-
---
|
|
5
|
-
# Keystone Dev
|
|
6
|
-
|
|
7
|
-
## Core workflow
|
|
8
|
-
1) Identify the target app root: this repo's scaffold template or a generated app.
|
|
9
|
-
2) Create or update the module using the generator or the Example module as the baseline.
|
|
10
|
-
3) Add or update tests for new behavior before finishing implementation.
|
|
11
|
-
4) Wire frontend routes, menus, permissions, help docs, and i18n.
|
|
12
|
-
5) Wire backend module registration, permissions, i18n, routes, migrations, and seeds.
|
|
13
|
-
6) Update contracts and types when APIs change.
|
|
14
|
-
7) Run the relevant checks before finishing.
|
|
15
|
-
|
|
16
|
-
## Module creation
|
|
17
|
-
- Use the generator when possible:
|
|
18
|
-
```bash
|
|
19
|
-
pnpm create:module <module-name> [options]
|
|
20
|
-
|
|
21
|
-
Options:
|
|
22
|
-
--frontend-only Only generate the frontend module
|
|
23
|
-
--backend-only Only generate the backend module
|
|
24
|
-
--with-crud Include CRUD example code
|
|
25
|
-
--with-approval Include approval workflow code (implies --with-crud)
|
|
26
|
-
--skip-register Skip auto registration steps
|
|
27
|
-
```
|
|
28
|
-
- Keep module names in kebab-case and consistent across frontend, backend, and permissions.
|
|
29
|
-
- Prefer copying the Example module if you need a manual template.
|
|
30
|
-
|
|
31
|
-
## Approval workflow (--with-approval)
|
|
32
|
-
When using `--with-approval`, the generator creates:
|
|
33
|
-
- **Backend**: `domain/service/approval.go` (Submit/Cancel), `domain/service/callback.go` (OnApproved/OnRejected), `api/handler/approval.go`
|
|
34
|
-
- **Frontend**: `components/ApprovalActions.tsx` with status tags and action buttons
|
|
35
|
-
- **Model updates**: Adds `draft/pending/approved/rejected` statuses and `ApprovalInstanceID` field
|
|
36
|
-
- **I18n**: Approval-related translations in both languages
|
|
37
|
-
- **Routes**: `POST /:id/submit` and `POST /:id/cancel` endpoints
|
|
38
|
-
|
|
39
|
-
After generation, register the approval callback in `module.go`:
|
|
40
|
-
```go
|
|
41
|
-
func (m *Module) RegisterApprovalCallback(reg *approval.CallbackRegistry) error {
|
|
42
|
-
return reg.Register(service.ApprovalBusinessType, service.New{Pascal}ApprovalCallback(m.repo))
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Frontend checklist (apps/web)
|
|
47
|
-
- Add module at `apps/web/src/modules/<module>`.
|
|
48
|
-
- In `index.ts`, call `loadModuleLocales` and `registerModule`.
|
|
49
|
-
- In `routes.tsx`, set `handle.menu`, `handle.permission`, `handle.helpKey`, and use `labelKey`/`breadcrumbKey` for i18n.
|
|
50
|
-
- Add help docs under `apps/web/src/modules/<module>/help/**` and keep `helpKey` aligned.
|
|
51
|
-
- Add locale files in `apps/web/src/modules/<module>/locales/zh-CN/*.json` and `en-US/*.json`.
|
|
52
|
-
|
|
53
|
-
## Backend checklist (apps/server)
|
|
54
|
-
- Add module at `apps/server/internal/modules/<module>`.
|
|
55
|
-
- Implement the Module interface in `module.go` and keep DDD layering (`api/`, `domain/`, `infra/`, `bootstrap/`).
|
|
56
|
-
- Register permissions with `CreateMenuI18n`/`CreateActionI18n` using `{module}:{resource}:{action}`.
|
|
57
|
-
- Register i18n in `RegisterI18n()` and provide `i18n/keys.go` + `i18n/locales/*.json`.
|
|
58
|
-
- Register the module in `apps/server/internal/modules/manifest.go`.
|
|
59
|
-
- Enable the module in `apps/server/config.yaml` (scaffold apps).
|
|
60
|
-
|
|
61
|
-
## Testing development
|
|
62
|
-
- Backend: add unit tests in package folders (`*_test.go`) or in `tests/unit`/`tests/integration`/`tests/perf`.
|
|
63
|
-
- Frontend: add component or page tests alongside modules (e.g. `*.test.tsx`).
|
|
64
|
-
- Cover critical paths first (permissions, validation, and data mutations).
|
|
65
|
-
|
|
66
|
-
## Contracts and API types
|
|
67
|
-
- Add or update OpenAPI specs under `contracts/NNN-<name>/`.
|
|
68
|
-
- Update `CONTRACT_MAPPING` in `scripts/generate-api-types.mjs` for new contract folders.
|
|
69
|
-
- Run `pnpm contracts:sync` and `pnpm -C packages/keystone-contracts generate` after contract changes.
|
|
70
|
-
|
|
71
|
-
## Quality gates
|
|
72
|
-
- For scaffold changes: `pnpm -C packages/create-keystone-app/template test`.
|
|
73
|
-
- For contracts: `pnpm contracts:check` and `pnpm -C packages/keystone-contracts typecheck`.
|
|
74
|
-
- For backend changes: `go test ./...`.
|
|
75
|
-
|
|
76
|
-
## Key references
|
|
77
|
-
- `packages/create-keystone-app/template/docs/CONVENTIONS.md`
|
|
78
|
-
- `packages/create-keystone-app/template/docs/CODE_STYLE.md`
|
|
79
|
-
- `packages/create-keystone-app/template/docs/I18N.md`
|
|
80
|
-
- `packages/create-keystone-app/template/apps/web/src/modules/example`
|
|
81
|
-
- `packages/create-keystone-app/template/apps/server/internal/modules/example`
|
|
82
|
-
|
|
83
|
-
## Advanced templates (in `references/`)
|
|
84
|
-
- `TEMPLATES.md` - 基础 CRUD + 高级业务模板(多实体、审批流、导入导出、前端高级组件)
|
|
85
|
-
- `ADVANCED_PATTERNS.md` - 高级开发模式(跨模块依赖、状态机、缓存、并发控制、任务编排)
|
|
86
|
-
- `PATTERNS.md` - 后端开发模式(分页、事务、批量、软删除、预加载、审批集成)
|
|
87
|
-
- `CHECKLIST.md` - 模块开发完整自检清单
|
|
88
|
-
- `GOTCHAS.md` - 常见陷阱与解决方案
|
|
89
|
-
- `CAPABILITIES.md` - 平台完整能力清单
|
|
90
|
-
- `TESTING.md` - 测试开发指南
|