Skip to content

Commit 1ffdec7

Browse files
authored
⚙️ [GH-84] Update cookiecutter options to use private vars (#88)
* chore: make slug and slug db private cc options [#84] * chore: lock update [#84] * fix: lint [#84] * docs: add common section [#84]
1 parent 8351927 commit 1ffdec7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+86
-41
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
exclude: "{{ cookiecutter.project_slug }}"
1+
exclude: "{{ cookiecutter.__project_slug }}"
22
default_language_version:
33
python: python3
44

README.md

Lines changed: 2 additions & 3 deletions

cookiecutter.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"project_name": "FastAPI Backend",
3-
"project_slug": "{{ cookiecutter.project_name|lower|replace(' ', '-') }}",
4-
"project_slug_db": "{{ cookiecutter.project_name|lower|replace(' ', '') }}",
3+
"__project_slug": "{{ cookiecutter.project_name|lower|replace(' ', '-') }}",
4+
"__project_slug_db": "{{ cookiecutter.project_name|lower|replace(' ', '') }}",
55

66
"author_email": "change.me@gmail.com",
77

docs/source/getting_started/quickstart.rst

Lines changed: 3 additions & 4 deletions

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Lines changed: 46 additions & 0 deletions

hooks/pre_gen_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
MODULE_REGEX = r"^[-a-zA-Z][-a-zA-Z0-9]+$"
55

6-
module_name = "{{ cookiecutter.project_slug}}"
6+
module_name = "{{ cookiecutter.__project_slug}}"
77
python_version = "{{ cookiecutter.py_version}}"
88

99

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cookiecutter-fastapi-backend"
3-
version = "2.5.0"
3+
version = "2.5.1"
44
description = "Cookiecutter template to build and deploy fastapi backends..batteries included"
55
authors = [{ name = "nickatnight", email = "nialexanderke@proton.me" }]
66
requires-python = ">=3.9"

tests/test_bake_project.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
def context() -> Dict:
4343
return {
4444
"project_name": "Goblet of Fire",
45-
"project_slug": "goblet-of-fire",
46-
"project_slug_db": "gobletoffire",
45+
"__project_slug": "goblet-of-fire",
46+
"__project_slug_db": "gobletoffire",
4747
"author_email": "harry@hogwarts.com",
4848
"py_version": "3.10",
4949
"db_container_name": "db",
@@ -85,7 +85,7 @@ def test_project_generation(cookies, context, context_override) -> None:
8585
result = cookies.bake(extra_context={**context, **context_override})
8686
assert result.exit_code == 0
8787
assert result.exception is None
88-
assert result.project_path.name == context["project_slug"]
88+
assert result.project_path.name == context["__project_slug"]
8989
assert result.project_path.is_dir()
9090

9191
paths = build_files_list(str(result.project_path))
@@ -96,7 +96,7 @@ def test_project_generation(cookies, context, context_override) -> None:
9696
@pytest.mark.parametrize("slug", ["project slug", "Project_Slug"])
9797
def test_invalid_slug(cookies, context, slug):
9898
"""Invalid slug should fail pre-generation hook."""
99-
context.update({"project_slug": slug})
99+
context.update({"__project_slug": slug})
100100

101101
result = cookies.bake(extra_context=context)
102102

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)