Skip to content

Commit 30edc43

Browse files
glauberlimaclaude
andcommitted
chore: improve project configuration and documentation
- Simplify .editorconfig by removing redundant file-specific rules - Remove .gitattributes file (using default git behavior) - Track Cargo.lock in version control for reproducible builds - Replace placeholder CLAUDE.md with comprehensive project documentation - Add Conventional Commits reminder to CLAUDE.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent fe85df2 commit 30edc43

File tree

6 files changed

+1521
-42
lines changed

6 files changed

+1521
-42
lines changed

.editorconfig

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,9 @@ trim_trailing_whitespace = true
88
indent_style = space
99
indent_size = 4
1010

11-
[*.rs]
12-
indent_style = space
13-
indent_size = 4
14-
15-
[*.toml]
16-
indent_style = space
17-
indent_size = 4
18-
1911
[*.md]
2012
trim_trailing_whitespace = false
2113
max_line_length = 100
2214

2315
[*.{yml,yaml}]
24-
indent_style = space
25-
indent_size = 2
26-
27-
[*.json]
28-
indent_style = space
2916
indent_size = 2

.gitattributes

Lines changed: 0 additions & 23 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Rust build artifacts
22
target/
3-
Cargo.lock
43

54
# IDE and editor files
65
.vscode/

CLAUDE.md

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,118 @@
1-
- sempre que estiver prestes a implementar um planejamento, me lembre de mudar para o modelo Haiku, caso ja nao esteja
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a Rust CLI tool that generates blocklists (AdBlock and hosts formats) from Procon-SP's (São Paulo Consumer Protection Foundation) database of untrusted websites. The tool fetches data from the public API and generates formatted blocklists that can be used in ad blockers or system hosts files.
8+
9+
## Development Commands
10+
11+
### Build and Run
12+
```bash
13+
# Development build
14+
cargo build
15+
16+
# Release build (optimized)
17+
cargo build --release
18+
19+
# Run in development
20+
cargo run -- generate
21+
22+
# Run release binary
23+
./target/release/procon-cli generate
24+
25+
# Generate specific formats
26+
./target/release/procon-cli generate --format adblock --output adblock.txt
27+
./target/release/procon-cli generate --format hosts --output hosts
28+
```
29+
30+
### Testing
31+
```bash
32+
# Run all tests
33+
cargo test
34+
35+
# Run tests with output
36+
cargo test -- --nocapture
37+
```
38+
39+
### Linting and Formatting
40+
```bash
41+
# Check code formatting
42+
cargo fmt -- --check
43+
44+
# Format code
45+
cargo fmt
46+
47+
# Run clippy for lints
48+
cargo clippy
49+
```
50+
51+
## Architecture
52+
53+
### Single-File Structure
54+
The entire application is contained in `src/main.rs` with a simple, straightforward architecture:
55+
56+
1. **CLI Layer** (lines 1-25): Uses `clap` for command-line argument parsing
57+
- Single `generate` subcommand with `--format` and `--output` options
58+
59+
2. **Data Fetching** (`fetch_sites()`, lines 63-83):
60+
- Makes HTTP request to Procon-SP API
61+
- Endpoint: `https://sistemas.procon.sp.gov.br/evitesite/list/evitesite.php`
62+
- Fetches up to 600 sites (jtPageSize=600)
63+
- Parses JSON response and extracts site URLs from `Records[].strSite`
64+
65+
3. **Format Generators**:
66+
- `generate_adblock()` (lines 85-105): Creates AdBlock filter list format with `||domain^` rules
67+
- `generate_hosts()` (lines 107-126): Creates hosts file format with `0.0.0.0 domain` entries
68+
- Both include metadata headers with title, description, license, and timestamp
69+
70+
4. **Output Handler** (`generate_list()`, lines 40-61):
71+
- Writes to file if `--output` specified, otherwise prints to stdout
72+
- Progress messages go to stderr, data to stdout
73+
74+
### Key Dependencies
75+
- **clap**: CLI argument parsing (derive API)
76+
- **reqwest**: HTTP client with native-tls
77+
- **serde/serde_json**: JSON deserialization
78+
- **tokio**: Async runtime (rt-multi-thread)
79+
- **chrono**: Timestamp formatting for headers
80+
- **anyhow**: Error handling
81+
82+
### Release Profile
83+
The `Cargo.toml` includes aggressive optimization settings for small, fast binaries:
84+
- LTO enabled
85+
- Single codegen unit
86+
- Panic=abort
87+
- Symbols stripped
88+
89+
## CI/CD Workflows
90+
91+
### PR Validation (`.github/workflows/validate-pr.yml`)
92+
Runs on PRs to main when Rust code or Cargo files change:
93+
1. Runs `cargo test`
94+
2. Runs `cargo build --release`
95+
96+
### Automated List Generation (`.github/workflows/generate-lists.yml`)
97+
Runs Tuesday-Friday at 02:30 UTC via cron schedule:
98+
1. Downloads latest pre-compiled Linux binary from releases
99+
2. Generates both AdBlock and hosts formats
100+
3. Compares site listings (ignoring timestamp changes)
101+
4. Only commits if actual site list changed
102+
103+
## Testing Strategy
104+
105+
Tests in `src/main.rs` (lines 128-165):
106+
- `test_mock_sites_structure`: Validates data structure handling
107+
- `test_generate_adblock`: Verifies AdBlock format generation
108+
- `test_generate_hosts`: Verifies hosts format generation
109+
110+
All tests use mock data, no network calls to actual API.
111+
112+
## Important Notes
113+
114+
- The project uses Rust edition 2024 (requires Rust 1.91+)
115+
- API responses may change format - the code expects JSON with `Records` array
116+
- The tool adds timestamps to headers, so file changes don't always mean content changes
117+
- Generated files are committed to `data/` directory for GitHub-hosted consumption
118+
- Always use Conventional Commits pattern when committing

0 commit comments

Comments
 (0)