Files
CleanMM/CONTRIBUTING.md

134 lines
3.9 KiB
Markdown
Raw Normal View History

# Contributing to Atlas for Mac
2025-10-12 20:49:10 +08:00
Thank you for your interest in contributing to Atlas for Mac! This guide covers everything you need to get started.
2025-10-12 20:49:10 +08:00
## Prerequisites
2025-10-12 20:49:10 +08:00
- macOS 14.0 (Sonoma) or later
- Xcode 16+ (Swift 6.0)
- [xcodegen](https://github.com/yonaskolb/XcodeGen): `brew install xcodegen`
- Go 1.24+ (only for legacy CLI components)
2025-10-12 20:49:10 +08:00
## Getting Started
2025-10-12 20:49:10 +08:00
2025-10-13 10:20:46 +08:00
```bash
# Clone the repository
git clone https://github.com/CSZHK/CleanMyPc.git
cd CleanMyPc
2025-10-12 20:49:10 +08:00
# Option A: Run directly
swift run --package-path Apps AtlasApp
2025-10-12 21:43:37 +08:00
# Option B: Open in Xcode
xcodegen generate
open Atlas.xcodeproj
2025-10-13 10:20:46 +08:00
```
2025-10-12 20:49:10 +08:00
## Architecture Overview
2025-10-12 20:49:10 +08:00
Atlas uses a layered Swift Package architecture with strict top-down dependency direction:
2025-12-08 15:33:52 +08:00
```
Apps/AtlasApp ← App entry point, state management, routing
Feature Packages ← One package per module (Overview, SmartClean, Apps, etc.)
AtlasDesignSystem ← Brand tokens, reusable UI components
AtlasDomain ← Core models, localization (AtlasL10n)
AtlasApplication ← Workspace controller, repository layer
AtlasInfrastructure ← Worker management, XPC communication
XPC/AtlasWorkerXPC ← Sandboxed worker service
Helpers/ ← Privileged helper for elevated operations
```
2025-10-12 20:49:10 +08:00
Each feature package depends only on `AtlasDesignSystem` + `AtlasDomain` and receives callbacks for parent coordination.
2025-12-08 15:33:52 +08:00
## Running Tests
2025-12-08 15:33:52 +08:00
```bash
# Domain, design system, adapters, and shared packages
swift test --package-path Packages
2025-12-08 15:33:52 +08:00
# App-level tests
swift test --package-path Apps
2025-12-08 15:33:52 +08:00
# Run a single test target
swift test --package-path Packages --filter AtlasDomainTests
2025-12-08 15:33:52 +08:00
# Full test suite (includes Go and shell tests)
./scripts/test.sh
2025-12-08 15:33:52 +08:00
```
## Code Quality
2025-12-08 15:33:52 +08:00
Run formatting and linting before committing:
2025-12-08 15:33:52 +08:00
```bash
./scripts/check.sh
2025-12-08 15:33:52 +08:00
```
CI will also run these checks automatically on every push and pull request.
2025-12-08 15:33:52 +08:00
## Code Style
2025-12-08 15:33:52 +08:00
### Swift
2025-12-08 15:33:52 +08:00
- Swift 6.0 with strict concurrency enabled
- Follow existing patterns in the codebase
- Use `AtlasL10n` for all user-facing strings — never hardcode display text
2025-12-08 15:33:52 +08:00
### Design System
All UI should use the shared design tokens from `AtlasDesignSystem`:
2025-12-08 15:33:52 +08:00
- **Colors**: `AtlasColor` — brand (teal), accent (mint), semantic (success/warning/danger/info)
- **Typography**: `AtlasTypography` — screenTitle, heroMetric, sectionTitle, label, body, caption
- **Spacing**: `AtlasSpacing` — 4pt grid (xxs=4, xs=8, sm=12, md=16, lg=20, xl=24, section=32)
- **Radius**: `AtlasRadius` — continuous corners (sm=8, md=12, lg=16)
2025-12-08 15:33:52 +08:00
### File Operations
2025-11-21 19:09:15 +08:00
All cleanup and deletion logic must use safe wrappers. Never use raw `rm -rf` or unguarded file removal. See `SECURITY_AUDIT.md` for details on path validation and deletion boundaries.
2025-11-21 19:09:15 +08:00
## Localization
2025-11-21 19:09:15 +08:00
Atlas supports Simplified Chinese (default) and English.
2025-12-01 19:26:03 +08:00
String files are located at:
2025-12-01 19:26:03 +08:00
```
Packages/AtlasDomain/Sources/AtlasDomain/Resources/zh-Hans.lproj/Localizable.strings
Packages/AtlasDomain/Sources/AtlasDomain/Resources/en.lproj/Localizable.strings
```
2025-12-01 19:26:03 +08:00
When adding user-facing text:
2025-11-21 19:09:15 +08:00
1. Add entries to **both** `.strings` files
2. Access strings via the `AtlasL10n` enum
## Go Components
The `cmd/analyze/` and `cmd/status/` directories contain Go-based TUI tools inherited from the upstream Mole project. These are built separately:
```bash
make build # Build for current architecture
go run ./cmd/analyze # Run disk analyzer directly
go run ./cmd/status # Run system monitor directly
```
## Pull Requests
2025-12-01 19:26:03 +08:00
1. Fork the repository and create a branch from `main`
2. Make your changes
3. Run tests: `swift test --package-path Packages && swift test --package-path Apps`
4. Run quality checks: `./scripts/check.sh`
5. Open a PR targeting `main`
2025-11-21 19:09:15 +08:00
CI will verify formatting, linting, and tests automatically.
2025-10-12 20:49:10 +08:00
## Security
2025-10-12 20:49:10 +08:00
If you discover a security vulnerability, **do not** open a public issue. Please report it privately following the instructions in [SECURITY.md](SECURITY.md).