Skip to content

Commit b47bb6e

Browse files
colyerdengShawnDen-coder
authored andcommitted
fix: fix template error
1 parent 2c9a8ab commit b47bb6e

File tree

15 files changed

+421
-84
lines changed

15 files changed

+421
-84
lines changed

README.md

Lines changed: 205 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,229 @@
33
[![PyPI version](https://badge.fury.io/py/repo-scaffold.svg)](https://badge.fury.io/py/repo-scaffold)
44
[![Python Version](https://img.shields.io/pypi/pyversions/repo-scaffold.svg)](https://pypi.org/project/repo-scaffold/)
55
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6+
[![Tests](https://github.com/your-username/repo-scaffold/workflows/Tests/badge.svg)](https://github.com/your-username/repo-scaffold/actions)
67

7-
A modern project scaffolding tool with component-based architecture.
8+
A modern, intelligent project scaffolding tool that generates production-ready Python projects in seconds.
89

9-
## Features
10+
## Features
1011

11-
- 🚀 Quick project creation
12-
- 📦 Component-based templates
13-
- ⚙️ Interactive configuration
14-
- 🔧 Best practices included
12+
- 🚀 **Zero-config setup** - Create projects instantly without answering questions
13+
- 📦 **Component-based architecture** - Mix and match features as needed
14+
- 🎯 **Production-ready templates** - Includes CI/CD, testing, documentation, and more
15+
- 🔧 **Modern Python tooling** - Built with uv, Ruff, pytest, and Task automation
16+
- 🐳 **Container support** - Optional Podman/Docker integration
17+
- 📚 **Documentation ready** - MkDocs setup with auto-generated API docs
18+
- 🔄 **GitHub Actions** - Complete CI/CD workflows included
19+
- 📦 **PyPI publishing** - Automated package publishing with trusted publishing
20+
- 🎨 **Code quality** - Pre-commit hooks, linting, and formatting configured
1521

16-
## Quick Start
22+
## 🚀 Quick Start
23+
24+
### Installation
1725

1826
```bash
19-
# Install
27+
# Install globally with uvx (recommended)
2028
uvx install repo-scaffold
2129

22-
# Create project
30+
# Or install with pip
31+
pip install repo-scaffold
32+
```
33+
34+
### Create Your First Project
35+
36+
```bash
37+
# Create a Python library project (uses smart defaults)
38+
repo-scaffold create
39+
40+
# That's it! Your project is ready with:
41+
# ✅ Modern Python setup (pyproject.toml, uv)
42+
# ✅ Testing framework (pytest with coverage)
43+
# ✅ Code quality tools (ruff, pre-commit)
44+
# ✅ GitHub Actions CI/CD
45+
# ✅ Documentation (MkDocs)
46+
# ✅ Task automation (Taskfile)
47+
```
48+
49+
### What You Get
50+
51+
After running `repo-scaffold create`, you'll have a complete project structure:
52+
53+
```
54+
my-python-library/
55+
├── .github/workflows/ # CI/CD pipelines
56+
├── docs/ # MkDocs documentation
57+
├── tests/ # Test suite
58+
├── my_python_library/ # Your package
59+
├── pyproject.toml # Modern Python configuration
60+
├── Taskfile.yml # Task automation
61+
├── README.md # Project documentation
62+
└── .pre-commit-config.yaml # Code quality hooks
63+
```
64+
65+
### Start Developing
66+
67+
```bash
68+
cd my-python-library
69+
task init # Initialize development environment
70+
task test # Run tests
71+
task lint # Check code quality
72+
task docs # Serve documentation locally
73+
```
74+
75+
## 📋 Available Commands
76+
77+
```bash
78+
# Project creation
79+
repo-scaffold create # Create with defaults (recommended)
80+
repo-scaffold create --input # Interactive mode with prompts
81+
repo-scaffold create -t python-library # Specify template explicitly
82+
repo-scaffold create -o ./my-project # Specify output directory
83+
84+
# Information commands
85+
repo-scaffold list # List available templates
86+
repo-scaffold components # List available components
87+
repo-scaffold show python-library # Show template details
88+
repo-scaffold --help # Show help
89+
```
90+
91+
## 🎯 Usage Examples
92+
93+
### Basic Usage (Recommended)
94+
95+
```bash
96+
# Create a project with smart defaults - no questions asked!
2397
repo-scaffold create
98+
```
99+
100+
This creates a full-featured Python library with:
101+
- **Python Core**: Modern pyproject.toml setup with uv
102+
- **Task Automation**: Taskfile.yml for common development tasks
103+
- **GitHub Actions**: Complete CI/CD with testing, linting, and publishing
104+
- **Documentation**: MkDocs with auto-generated API docs
105+
- **Code Quality**: Pre-commit hooks, Ruff linting and formatting
106+
- **Container Support**: Podman/Docker setup for containerized development
107+
- **PyPI Publishing**: Automated package publishing workflows
108+
109+
### Interactive Mode
110+
111+
```bash
112+
# If you want to customize the setup
113+
repo-scaffold create --input
114+
```
24115

25-
# Or run directly
26-
uvx run repo-scaffold create
116+
This will prompt you to:
117+
- Choose which components to include
118+
- Configure project details
119+
- Set up custom options
120+
121+
### Advanced Usage
122+
123+
```bash
124+
# Create in specific directory
125+
repo-scaffold create -o ~/projects/my-new-lib
126+
127+
# Use different template (when more templates are available)
128+
repo-scaffold create -t python-library
129+
130+
# Combine options
131+
repo-scaffold create -t python-library -o ~/projects --input
132+
```
133+
134+
## 🧩 Available Components
135+
136+
The `python-library` template includes these components:
137+
138+
| Component | Description | Included by Default |
139+
|-----------|-------------|-------------------|
140+
| **Python Core** | Modern Python setup with pyproject.toml and uv ||
141+
| **Task Automation** | Taskfile.yml for development workflows ||
142+
| **GitHub Actions** | CI/CD pipelines for testing and deployment ||
143+
| **MkDocs** | Documentation site with auto-generated API docs ||
144+
| **Pre-commit** | Code quality hooks and automated formatting ||
145+
| **Podman** | Container support for development and deployment ||
146+
| **PyPI Publishing** | Automated package publishing to PyPI ||
147+
148+
## 🛠️ Development Workflow
149+
150+
After creating your project, here's the typical development workflow:
151+
152+
```bash
153+
# 1. Initialize the development environment
154+
task init
155+
156+
# 2. Make your changes
157+
# Edit code in your_package/
158+
159+
# 3. Run tests
160+
task test
161+
162+
# 4. Check code quality
163+
task lint
164+
165+
# 5. View documentation
166+
task docs
167+
168+
# 6. Build package
169+
task build
170+
171+
# 7. Commit changes (pre-commit hooks will run automatically)
172+
git add .
173+
git commit -m "feat: add new feature"
174+
175+
# 8. Push to trigger CI/CD
176+
git push
27177
```
28178

29-
## Commands
179+
## 🔧 Configuration
180+
181+
### Default Values
182+
183+
The tool uses sensible defaults for all configuration:
184+
185+
- **Project Name**: "My Python Library"
186+
- **Package Name**: Auto-generated from project name
187+
- **Author**: "Your Name" (customize in interactive mode)
188+
- **License**: MIT
189+
- **Python Version**: 3.10-3.12 support, 3.10 for development
190+
- **All Components**: Enabled by default
191+
192+
### Customization
193+
194+
Use `--input` flag for interactive customization:
30195

31196
```bash
32-
repo-scaffold list # List templates
33-
repo-scaffold components # List components
34-
repo-scaffold create # Create project
35-
repo-scaffold show <name> # Show template info
197+
repo-scaffold create --input
36198
```
37199

38-
## Documentation
200+
This allows you to:
201+
- Set custom project name and description
202+
- Choose your preferred license
203+
- Select which components to include
204+
- Configure component-specific options
205+
206+
## 📚 Documentation
39207

40208
- [Getting Started](docs/getting-started/)
41209
- [Installation](docs/getting-started/installation.md)
42210
- [Quick Start](docs/getting-started/quick-start.md)
43211
- [Configuration](docs/getting-started/configuration.md)
212+
- [Components](docs/components/)
213+
- [Templates](docs/templates/)
214+
215+
## 🤝 Contributing
216+
217+
Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
218+
219+
## 📄 License
220+
221+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
222+
223+
## 🙏 Acknowledgments
224+
225+
Built with modern Python tooling:
226+
- [uv](https://github.com/astral-sh/uv) - Fast Python package manager
227+
- [Ruff](https://github.com/astral-sh/ruff) - Lightning-fast Python linter
228+
- [pytest](https://pytest.org/) - Testing framework
229+
- [MkDocs](https://www.mkdocs.org/) - Documentation generator
230+
- [Task](https://taskfile.dev/) - Task automation
231+
- [Cookiecutter](https://github.com/cookiecutter/cookiecutter) - Template engine

repo_scaffold/cli.py

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import click
1010
import yaml
1111

12-
from .core.component_manager import ComponentManager
13-
from .core.cookiecutter_runner import CookiecutterRunner
14-
from .core.template_composer import TemplateComposer
12+
from repo_scaffold.core.component_manager import ComponentManager
13+
from repo_scaffold.core.cookiecutter_runner import CookiecutterRunner
14+
from repo_scaffold.core.template_composer import TemplateComposer
1515

1616

1717
# Default paths - can be overridden by environment variables or config
@@ -35,19 +35,49 @@ def cli():
3535
default=Path.cwd(),
3636
help="Output directory for the generated project",
3737
)
38-
def create(template: str | None, output: Path):
39-
"""Create a new project from a template."""
38+
@click.option(
39+
"--no-input",
40+
is_flag=True,
41+
default=True,
42+
help="Do not prompt for parameters and only use cookiecutter.json file content (default: True)",
43+
)
44+
@click.option(
45+
"--input",
46+
"prompt_input",
47+
is_flag=True,
48+
help="Prompt for parameters interactively (overrides --no-input)",
49+
)
50+
def create(template: str | None, output: Path, no_input: bool, prompt_input: bool):
51+
"""Create a new project from a template.
52+
53+
By default, uses template defaults without prompting (--no-input).
54+
Use --input to enable interactive prompts for customization.
55+
"""
4056
try:
57+
# Determine if we should prompt for input
58+
# --input flag overrides the default --no-input behavior
59+
should_prompt = prompt_input or not no_input
60+
4161
if template:
4262
# Use specified template
4363
template_config = load_template_config(template)
4464
template_name = template
4565
else:
46-
# Interactive template selection
47-
template_name, template_config = interactive_template_selection()
48-
49-
# Interactive component selection
50-
selected_components = interactive_component_selection(template_config)
66+
# Interactive template selection (only if prompting is enabled)
67+
if should_prompt:
68+
template_name, template_config = interactive_template_selection()
69+
else:
70+
# Use default template when no input is requested
71+
template_name = "python-library"
72+
template_config = load_template_config(template_name)
73+
74+
# Component selection
75+
if should_prompt:
76+
# Interactive component selection
77+
selected_components = interactive_component_selection(template_config)
78+
else:
79+
# Use all required components when no input is requested
80+
selected_components = template_config.get("required_components", [])
5181

5282
# Initialize core components
5383
component_manager = ComponentManager(DEFAULT_COMPONENTS_DIR)
@@ -69,7 +99,7 @@ def create(template: str | None, output: Path):
6999
try:
70100
# Run cookiecutter
71101
click.echo("🚀 Generating project...")
72-
project_path = runner.run_cookiecutter(temp_template_dir, output)
102+
project_path = runner.run_cookiecutter(temp_template_dir, output, no_input=not should_prompt)
73103

74104
click.echo(f"✅ Project created successfully at: {project_path}")
75105

repo_scaffold/components/github_actions/files/.github/workflows/ci-tests.yaml.j2

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ permissions:
1010
contents: read
1111
env:
1212
{% if cookiecutter.use_private_pypi == "true" -%}
13-
UV_INDEX_{{cookiecutter.private_pypi_name | upper}}_USERNAME: ${{ secrets.PYPI_SERVER_USERNAME }}
14-
UV_INDEX_{{cookiecutter.private_pypi_name | upper}}_PASSWORD: ${{ secrets.PYPI_SERVER_PASSWORD }}
15-
PYPI_SERVER_USERNAME: ${{ secrets.PYPI_SERVER_USERNAME }}
16-
PYPI_SERVER_PASSWORD: ${{ secrets.PYPI_SERVER_PASSWORD }}
13+
UV_INDEX_{{cookiecutter.private_pypi_name | upper}}_USERNAME: ${% raw %}{{ secrets.PYPI_SERVER_USERNAME }}{% endraw %}
14+
UV_INDEX_{{cookiecutter.private_pypi_name | upper}}_PASSWORD: ${% raw %}{{ secrets.PYPI_SERVER_PASSWORD }}{% endraw %}
15+
PYPI_SERVER_USERNAME: ${% raw %}{{ secrets.PYPI_SERVER_USERNAME }}{% endraw %}
16+
PYPI_SERVER_PASSWORD: ${% raw %}{{ secrets.PYPI_SERVER_PASSWORD }}{% endraw %}
1717
{% endif -%}
1818
jobs:
1919
check:
@@ -58,13 +58,13 @@ jobs:
5858
id: build-container
5959
uses: redhat-actions/buildah-build@v2
6060
with:
61-
image: ${{ github.repository }}-test
62-
tags: test-${{ github.sha }}
61+
image: ${% raw %}{{ github.repository }}{% endraw %}-test
62+
tags: test-${% raw %}{{ github.sha }}{% endraw %}
6363
containerfiles: ./container/Containerfile
6464
platforms: linux/amd64,linux/arm64
6565
{% if cookiecutter.use_private_pypi == "true" -%}
6666
build-args: |-
67-
PYPI_SERVER_USERNAME=${{ env.PYPI_SERVER_USERNAME }}
68-
PYPI_SERVER_PASSWORD=${{ env.PYPI_SERVER_PASSWORD }}
67+
PYPI_SERVER_USERNAME=${% raw %}{{ env.PYPI_SERVER_USERNAME }}{% endraw %}
68+
PYPI_SERVER_PASSWORD=${% raw %}{{ env.PYPI_SERVER_PASSWORD }}{% endraw %}
6969
{% endif -%}
7070
{% endif -%}

repo_scaffold/components/github_actions/files/.github/workflows/version-bump.yaml.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ permissions:
2121
pull-requests: write # 用于创建 PR
2222
jobs:
2323
bump-version:
24-
if: ${{ github.event_name == 'workflow_dispatch' || !startsWith(github.event.head_commit.message, 'bump:') }}
24+
if: ${% raw %}{{ github.event_name == 'workflow_dispatch' || !startsWith(github.event.head_commit.message, 'bump:') }}{% endraw %}
2525
runs-on: ubuntu-latest
2626
name: Bump version and create changelog with commitizen
2727
steps:
2828
- name: Check out
2929
uses: actions/checkout@v4
3030
with:
3131
fetch-depth: 0
32-
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
32+
token: ${% raw %}{{ secrets.PERSONAL_ACCESS_TOKEN }}{% endraw %}
3333
- name: Create bump and changelog
3434
uses: commitizen-tools/commitizen-action@master
3535
with:
36-
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
36+
github_token: ${% raw %}{{ secrets.PERSONAL_ACCESS_TOKEN }}{% endraw %}
3737
branch: master
38-
increment: ${{ github.event.inputs.increment || '' }}
38+
increment: ${% raw %}{{ github.event.inputs.increment || '' }}{% endraw %}
3939
no_raise: '21'

repo_scaffold/components/mkdocs/component.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ category: documentation
55
dependencies: []
66
conflicts: []
77
cookiecutter_vars:
8-
use_docs: true
98
use_mkdocs: true
109
files:
1110
- src: mkdocs.yml.j2

0 commit comments

Comments
 (0)