-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
199 lines (142 loc) · 5.07 KB
/
Makefile
File metadata and controls
199 lines (142 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# SPDX-FileCopyrightText: 2024-2026 caixw
#
# SPDX-License-Identifier: MIT
ROOT = .
APPS = $(ROOT)/apps
APPS_SERVER = $(APPS)/server
SERVER_BIN = server
ifeq ($(OS),Windows_NT)
SERVER_BIN = server.exe
else
SERVER_BIN = server
endif
########################### mk-coverage ###################################
.PHONY: mk-coverage gen
COVERAGE = $(ROOT)/coverage
ifeq ($(OS),Windows_NT)
MKCOVERAGE = mkdir "$(COVERAGE)" 2>NUL || exit 0
else
MKCOVERAGE = mkdir -p $(COVERAGE)
endif
mk-coverage:
$(MKCOVERAGE)
# 生成中间代码
gen:
go generate $(ROOT)/...
########################### build ###################################
.PHONY: build build-go build-ts build-app
.PHONY: build-ts-plugin-about build-ts-plugin-api build-ts-plugin
.PHONY: build-ts-docs build-ts-admin-demo build-ts-core build-ts-components build-ts-illustrations build-ts-admin
build: build-go build-ts
build-app: build-go build-ts-admin build-ts-docs
build-ts-plugin: build-ts-plugin-about build-ts-plugin-api
build-go: gen
go build -o=$(APPS_SERVER)/$(SERVER_BIN) -v $(APPS_SERVER)
build-ts-docs: build-ts-admin-demo build-ts-plugin-api
pnpm --filter=./apps/docs run build
build-ts-plugin-about: build-ts-admin
pnpm --filter=./build/vite-plugin-about run build
build-ts-plugin-api:
pnpm --filter=./build/vite-plugin-api run build
build-ts-core:
pnpm --filter=./packages/core run build
build-ts-components: build-ts-core
pnpm --filter=./packages/components run build
build-ts-illustrations: build-ts-components
pnpm --filter=./packages/illustrations run build
build-ts-admin: build-ts-components build-ts-illustrations
pnpm --filter=./packages/admin run build
build-ts-admin-demo: build-ts-admin build-ts-plugin-about
pnpm --filter=./apps/admin run build
# 编译前端项目内容
build-ts: build-ts-docs
########################### install ###################################
.PHONY: install install-ts install-go init
install-ts:
pnpm install
install-go:
go mod download
# 安装依赖
install: install-go install-ts
# 安装基本数据,依赖 build 生成的测试项目
init: build-app
cd $(APPS_SERVER) && ./$(SERVER_BIN) -a=install
########################### watch ###################################
.PHONY: watch-server watch-admin watch-docs watch
watch-server:
web watch -app=-a=serve $(APPS_SERVER)
watch-admin:
pnpm --filter=./apps/admin run dev
watch-docs:
pnpm --filter=./apps/docs run dev
# 运行测试内容
#
# 需要采用 -j 执行并行命令,比如:
# make watch -j2
watch: watch-server watch-admin
########################### test ###################################
.PHONY: test test-go test-ts lint-ts
.PHONY: test-ts-core test-ts-components test-ts-admin
.PHONY: test-ts-docs
.PHONY: test-ts-plugin-about test-ts-plugin-api
lint-ts:
pnpm run lint
# 执行 Go 测试
test-go: mk-coverage
go vet -v ./...
go test -v -coverprofile='coverage/go.txt' -p=1 -parallel=1 -covermode=atomic ./...
test-ts-plugin-about: mk-coverage
pnpm run test --project=@cmfx/vite-plugin-about
test-ts-plugin-api: mk-coverage
pnpm run test --project=@cmfx/vite-plugin-api
test-ts-core: mk-coverage
pnpm run test --project=@cmfx/core
test-ts-docs: mk-coverage
pnpm run test --project=@cmfx/docs
test-ts-components: mk-coverage build-ts-core
pnpm run test --project=@cmfx/components
test-ts-admin: mk-coverage build-ts-components
pnpm run test --project=@cmfx/admin
# 执行 TypeScript 测试
test-ts: build-ts mk-coverage
pnpm run test-nowatch
# 执行测试内容
test: test-go test-ts
############################# changelog ###############################
# 生成 CHANGELOG.md 文件,接受 from 和 to 参数,用于指定生成的范围,一般为 git tag 值。
# to 同时也会作为版本号写入 CHANGELOG.md 文件。
#
# 如果不指定参数
# to 表示最新的提交
# from 表示第一个提交
#
# 用法:
# make changelog
# make changelog from=v1.0.0 to=v1.1.0
.PHONY: changelog
to = 'HEAD'
from = '$(shell git rev-list --max-parents=0 HEAD)'
changelog:
bash ./scripts/changelog.sh $(from) $(to)
########################### publish ###################################
.PHONY: publish-npm
publish-npm: build-ts
pnpm publish --filter=./packages/core --filter=./packages/components \
--filter=./packages/admin --filter=./packages/illustrations \
--filter=./build/vite-plugin-about --filter=./build/vite-plugin-api \
--access=public --no-git-checks
########################### version ###################################
# 用于修正当前项目的版本号
#
# 包含一个参数 target,用以指定需要升级的版本号,可以是 patch、minor 和 major 三个值,默认值为 patch。
# 比如:`make version` 或是 `make version target=minor`
#
# 该操作会同时更新所有 package.json 中的版本号以及 cmfx/VERSION 的内容,后者为服务端项目的版本号。
#
# NOTE: 大版本号的更新会清零小版本号。
.PHONY: version
target = patch
version:
@VER=$$(pnpm version $(target) --commit-hooks=false --git-tag-version=false --workspaces \
--include-workspace-root --workspaces-update=false | tail -n 1 | sed 's/^v//'); \
echo $$VER > cmfx/VERSION