refactor: move server rs workspace entries into crates

This commit is contained in:
2026-04-21 11:01:25 +08:00
parent 5a60ab3972
commit f6bf5f665e
47 changed files with 244 additions and 233 deletions

View File

@@ -8,13 +8,13 @@ usage() {
cat <<'EOF'
用法:
./server-rs/scripts/check.sh
SERVER_RS_CHECK_PACKAGE=api-server ./server-rs/scripts/check.sh
SERVER_RS_CHECK_CRATE=api-server ./server-rs/scripts/check.sh
说明:
1. 先执行整个 `server-rs` workspace 的 `cargo fmt --all --check`
2. 默认继续执行整个 workspace 的 `cargo clippy`、`cargo check`、`cargo test`
3. 可通过 `SERVER_RS_CHECK_PACKAGE` 将 clippy/check/test 收窄到单个 package
4. `cargo fmt --all --check` 始终覆盖整个 workspace避免多 package 下格式口径漂移
3. 可通过 `SERVER_RS_CHECK_CRATE` 将 clippy/check/test 收窄到单个 crate
4. `cargo fmt --all --check` 始终覆盖整个 workspace避免多 crate 下格式口径漂移
EOF
}
@@ -38,16 +38,18 @@ echo "[server-rs:check] 步骤: cargo fmt --all --check"
cd "${SERVER_RS_DIR}"
cargo fmt --all --check --manifest-path "${MANIFEST_PATH}"
if [[ -n "${SERVER_RS_CHECK_PACKAGE:-}" ]]; then
echo "[server-rs:check] 目标 package: ${SERVER_RS_CHECK_PACKAGE}"
echo "[server-rs:check] 步骤: cargo clippy -p ${SERVER_RS_CHECK_PACKAGE} --all-targets --all-features -D warnings"
cargo clippy -p "${SERVER_RS_CHECK_PACKAGE}" --manifest-path "${MANIFEST_PATH}" --all-targets --all-features -- -D warnings
TARGET_CRATE="${SERVER_RS_CHECK_CRATE:-${SERVER_RS_CHECK_PACKAGE:-}}"
echo "[server-rs:check] 步骤: cargo check -p ${SERVER_RS_CHECK_PACKAGE}"
cargo check -p "${SERVER_RS_CHECK_PACKAGE}" --manifest-path "${MANIFEST_PATH}"
if [[ -n "${TARGET_CRATE}" ]]; then
echo "[server-rs:check] 目标 crate: ${TARGET_CRATE}"
echo "[server-rs:check] 步骤: cargo clippy -p ${TARGET_CRATE} --all-targets --all-features -D warnings"
cargo clippy -p "${TARGET_CRATE}" --manifest-path "${MANIFEST_PATH}" --all-targets --all-features -- -D warnings
echo "[server-rs:check] 步骤: cargo test -p ${SERVER_RS_CHECK_PACKAGE}"
cargo test -p "${SERVER_RS_CHECK_PACKAGE}" --manifest-path "${MANIFEST_PATH}"
echo "[server-rs:check] 步骤: cargo check -p ${TARGET_CRATE}"
cargo check -p "${TARGET_CRATE}" --manifest-path "${MANIFEST_PATH}"
echo "[server-rs:check] 步骤: cargo test -p ${TARGET_CRATE}"
cargo test -p "${TARGET_CRATE}" --manifest-path "${MANIFEST_PATH}"
else
echo "[server-rs:check] 步骤: cargo clippy --workspace --all-targets --all-features -D warnings"
cargo clippy --workspace --manifest-path "${MANIFEST_PATH}" --all-targets --all-features -- -D warnings