refactor: comprehensive code quality, security, and release readiness improvements
Some checks failed
Lint & Test / test (push) Failing after 48s
Some checks failed
Lint & Test / test (push) Failing after 48s
Security: tighten CORS defaults, add webhook rate limiting, fix XSS in automations, guard WebSocket JSON.parse, validate ADB address input, seal debug exception leak, URL-encode WS tokens, CSS.escape in selectors. Code quality: add Pydantic models for brightness/power endpoints, fix thread safety and name uniqueness in DeviceStore, immutable update pattern, split 6 oversized files into 16 focused modules, enable TypeScript strictNullChecks (741→102 errors), type state variables, add dom-utils helper, migrate 3 modules from inline onclick to event delegation, ProcessorDependencies dataclass. Performance: async store saves, health endpoint log level, command palette debounce, optimized entity-events comparison, fix service worker precache list. Testing: expand from 45 to 293 passing tests — add store tests (141), route tests (25), core logic tests (42), E2E flow tests (33), organize into tests/api/, tests/storage/, tests/core/, tests/e2e/. DevOps: CI test pipeline, pre-commit config, Dockerfile multi-stage build with non-root user and health check, docker-compose improvements, version bump to 0.2.0. Docs: rewrite CLAUDE.md (202→56 lines), server/CLAUDE.md (212→76), create contexts/server-operations.md, fix .js→.ts references, fix env var prefix in README, rewrite INSTALLATION.md, add CONTRIBUTING.md and .env.example.
This commit is contained in:
85
CONTRIBUTING.md
Normal file
85
CONTRIBUTING.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# Contributing
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Python 3.11+
|
||||
- Node.js 20+ (for frontend bundle)
|
||||
- Git
|
||||
|
||||
## Development Setup
|
||||
|
||||
```bash
|
||||
git clone https://git.dolgolyov-family.by/alexei.dolgolyov/wled-screen-controller-mixed.git
|
||||
cd wled-screen-controller-mixed/server
|
||||
|
||||
# Python environment
|
||||
python -m venv venv
|
||||
source venv/bin/activate # Linux/Mac
|
||||
# venv\Scripts\activate # Windows
|
||||
pip install -e ".[dev]"
|
||||
|
||||
# Frontend dependencies
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
## Running the Server
|
||||
|
||||
```bash
|
||||
cd server
|
||||
export PYTHONPATH=$(pwd)/src # Linux/Mac
|
||||
# set PYTHONPATH=%CD%\src # Windows
|
||||
python -m wled_controller.main
|
||||
```
|
||||
|
||||
Open http://localhost:8080 to access the dashboard.
|
||||
|
||||
## Running Tests
|
||||
|
||||
```bash
|
||||
cd server
|
||||
pytest
|
||||
```
|
||||
|
||||
Tests use pytest with pytest-asyncio. Coverage reports are generated automatically.
|
||||
|
||||
## Code Style
|
||||
|
||||
This project uses **black** for formatting and **ruff** for linting (both configured in `pyproject.toml` with a line length of 100).
|
||||
|
||||
```bash
|
||||
cd server
|
||||
black src/ tests/
|
||||
ruff check src/ tests/
|
||||
```
|
||||
|
||||
## Frontend Changes
|
||||
|
||||
After modifying any file under `server/src/wled_controller/static/js/` or `static/css/`, rebuild the bundle:
|
||||
|
||||
```bash
|
||||
cd server
|
||||
npm run build
|
||||
```
|
||||
|
||||
The browser loads the esbuild bundle (`static/dist/`), not the source files directly.
|
||||
|
||||
## Commit Messages
|
||||
|
||||
Follow the [Conventional Commits](https://www.conventionalcommits.org/) format:
|
||||
|
||||
```
|
||||
feat: add new capture engine
|
||||
fix: correct LED color mapping
|
||||
refactor: extract filter pipeline
|
||||
docs: update API reference
|
||||
test: add audio source tests
|
||||
chore: update dependencies
|
||||
```
|
||||
|
||||
## Pull Requests
|
||||
|
||||
1. Create a feature branch from `master`
|
||||
2. Make your changes with tests
|
||||
3. Ensure `ruff check` and `pytest` pass
|
||||
4. Open a PR with a clear description of the change
|
||||
Reference in New Issue
Block a user