Skip to content

Commit 0a83f2f

Browse files
committed
[FIX] update package selection feature, enhance template testcases
1 parent c6a178e commit 0a83f2f

File tree

21 files changed

+884
-399
lines changed

21 files changed

+884
-399
lines changed

CHANGELOG.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
11
# Changelog
22

3+
## v1.1.0 (2025-01-15)
4+
5+
### Features
6+
7+
- **Package Manager Support**: Add comprehensive support for multiple Python package managers
8+
- Support for UV (default), PDM, Poetry, and PIP package managers
9+
- Interactive package manager selection in `fastkit init` and `fastkit startdemo` commands
10+
- `--package-manager` CLI option for non-interactive usage
11+
- Automatic generation of appropriate dependency files (`pyproject.toml` for UV/PDM/Poetry, `requirements.txt` for PIP)
12+
- PEP 621 compliant project metadata for modern package managers
13+
14+
- **Automated Template Testing System**: Revolutionary zero-configuration template testing
15+
- Dynamic template discovery - new templates are automatically tested
16+
- Comprehensive end-to-end testing with actual project creation
17+
- Multi-package manager compatibility testing
18+
- Virtual environment creation and dependency installation validation
19+
- Project structure and FastAPI integration verification
20+
- Parameterized testing with pytest for scalable test execution
21+
22+
### Improvements
23+
24+
- **Enhanced CLI Experience**: Package manager selection with interactive prompts and helpful descriptions
25+
- **Better Template Quality Assurance**: Multi-layer quality assurance with static inspection and dynamic testing
26+
- **Improved Developer Experience**: Zero boilerplate test configuration for template contributors
27+
- **Cross-Platform Compatibility**: Enhanced support for different package manager workflows
28+
29+
### Documentation
30+
31+
- Updated all user guides with package manager selection examples
32+
- Enhanced CLI reference with comprehensive package manager documentation
33+
- Updated contributing guidelines with new automated testing system
34+
- Improved template creation guide with zero-configuration testing instructions
35+
- Enhanced template quality assurance documentation
36+
37+
### Technical
38+
39+
- Implemented BasePackageManager abstract class with concrete implementations
40+
- Added PackageManagerFactory for dynamic package manager instantiation
41+
- Enhanced project metadata injection for all package managers
42+
- Improved test infrastructure with dynamic template discovery
43+
- Updated CI/CD pipelines for multi-package manager testing
44+
45+
### Breaking Changes
46+
47+
- **Default Package Manager**: Changed from PIP to UV for better performance
48+
- **CLI Prompts**: Added package manager selection step in interactive commands
49+
350
## v1.0.2 (2025-07-02)
451

552
### Features

src/fastapi_fastkit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.0.2"
1+
__version__ = "1.1.0"
22

33
import os
44

src/fastapi_fastkit/backend/main.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,22 +314,34 @@ def install_dependencies(project_dir: str, venv_path: str) -> None:
314314

315315

316316
def generate_dependency_file_with_manager(
317-
project_dir: str, dependencies: List[str], manager_type: str = "pip"
317+
project_dir: str,
318+
dependencies: List[str],
319+
manager_type: str = "pip",
320+
project_name: str = "",
321+
author: str = "",
322+
author_email: str = "",
323+
description: str = "",
318324
) -> None:
319325
"""
320326
Generate a dependency file using the specified package manager.
321327
322328
:param project_dir: Path to the project directory
323329
:param dependencies: List of dependency specifications
324330
:param manager_type: Type of package manager to use
331+
:param project_name: Name of the project
332+
:param author: Author name
333+
:param author_email: Author email
334+
:param description: Project description
325335
:return: None
326336
:raises: BackendExceptions if dependency file generation fails
327337
"""
328338
try:
329339
package_manager = PackageManagerFactory.create_manager(
330340
manager_type, project_dir, auto_detect=True
331341
)
332-
package_manager.generate_dependency_file(dependencies)
342+
package_manager.generate_dependency_file(
343+
dependencies, project_name, author, author_email, description
344+
)
333345
except Exception as e:
334346
debug_log(f"Error generating dependency file with {manager_type}: {e}", "error")
335347
raise BackendExceptions(f"Failed to generate dependency file: {str(e)}")

src/fastapi_fastkit/backend/package_managers/base.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,22 @@ def install_dependencies(self, venv_path: str) -> None:
6565
pass
6666

6767
@abstractmethod
68-
def generate_dependency_file(self, dependencies: List[str]) -> None:
68+
def generate_dependency_file(
69+
self,
70+
dependencies: List[str],
71+
project_name: str = "",
72+
author: str = "",
73+
author_email: str = "",
74+
description: str = "",
75+
) -> None:
6976
"""
70-
Generate a dependency file with the given dependencies.
77+
Generate a dependency file with the given dependencies and metadata.
7178
7279
:param dependencies: List of dependency specifications
80+
:param project_name: Name of the project
81+
:param author: Author name
82+
:param author_email: Author email
83+
:param description: Project description
7384
"""
7485
pass
7586

src/fastapi_fastkit/backend/package_managers/pdm_manager.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,22 @@ def install_dependencies(self, venv_path: str) -> None:
120120
f"Failed to install dependencies with PDM: {str(e)}"
121121
)
122122

123-
def generate_dependency_file(self, dependencies: List[str]) -> None:
123+
def generate_dependency_file(
124+
self,
125+
dependencies: List[str],
126+
project_name: str = "",
127+
author: str = "",
128+
author_email: str = "",
129+
description: str = "",
130+
) -> None:
124131
"""
125-
Generate a pyproject.toml file with the given dependencies.
132+
Generate a pyproject.toml file with the given dependencies and metadata.
126133
127134
:param dependencies: List of dependency specifications
135+
:param project_name: Name of the project
136+
:param author: Author name
137+
:param author_email: Author email
138+
:param description: Project description
128139
"""
129140
pyproject_path = self.get_dependency_file_path()
130141

@@ -137,11 +148,11 @@ def generate_dependency_file(self, dependencies: List[str]) -> None:
137148

138149
# Create basic pyproject.toml content as string
139150
pyproject_content = f"""[project]
140-
name = ""
151+
name = "{project_name or 'fastapi-project'}"
141152
version = "0.1.0"
142-
description = ""
153+
description = "{description or 'A FastAPI project'}"
143154
authors = [
144-
{{name = "", email = ""}},
155+
{{name = "{author or 'Author'}", email = "{author_email or '[email protected]'}"}},
145156
]
146157
dependencies = {deps_toml}
147158
requires-python = ">=3.8"
@@ -152,6 +163,9 @@ def generate_dependency_file(self, dependencies: List[str]) -> None:
152163
requires = ["pdm-backend"]
153164
build-backend = "pdm.backend"
154165
166+
[tool.hatch.build.targets.wheel]
167+
packages = ["src"]
168+
155169
[tool.pdm]
156170
"""
157171

@@ -242,6 +256,9 @@ def initialize_project(
242256
requires = ["pdm-backend"]
243257
build-backend = "pdm.backend"
244258
259+
[tool.hatch.build.targets.wheel]
260+
packages = ["src"]
261+
245262
[tool.pdm]
246263
"""
247264

src/fastapi_fastkit/backend/package_managers/pip_manager.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,22 @@ def install_dependencies(self, venv_path: str) -> None:
129129
handle_exception(e, f"Error during dependency installation: {str(e)}")
130130
raise BackendExceptions(f"Failed to install dependencies: {str(e)}")
131131

132-
def generate_dependency_file(self, dependencies: List[str]) -> None:
132+
def generate_dependency_file(
133+
self,
134+
dependencies: List[str],
135+
project_name: str = "",
136+
author: str = "",
137+
author_email: str = "",
138+
description: str = "",
139+
) -> None:
133140
"""
134141
Generate a requirements.txt file with the given dependencies.
135142
136143
:param dependencies: List of dependency specifications
144+
:param project_name: Name of the project (not used for pip)
145+
:param author: Author name (not used for pip)
146+
:param author_email: Author email (not used for pip)
147+
:param description: Project description (not used for pip)
137148
"""
138149
requirements_path = self.get_dependency_file_path()
139150

src/fastapi_fastkit/backend/package_managers/poetry_manager.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,22 @@ def install_dependencies(self, venv_path: str) -> None:
158158
f"Failed to install dependencies with Poetry: {str(e)}"
159159
)
160160

161-
def generate_dependency_file(self, dependencies: List[str]) -> None:
161+
def generate_dependency_file(
162+
self,
163+
dependencies: List[str],
164+
project_name: str = "",
165+
author: str = "",
166+
author_email: str = "",
167+
description: str = "",
168+
) -> None:
162169
"""
163-
Generate a pyproject.toml file with the given dependencies.
170+
Generate a pyproject.toml file with the given dependencies and metadata.
164171
165172
:param dependencies: List of dependency specifications
173+
:param project_name: Name of the project
174+
:param author: Author name
175+
:param author_email: Author email
176+
:param description: Project description
166177
"""
167178
pyproject_path = self.get_dependency_file_path()
168179

@@ -179,12 +190,13 @@ def generate_dependency_file(self, dependencies: List[str]) -> None:
179190

180191
# Create basic pyproject.toml content for Poetry
181192
pyproject_content = f"""[tool.poetry]
182-
name = ""
193+
name = "{project_name or 'fastapi-project'}"
183194
version = "0.1.0"
184-
description = ""
185-
authors = ["Author <[email protected]>"]
195+
description = "{description or 'A FastAPI project'}"
196+
authors = ["{author or 'Author'} <{author_email or '[email protected]'}>"]
186197
readme = "README.md"
187198
license = "MIT"
199+
packages = [{{include = "src"}}]
188200
189201
[tool.poetry.dependencies]
190202
python = "^3.8"

src/fastapi_fastkit/backend/package_managers/uv_manager.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,22 @@ def install_dependencies(self, venv_path: str) -> None:
117117
handle_exception(e, f"Error during dependency installation: {str(e)}")
118118
raise BackendExceptions(f"Failed to install dependencies with UV: {str(e)}")
119119

120-
def generate_dependency_file(self, dependencies: List[str]) -> None:
120+
def generate_dependency_file(
121+
self,
122+
dependencies: List[str],
123+
project_name: str = "",
124+
author: str = "",
125+
author_email: str = "",
126+
description: str = "",
127+
) -> None:
121128
"""
122-
Generate a pyproject.toml file with the given dependencies.
129+
Generate a pyproject.toml file with the given dependencies and metadata.
123130
124131
:param dependencies: List of dependency specifications
132+
:param project_name: Name of the project
133+
:param author: Author name
134+
:param author_email: Author email
135+
:param description: Project description
125136
"""
126137
pyproject_path = self.get_dependency_file_path()
127138

@@ -134,11 +145,11 @@ def generate_dependency_file(self, dependencies: List[str]) -> None:
134145

135146
# Create basic pyproject.toml content for UV
136147
pyproject_content = f"""[project]
137-
name = ""
148+
name = "{project_name or 'fastapi-project'}"
138149
version = "0.1.0"
139-
description = ""
150+
description = "{description or 'A FastAPI project'}"
140151
authors = [
141-
{{name = "", email = ""}},
152+
{{name = "{author or 'Author'}", email = "{author_email or '[email protected]'}"}},
142153
]
143154
dependencies = {deps_toml}
144155
requires-python = ">=3.8"
@@ -149,6 +160,9 @@ def generate_dependency_file(self, dependencies: List[str]) -> None:
149160
requires = ["hatchling"]
150161
build-backend = "hatchling.build"
151162
163+
[tool.hatch.build.targets.wheel]
164+
packages = ["src"]
165+
152166
[tool.uv]
153167
dev-dependencies = []
154168
"""
@@ -240,6 +254,9 @@ def initialize_project(
240254
requires = ["hatchling"]
241255
build-backend = "hatchling.build"
242256
257+
[tool.hatch.build.targets.wheel]
258+
packages = ["src"]
259+
243260
[tool.uv]
244261
dev-dependencies = []
245262
"""

0 commit comments

Comments
 (0)