@ddd-tool/domain-designer-cli 0.0.0-alpha.9 → 0.1.0-beta.1
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 +1 -1
- package/README.md +125 -13
- package/bin/domain-designer-cli.cjs +280 -99
- package/package.json +20 -19
- package/scripts/build-ts.mjs +52 -0
- package/scripts/sync-ver.mjs +0 -0
- package/src/views/design-en.ts +18 -31
- package/src/views/design-zh.ts +14 -24
- package/src/views/index.ts +12 -4
- package/templates/example-agg.ts +31 -0
- package/templates/example.ts +91 -0
- package/templates/node_modules/@ddd-tool/domain-designer-core/actor.d.ts +1 -1
- package/templates/node_modules/@ddd-tool/domain-designer-core/common.d.ts +34 -155
- package/templates/node_modules/@ddd-tool/domain-designer-core/define.d.ts +259 -124
- package/templates/node_modules/@ddd-tool/domain-designer-core/index.d.ts +3 -203
- package/templates/node_modules/@ddd-tool/domain-designer-core/info.d.ts +2 -0
- package/templates/node_modules/@ddd-tool/domain-designer-core/note.d.ts +2 -0
- package/templates/node_modules/@ddd-tool/domain-designer-core/policy.d.ts +1 -1
- package/templates/node_modules/@ddd-tool/domain-designer-core/service.d.ts +1 -1
- package/templates/node_modules/@ddd-tool/domain-designer-core/system.d.ts +1 -1
- package/templates/node_modules/version.txt +1 -1
- package/tsconfig.json +6 -19
- package/vite.config.ts +11 -5
- package/bin/domain-designer-cli.cjs.map +0 -7
- package/templates/node_modules/@ddd-tool/domain-designer-core/desc.d.ts +0 -2
- package/templates/node_modules/@ddd-tool/domain-designer-core/info/field.d.ts +0 -2
- package/templates/node_modules/@ddd-tool/domain-designer-core/info/index.d.ts +0 -3
- package/templates//347/244/272/344/276/213.ts +0 -31
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright 2024 <AlphaFoxz@github.com>
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -1,45 +1,157 @@
|
|
|
1
|
-
#
|
|
1
|
+
# domain-designer-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
通过编写 ts 的方式进行领域设计,目标是作为 ddd 建模生产力工具
|
|
4
|
+
|
|
5
|
+
设计原则:
|
|
6
|
+
|
|
7
|
+
- 尽可能让代码与视图拥有相近的表达能力
|
|
8
|
+
|
|
9
|
+
- 借助 ts 代码检查保证一定的完备性
|
|
10
|
+
|
|
11
|
+
- 探索在设计的时候,如何更多地表达 `WHY`,而不是像传统设计图一样只表达 `HOW`。(工作流 + 用户故事)
|
|
12
|
+
|
|
13
|
+
## 1 前置依赖
|
|
4
14
|
|
|
5
15
|
[nodejs](https://nodejs.org/en/download/) >= 18
|
|
6
16
|
|
|
7
|
-
[pnpm](https://pnpm.io/) >= 9
|
|
17
|
+
[bun](https://bun.sh/) OR [pnpm](https://pnpm.io/) >= 9
|
|
18
|
+
|
|
19
|
+
- 确保有全局的 `bun` 或者 `pnpm` 指令 bun
|
|
8
20
|
|
|
9
|
-
-
|
|
21
|
+
- 本程序会优先使用 bun 运行,如果没有则切换为 pnpm
|
|
10
22
|
|
|
11
|
-
## 2
|
|
23
|
+
## 2 安装
|
|
12
24
|
|
|
13
25
|
```bash
|
|
26
|
+
bun i @ddd-tool/domain-designer-cli -g
|
|
27
|
+
# or
|
|
14
28
|
pnpm i @ddd-tool/domain-designer-cli -g
|
|
15
29
|
```
|
|
16
30
|
|
|
17
|
-
## 3
|
|
31
|
+
## 3 更新版本
|
|
32
|
+
|
|
33
|
+
### 3.1 更新软件
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bun i @ddd-tool/domain-designer-cli@latest -g
|
|
37
|
+
# or
|
|
38
|
+
pnpm i @ddd-tool/domain-designer-cli@latest -g
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3.2 更新工作空间
|
|
42
|
+
|
|
43
|
+
在已有的工作空间中执行命令
|
|
18
44
|
|
|
19
45
|
```bash
|
|
46
|
+
bunx domain-designer-cli update
|
|
47
|
+
# or
|
|
48
|
+
domain-designer-cli update
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 4 使用
|
|
52
|
+
|
|
53
|
+
### 4.1 初始化一个工作空间
|
|
54
|
+
|
|
55
|
+
在一个空文件夹中执行命令
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
bunx domain-designer-cli init
|
|
59
|
+
# or
|
|
20
60
|
domain-designer-cli init
|
|
21
61
|
```
|
|
22
62
|
|
|
63
|
+
- 推荐将工作空间中的所有文件放入实际项目,随项目一起进行版本控制。由于 ts 代码的表达能力并不弱,在多人协作的时候,即使其他人没有安装本工具,也可以通过代码安全地了解、调整领域模型。
|
|
64
|
+
|
|
23
65
|
- 初始化后的目录包含如下内容:
|
|
24
66
|
|
|
25
|
-
- node_modules
|
|
67
|
+
- node_modules 目录:为 ide 提供代码补全的少量 `.d.ts` 文件,不包含任何实现
|
|
68
|
+
|
|
69
|
+
- 示例 ts 文件。可以快速了解如何使用 ts 代码进行建模
|
|
26
70
|
|
|
27
|
-
-
|
|
71
|
+
- RunWeb 脚本:用于实时查看建模效果
|
|
28
72
|
|
|
29
|
-
-
|
|
73
|
+
- GenCode 脚本:用于代码生成
|
|
30
74
|
|
|
31
|
-
|
|
75
|
+
### 4.2 编写 ts 文件
|
|
32
76
|
|
|
33
77
|
- 可以自行创建多个任意名称的 ts 文件
|
|
34
78
|
|
|
35
|
-
-
|
|
79
|
+
- ※ 特殊规则:只有位于工作空间根目录、且默认导出了一个 DomainDesigner 实例的 ts 文件才会被识别为一个“数据源”,如示例文件中的 `export default d`。除此以外,所有规则与普通 ts 项目一致
|
|
80
|
+
|
|
81
|
+
- 多个数据源 ts 文件会被 web 服务识别为多个数据源,可在 web 页面的设置中切换数据源
|
|
36
82
|
|
|
37
|
-
|
|
83
|
+
### 4.3 Web 端运行
|
|
38
84
|
|
|
39
85
|
- 运行自动生成的`RunWeb`脚本文件,即可启动 web 服务
|
|
40
86
|
|
|
41
|
-
|
|
87
|
+
### 4.4 代码生成
|
|
88
|
+
|
|
89
|
+
- 运行自动生成的`GenCode`脚本文件,根据实际需求进行命令行交互
|
|
90
|
+
|
|
91
|
+
- 支持编程语言列表(开发中...)
|
|
92
|
+
|
|
93
|
+
- [x] Java
|
|
94
|
+
|
|
95
|
+
- [x] Kotlin
|
|
96
|
+
|
|
97
|
+
- [ ] C#
|
|
98
|
+
|
|
99
|
+
- [ ] GoLang
|
|
100
|
+
|
|
101
|
+
## 5 其他说明
|
|
42
102
|
|
|
43
103
|
- 对于每个 ts 文件内的修改,刷新页面即可看到效果
|
|
44
104
|
|
|
45
105
|
- 如果新增或者删除了 ts 文件,需要重新运行`RunWeb`脚本
|
|
106
|
+
|
|
107
|
+
## 6 设计理念
|
|
108
|
+
|
|
109
|
+
### 6.1 低学习成本
|
|
110
|
+
|
|
111
|
+
- 用户学习成本必须控制在几分钟以内。必须把复杂性封装到库内,然后把使用难度保持在 js 级别(无需考虑类型)
|
|
112
|
+
|
|
113
|
+
### 6.2 单向工作流
|
|
114
|
+
|
|
115
|
+
- 对于特性的添加,遵循“单向工作流”原则:先设计 -> 再开始落地 -> ...
|
|
116
|
+
拒绝“落地影响设计”
|
|
117
|
+
|
|
118
|
+
- 如果某些特性,哪怕可以给每个项目的落地节省 10 分钟,就可以考虑做
|
|
119
|
+
|
|
120
|
+
- 如果某些特性,侵占了下一步工作的“职责”,那就不做
|
|
121
|
+
|
|
122
|
+
- 例如:代码生成功能可以做,且这个功能应开始于减负,结束于减负:它的目标就是让我们在初次落地时少写一点样板代码,假如这个样板代码不太准确,我们可以先手动调整,然后在不增加领域建模负担的前提下慢慢优化功能。
|
|
123
|
+
这个代码生成功能绝不会是“低代码”,否则这将要求领域设计工作的复杂度与完备性将与目标编程语言的实现相近,最大的问题是,假如是低代码理念,当落地代码需要有某些调整(非领域设计问题),我们又要回过头担忧怎么改设计了,这实质上是一种返工。最终浪费的时间将远超样板代码方面节省的时间。一个好的工具应该让使用者顺利在自己应有的工作流程中一步步走下去,而不是制造麻烦。
|
|
124
|
+
|
|
125
|
+
## TODO list
|
|
126
|
+
|
|
127
|
+
- [ ] 多端适配
|
|
128
|
+
|
|
129
|
+
- [x] Windows
|
|
130
|
+
|
|
131
|
+
- [ ] Linux
|
|
132
|
+
|
|
133
|
+
- [ ] Mac
|
|
134
|
+
|
|
135
|
+
- [x] 代码生成功能
|
|
136
|
+
|
|
137
|
+
- [x] csharp
|
|
138
|
+
|
|
139
|
+
- [x] go
|
|
140
|
+
|
|
141
|
+
- [x] java
|
|
142
|
+
|
|
143
|
+
- [x] kotlin
|
|
144
|
+
|
|
145
|
+
- [x] 图形化展示
|
|
146
|
+
|
|
147
|
+
- [x] 事件风暴 uml
|
|
148
|
+
|
|
149
|
+
- [x] 用户故事
|
|
150
|
+
|
|
151
|
+
- [x] 工作流动画
|
|
152
|
+
|
|
153
|
+
- [x] 完备性分析
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
|