refactor template

This commit is contained in:
Jev
2026-01-19 21:16:56 +01:00
parent 27bb46e039
commit 1b66fecb9a
29 changed files with 555 additions and 256 deletions

View File

@@ -1,19 +1,18 @@
# Python Library Template
# Python App Template
A [Cookiecutter](https://github.com/cookiecutter/cookiecutter) template for creating modern Python libraries with uv, ruff, mypy, and pytest.
A Cookiecutter template for building CLI-first Python applications with uv, Typer, Pydantic, and strict typing.
## Features
- **Modern Python setup** with Python 3.12+ support
- **uv** for fast dependency management
- **Ruff** for linting and formatting
- **MyPy** for type checking
- **CLI-first** architecture with Typer
- **Local-first config** (XDG paths) with env override
- **uv** for fast dependency management and reproducible installs
- **Ruff** for linting/formatting
- **MyPy** with strict typing
- **Pytest** with coverage support
- **bump-my-version** for automated version management
- **Invoke** tasks for common operations
- **Pre-configured** development workflow
- **Type hints** support with py.typed marker
- **CLAUDE.md** guidance for Claude Code integration
- **py.typed** marker for typed packages
- **Example command** wired from core `commands/` into CLI
## Quick Start
@@ -24,12 +23,12 @@ A [Cookiecutter](https://github.com/cookiecutter/cookiecutter) template for crea
2. Generate a new project:
```bash
cruft create https://gitlab.com/roxautomation/templates/python-lib-template
cruft create https://gitlab.com/roxautomation/templates/python-app-template
```
Or locally:
```bash
cookiecutter /path/to/python-lib-template
cookiecutter /path/to/python-app-template
```
3. The template will prompt for project details and automatically:
@@ -42,10 +41,10 @@ A [Cookiecutter](https://github.com/cookiecutter/cookiecutter) template for crea
| Variable | Description | Example |
|----------|-------------|---------|
| `project_name` | Human-readable project name | "My Python Library" |
| `project_slug` | Repository/directory name | "my-python-library" |
| `package_name` | Python package name | "my_python_library" |
| `description` | Short project description | "A modern Python library" |
| `project_name` | Human-readable project name | "My CLI App" |
| `project_slug` | Repository/directory name | "my-cli-app" |
| `package_name` | Python package name | "my_cli_app" |
| `description` | Short project description | "A modern CLI tool" |
| `author_name` | Author's full name | "Your Name" |
| `author_email` | Author's email | "your.email@example.com" |
| `version` | Initial version | "0.1.0" |
@@ -55,49 +54,58 @@ A [Cookiecutter](https://github.com/cookiecutter/cookiecutter) template for crea
```
your-project/
├── CLAUDE.md # Claude Code guidance
├── README.md # Project documentation
├── pyproject.toml # Project configuration
├── tasks.py # Invoke tasks
├── README.md
├── pyproject.toml
├── tasks.py
├── src/
│ └── your_package/
│ ├── __init__.py
│ ├── core.py
── py.typed
│ ├── py.typed
── cli/
│ │ ├── __init__.py
│ │ ├── app.py
│ │ ├── common.py
│ │ ├── config.py
│ │ └── hello.py
│ ├── config/
│ │ ├── __init__.py
│ │ ├── paths.py
│ │ └── settings.py
│ ├── commands/
│ │ ├── __init__.py
│ │ └── hello.py
│ ├── models/
│ │ └── __init__.py
│ └── utils/
│ ├── __init__.py
│ └── logging.py
├── tests/
── test_your_package.py
── conftest.py
│ ├── test_public.py
│ └── test_internals.py
└── examples/
└── basic_usage.py
└── config_init.sh
```
## Development Workflow
The generated project includes these common tasks:
### Setup
```bash
uv sync
uv sync --group dev
```
### Code Quality
```bash
uv run ruff check --fix # Linting
uv run ruff format # Formatting
uv run mypy . # Type checking
uv run invoke lint # All quality checks
uv run ruff check src tests
uv run ruff format src tests
uv run mypy src
uv run invoke lint
```
### Testing
```bash
uv run pytest # Run tests
uv run invoke test # Run tests with coverage
```
### Version Management
```bash
uv run bump-my-version bump patch # 0.1.0 → 0.1.1
uv run bump-my-version bump minor # 0.1.0 → 0.2.0
uv run bump-my-version bump major # 0.1.0 → 1.0.0
uv run pytest
uv run invoke test
```
## Template Development