配置: - rustfmt.toml: 固化 max_width=100 / 4 空格缩进,cargo fmt 全量格式化 - Cargo.toml: 配置 [lints.rust] 与 [lints.clippy] 渐进式规则 - .github/workflows/ci.yml: Rust(fmt+clippy+test) + 前端(eslint+tsc+test) 双平台 CI - Makefile: 新增 check/fmt/fix 目标,clippy 对齐 --all-targets --all-features - web: eslint flat config + prettier 配置 + package.json 脚本与依赖 - src/main.rs: loop→while 修复 clippy::never_loop 对抗性审查发现并修复: - eslint 缺 caughtErrorsIgnorePattern 导致 catch(_) 误报为 error - 前端 lint 未接入 CI,现已补上 Lint 步骤 - Makefile 与 CI 的 clippy flags 不一致,已对齐
83 lines
2.1 KiB
Makefile
83 lines
2.1 KiB
Makefile
# PicoBot Web UI Makefile
|
|
|
|
.PHONY: dev dev-backend dev-frontend build clean install check fmt fix help
|
|
|
|
# Default target
|
|
all: build
|
|
|
|
# Install dependencies
|
|
install:
|
|
@echo "Installing frontend dependencies..."
|
|
cd web && npm install
|
|
|
|
# Development - start both backend and frontend
|
|
dev:
|
|
@echo "Starting development servers..."
|
|
@make dev-backend &
|
|
@sleep 3
|
|
@make dev-frontend
|
|
@wait
|
|
|
|
# Start backend only
|
|
dev-backend:
|
|
@echo "Starting Rust backend..."
|
|
cargo run -- gateway
|
|
|
|
# Start frontend only
|
|
dev-frontend:
|
|
@echo "Starting frontend dev server..."
|
|
cd web && npm run dev
|
|
|
|
# Build for production (frontend is built automatically by cargo via build.rs)
|
|
build:
|
|
@echo "Building PicoBot Web UI..."
|
|
cargo build --release
|
|
@echo "Build complete!"
|
|
|
|
# Run production build
|
|
run:
|
|
cargo run --release -- gateway
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
@echo "Cleaning build artifacts..."
|
|
rm -rf static/*
|
|
cd web && rm -rf dist node_modules
|
|
cargo clean
|
|
|
|
# Check code formatting and linting
|
|
check:
|
|
@echo "Checking formatting..."
|
|
cargo fmt --all -- --check
|
|
@echo "Checking frontend (lint + build)..."
|
|
cd web && npm run lint
|
|
cd web && npm run build
|
|
@echo "Checking Rust code..."
|
|
cargo check
|
|
cargo clippy --all-targets --all-features
|
|
|
|
# Format all Rust code in place
|
|
fmt:
|
|
cargo fmt --all
|
|
|
|
# Auto-fix clippy lints where possible
|
|
fix:
|
|
cargo clippy --fix --all-targets --allow-dirty --allow-no-vcs
|
|
|
|
# Help
|
|
help:
|
|
@echo "PicoBot Web UI Makefile"
|
|
@echo ""
|
|
@echo "Available targets:"
|
|
@echo " make install - Install frontend dependencies"
|
|
@echo " make dev - Start both backend and frontend (development)"
|
|
@echo " make dev-backend - Start Rust backend only"
|
|
@echo " make dev-frontend - Start frontend dev server only"
|
|
@echo " make build - Build for production"
|
|
@echo " make run - Run production build"
|
|
@echo " make clean - Clean build artifacts"
|
|
@echo " make check - Check code formatting and linting"
|
|
@echo " make fmt - Format all Rust code in place"
|
|
@echo " make fix - Auto-fix clippy lints where possible"
|
|
@echo " make help - Show this help message"
|