4141 * ("--demo-name" , DEFAULT_DEMO_NAME ),
4242)
4343
44- SYNC_UV_WITH_DEMO_SCRIPT : Path = SCRIPTS_FOLDER / "sync-uv-with-demo.py"
45- SYNC_UV_WITH_DEMO_OPTIONS : tuple [str , ...] = (
46- * ("--template-folder" , TEMPLATE_FOLDER ),
47- * ("--demos-cache-folder" , PROJECT_DEMOS_FOLDER ),
48- * ("--demo-name" , DEFAULT_DEMO_NAME ),
49- )
44+
45+ MATCH_GENERATED_PRECOMMIT_SCRIPT : Path = SCRIPTS_FOLDER / "match-generated-precommit.py"
46+ MATCH_GENERATED_PRECOMMIT_OPTIONS : tuple [str , ...] = GENERATE_DEMO_PROJECT_OPTIONS
5047
5148
5249@nox .session (name = "generate-demo-project" , python = DEFAULT_TEMPLATE_PYTHON_VERSION )
5350def generate_demo_project (session : Session ) -> None :
5451 """Generates a project demo using the cookiecutter-robust-python template."""
5552 session .install ("cookiecutter" , "platformdirs" , "loguru" , "typer" )
56- session .run (
57- "python" ,
58- GENERATE_DEMO_PROJECT_SCRIPT ,
59- * GENERATE_DEMO_PROJECT_OPTIONS ,
60- * session .posargs
61- )
62-
63-
64- @nox .session (name = "sync-uv-with-demo" , python = DEFAULT_TEMPLATE_PYTHON_VERSION )
65- def sync_uv_with_demo (session : Session ) -> None :
66- """Syncs the uv environment with the current demo project."""
67- session .install ("cookiecutter" , "platformdirs" , "loguru" , "typer" )
68- session .run (
69- "python" ,
70- SYNC_UV_WITH_DEMO_SCRIPT ,
71- * SYNC_UV_WITH_DEMO_OPTIONS ,
72- )
73-
74-
75- @nox .session (name = "uv-in-demo" , python = DEFAULT_TEMPLATE_PYTHON_VERSION )
76- def uv_in_demo (session : Session ) -> None :
77- """Runs a uv command in a new project demo project then syncs with it."""
78- session .install ("cookiecutter" , "platformdirs" , "loguru" , "typer" )
79- session .run (
80- "python" ,
81- GENERATE_DEMO_PROJECT_SCRIPT ,
82- * GENERATE_DEMO_PROJECT_OPTIONS ,
83- )
84- original_dir : Path = Path .cwd ()
85- session .cd (DEMO_ROOT_FOLDER )
86- session .run ("uv" , * session .posargs )
87- session .cd (original_dir )
88- session .run (
89- SYNC_UV_WITH_DEMO_SCRIPT ,
90- * SYNC_UV_WITH_DEMO_OPTIONS ,
91- external = True ,
92- )
93-
94-
95- @nox .session (name = "in-demo" , python = DEFAULT_TEMPLATE_PYTHON_VERSION )
96- def in_demo (session : Session ) -> None :
97- """Generates a project demo and run a uv command in it."""
98- session .install ("cookiecutter" , "platformdirs" , "loguru" , "typer" )
99- session .run (
100- "python" ,
101- GENERATE_DEMO_PROJECT_SCRIPT ,
102- * GENERATE_DEMO_PROJECT_OPTIONS ,
103- )
104- original_dir : Path = Path .cwd ()
105- session .cd (DEMO_ROOT_FOLDER )
106- session .run ("python" , DEMO_ROOT_FOLDER / "scripts" / "setup-git.py" , DEMO_ROOT_FOLDER )
107- session .run ("git" , "checkout" , "." )
108- session .run (* session .posargs )
109- session .cd (original_dir )
53+ session .run ("python" , GENERATE_DEMO_PROJECT_SCRIPT , * GENERATE_DEMO_PROJECT_OPTIONS , * session .posargs )
11054
11155
11256@nox .session (name = "clear-cache" , python = DEFAULT_TEMPLATE_PYTHON_VERSION )
@@ -133,19 +77,12 @@ def lint(session: Session):
13377 session .run ("ruff" , "check" , "--verbose" , "--fix" )
13478
13579
136- @nox .session (python = DEFAULT_TEMPLATE_PYTHON_VERSION , name = "lint -generated-project " , tags = [])
137- def lint_generated_project (session : Session ):
80+ @nox .session (python = DEFAULT_TEMPLATE_PYTHON_VERSION , name = "match -generated-precommit " , tags = [])
81+ def match_generated_precommit (session : Session ):
13882 """Lint the generated project's Python files and configurations."""
13983 session .log ("Installing linting dependencies for the generated project..." )
14084 session .install ("-e" , "." , "--group" , "dev" , "--group" , "lint" )
141- session ._runner .posargs = ["nox" , "-t" , "lint" , "format" ]
142- in_demo (session )
143- original_dir : Path = Path .cwd ()
144- session .chdir (DEMO_ROOT_FOLDER )
145- session .run ("git" , "commit" , "-a" , "-m" , "meta: lint-generated-project" , "--no-verify" )
146- session .chdir (original_dir )
147-
148- session .run ("retrocookie" , DEMO_ROOT_FOLDER , "HEAD" )
85+ session .run ("python" , MATCH_GENERATED_PRECOMMIT_SCRIPT , * MATCH_GENERATED_PRECOMMIT_OPTIONS , * session .posargs )
14986
15087
15188@nox .session (python = DEFAULT_TEMPLATE_PYTHON_VERSION )
0 commit comments