feat(agent): add agent/lprovider crate scaffold and workspace Makefile
zhenyi committed
Added agent/lprovider/Cargo.toml agent/lprovider/Cargo.toml +14 −0 View agent/lprovider/Cargo.toml
@@ -0,0 +1,14 @@
1[package]
2name = "lprovider"
3version.workspace = true
4edition.workspace = true
5authors.workspace = true
6categories.workspace = true
7keywords.workspace = true
8repository.workspace = true
9homepage.workspace = true
10
11[lib]
12path = "lib.rs"
13name = "lprovider"
14[dependencies]
Added agent/lprovider/lib.rs agent/lprovider/lib.rs +0 −0 View agent/lprovider/lib.rs
No content changes.
Added Makefile Makefile +246 −0 View Makefile
@@ -0,0 +1,246 @@
1SHELL := /usr/bin/env bash
2MAKEFLAGS += --no-builtin-rules
3
4EXTRA_ARGS := $(filter-out -- $(firstword $(MAKECMDGOALS)),$(MAKECMDGOALS))
5
6.DEFAULT_GOAL := help
7
8.PHONY: help
9help:
10 @printf ' \033[36m%-22s\033[0m %s\n' 'target' 'description'
11 @awk 'BEGIN {FS = ":.*?## "} \
12 /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}' \
13 $(MAKEFILE_LIST)
14
15.PHONY: build
16build:
17 cargo build --workspace
18
19.PHONY: check
20check:
21 cargo check --workspace --all-targets
22
23.PHONY: test
24test:
25 cargo test --workspace
26
27.PHONY: clippy
28clippy:
29 cargo clippy --workspace --all-targets -- -D warnings
30
31.PHONY: fmt
32fmt:
33 cargo fmt --all
34
35.PHONY: fmt-check
36fmt-check:
37 cargo fmt --all --check
38
39.PHONY: clean
40clean:
41 cargo clean
42 @find . -type d -name target -prune -exec rm -rf {} +
43 @echo "已清理 target/ 目录"
44
45.PHONY: list-apps
46list-apps:
47 @echo apihost githook gitpro livechat mails
48
49.PHONY: ports
50ports:
51 @printf ' %-12s %s\n' app port
52 @printf ' %-12s %s\n' apihost 8080
53 @printf ' %-12s %s\n' githook '(non-network)'
54 @printf ' %-12s %s\n' gitpro '(non-network)'
55 @printf ' %-12s %s\n' livechat 8081
56 @printf ' %-12s %s\n' mails '(non-network)'
57
58.PHONY: port-check
59port-check:
60 @status=0; \
61 check() { \
62 port="$$1"; \
63 name="$$2"; \
64 if [ "$$port" = "0" ]; then return; fi; \
65 if ss -ltn 2>/dev/null | grep -q ":$$port "; then \
66 echo " ✗ $$name: port $$port 已占用"; \
67 status=1; \
68 else \
69 echo " ✓ $$name: port $$port 空闲"; \
70 fi; \
71 }; \
72 check 8080 apihost; \
73 check 8081 livechat; \
74 exit $$status
75
76.PHONY: run-apihost
77run-apihost:
78 @if ss -ltn 2>/dev/null | grep -q ":8080 "; then \
79 echo "✗ apihost 默认端口 8080 已被占用"; \
80 echo " kill 占用进程,或 make run-apihost -- --port <其他>"; \
81 exit 1; \
82 fi
83 @if [ -n "$(EXTRA_ARGS)" ]; then \
84 cargo run -p apihost -- $(EXTRA_ARGS); \
85 else \
86 cargo run -p apihost; \
87 fi
88
89.PHONY: build-apihost
90build-apihost:
91 cargo build -p apihost
92
93.PHONY: check-apihost
94check-apihost:
95 cargo check -p apihost
96
97.PHONY: test-apihost
98test-apihost:
99 cargo test -p apihost
100
101.PHONY: dev-apihost
102dev-apihost:
103 @command -v cargo-watch >/dev/null 2>&1 || { \
104 echo "缺少 cargo-watch,请先: cargo install cargo-watch --locked"; \
105 exit 1; \
106 }
107 cargo watch -x "run -p apihost"
108
109.PHONY: run-githook
110run-githook:
111 @if [ -n "$(EXTRA_ARGS)" ]; then \
112 cargo run -p githook -- $(EXTRA_ARGS); \
113 else \
114 cargo run -p githook; \
115 fi
116
117.PHONY: build-githook
118build-githook:
119 cargo build -p githook
120
121.PHONY: check-githook
122check-githook:
123 cargo check -p githook
124
125.PHONY: test-githook
126test-githook:
127 cargo test -p githook
128
129.PHONY: dev-githook
130dev-githook:
131 @command -v cargo-watch >/dev/null 2>&1 || { \
132 echo "缺少 cargo-watch,请先: cargo install cargo-watch --locked"; \
133 exit 1; \
134 }
135 cargo watch -x "run -p githook"
136
137.PHONY: run-gitpro
138run-gitpro:
139 @if [ -n "$(EXTRA_ARGS)" ]; then \
140 cargo run -p gitpro -- $(EXTRA_ARGS); \
141 else \
142 cargo run -p gitpro; \
143 fi
144
145.PHONY: build-gitpro
146build-gitpro:
147 cargo build -p gitpro
148
149.PHONY: check-gitpro
150check-gitpro:
151 cargo check -p gitpro
152
153.PHONY: test-gitpro
154test-gitpro:
155 cargo test -p gitpro
156
157.PHONY: dev-gitpro
158dev-gitpro:
159 @command -v cargo-watch >/dev/null 2>&1 || { \
160 echo "缺少 cargo-watch,请先: cargo install cargo-watch --locked"; \
161 exit 1; \
162 }
163 cargo watch -x "run -p gitpro"
164
165.PHONY: run-livechat
166run-livechat:
167 @if ss -ltn 2>/dev/null | grep -q ":8081 "; then \
168 echo "✗ livechat 默认端口 8081 已被占用"; \
169 echo " kill 占用进程,或 make run-livechat -- --port <其他>"; \
170 exit 1; \
171 fi
172 @if [ -n "$(EXTRA_ARGS)" ]; then \
173 cargo run -p livechat -- $(EXTRA_ARGS); \
174 else \
175 cargo run -p livechat; \
176 fi
177
178.PHONY: build-livechat
179build-livechat:
180 cargo build -p livechat
181
182.PHONY: check-livechat
183check-livechat:
184 cargo check -p livechat
185
186.PHONY: test-livechat
187test-livechat:
188 cargo test -p livechat
189
190.PHONY: dev-livechat
191dev-livechat:
192 @command -v cargo-watch >/dev/null 2>&1 || { \
193 echo "缺少 cargo-watch,请先: cargo install cargo-watch --locked"; \
194 exit 1; \
195 }
196 cargo watch -x "run -p livechat"
197
198.PHONY: run-mails
199run-mails:
200 @if [ -n "$(EXTRA_ARGS)" ]; then \
201 cargo run -p mails -- $(EXTRA_ARGS); \
202 else \
203 cargo run -p mails; \
204 fi
205
206.PHONY: build-mails
207build-mails:
208 cargo build -p mails
209
210.PHONY: check-mails
211check-mails:
212 cargo check -p mails
213
214.PHONY: test-mails
215test-mails:
216 cargo test -p mails
217
218.PHONY: dev-mails
219dev-mails:
220 @command -v cargo-watch >/dev/null 2>&1 || { \
221 echo "缺少 cargo-watch,请先: cargo install cargo-watch --locked"; \
222 exit 1; \
223 }
224 cargo watch -x "run -p mails"
225
226.PHONY: run
227run: run-apihost
228
229.PHONY: run-all
230run-all: port-check
231 @trap 'kill 0' SIGINT SIGTERM; \
232 cargo run -p apihost -- --port 8080 & \
233 cargo run -p githook & \
234 cargo run -p gitpro & \
235 cargo run -p livechat -- --port 8081 & \
236 cargo run -p mails & \
237 wait
238
239.PHONY: check-deps
240check-deps:
241 @command -v cargo-outdated >/dev/null 2>&1 && \
242 cargo outdated --workspace --exit-code 0 || \
243 echo "未安装 cargo-outdated(cargo install cargo-outdated --locked)"
244 @command -v cargo-deny >/dev/null 2>/dev/null && \
245 cargo deny check || \
246 echo "未安装 cargo-deny(cargo install cargo-deny --locked)"
No newline at end of file