Skip to content

Commit e085994

Browse files
committed
feat: add some new utility sessions to the template's noxfile
1 parent e6b631d commit e085994

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

noxfile.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545

4646
TEMPLATE_PYTHON_LOCATIONS: tuple[Path, ...] = (
4747
Path("noxfile.py"),
48+
Path("scripts/*"),
49+
Path("hooks/*")
4850
)
4951

5052
TEMPLATE_CONFIG_AND_DOCS: tuple[Path, ...] = (
@@ -105,6 +107,31 @@ def uv_in_demo(session: Session) -> None:
105107
)
106108

107109

110+
@nox.session(name="in-demo", python=DEFAULT_TEMPLATE_PYTHON_VERSION)
111+
def in_demo(session: Session) -> None:
112+
session.install("cookiecutter", "platformdirs", "loguru", "typer")
113+
session.run(
114+
"python",
115+
"scripts/generate-demo-project.py",
116+
*GENERATE_DEMO_PROJECT_OPTIONS,
117+
)
118+
original_dir: Path = Path.cwd()
119+
session.cd(DEMO_ROOT_FOLDER)
120+
session.run(*session.posargs)
121+
session.cd(original_dir)
122+
123+
124+
@nox.session(name="clear-cache", python=DEFAULT_TEMPLATE_PYTHON_VERSION)
125+
def clear_cache(session: Session) -> None:
126+
"""Clear the cache of generated project demos.
127+
128+
Not commonly used, but sometimes permissions might get messed up if exiting mid-build and such.
129+
"""
130+
session.log("Clearing cache of generated project demos...")
131+
shutil.rmtree(PROJECT_DEMOS_FOLDER, ignore_errors=True)
132+
session.log("Cache cleared.")
133+
134+
108135
@nox.session(python=DEFAULT_TEMPLATE_PYTHON_VERSION)
109136
def lint(session: Session):
110137
"""Lint the template's own Python files and configurations."""

0 commit comments

Comments
 (0)