Files
CleanMM/CONTRIBUTING.md

84 lines
1.8 KiB
Markdown
Raw Normal View History

2025-10-12 20:49:10 +08:00
# Contributing to Mole
## Setup
```bash
2025-10-13 10:20:46 +08:00
# Install development tools
2025-10-12 20:49:10 +08:00
brew install shfmt shellcheck bats-core
```
## Development
2025-10-13 10:20:46 +08:00
Run all quality checks before committing:
2025-10-12 20:49:10 +08:00
2025-10-13 10:20:46 +08:00
```bash
./scripts/check.sh
2025-10-12 20:49:10 +08:00
```
2025-10-13 10:20:46 +08:00
This command runs:
2025-10-12 20:49:10 +08:00
2025-10-13 10:20:46 +08:00
- Code formatting check
- ShellCheck linting
- Unit tests
Individual commands:
2025-10-12 21:43:37 +08:00
2025-10-12 20:49:10 +08:00
```bash
2025-10-13 10:20:46 +08:00
# Format code
./scripts/format.sh
2025-10-12 20:49:10 +08:00
2025-10-13 10:20:46 +08:00
# Run tests only
./tests/run.sh
```
2025-10-12 20:49:10 +08:00
## Code Style
- Bash 3.2+ compatible
- 4 spaces indent
- Use `set -euo pipefail`
- Quote all variables
- BSD commands not GNU
Config: `.editorconfig` and `.shellcheckrc`
2025-11-21 19:09:15 +08:00
## Requirements
- macOS 10.14 or newer, works on Intel and Apple Silicon
- Default macOS Bash 3.2+ plus administrator privileges for cleanup tasks
- Install Command Line Tools with `xcode-select --install` for curl, tar, and related utilities
- Go 1.24+ required when building the `mo status` or `mo analyze` TUI binaries locally
## Go Components
2025-12-01 19:26:03 +08:00
`mo status` and `mo analyze` use Go with Bubble Tea for interactive dashboards.
**Code organization:**
- Each module split into focused files by responsibility
- `cmd/analyze/` - Disk analyzer with 7 files under 500 lines each
- `cmd/status/` - System monitor with metrics split into 11 domain files
**Development workflow:**
2025-11-21 19:09:15 +08:00
- Format code with `gofmt -w ./cmd/...`
2025-12-01 19:26:03 +08:00
- Run `go vet ./cmd/...` to check for issues
- Build with `go build ./...` to verify all packages compile
- Build universal binaries via `./scripts/build-status.sh` and `./scripts/build-analyze.sh`
**Guidelines:**
- Keep files focused on single responsibility
- Extract constants instead of magic numbers
- Use context for timeout control on external commands
- Add comments explaining why, not what
2025-11-21 19:09:15 +08:00
2025-10-12 20:49:10 +08:00
## Pull Requests
1. Fork and create branch
2. Make changes
2025-10-13 10:20:46 +08:00
3. Run checks: `./scripts/check.sh`
4. Commit and push
5. Open PR
2025-10-12 20:49:10 +08:00
2025-10-13 10:20:46 +08:00
CI will verify formatting, linting, and tests.