1- """Module used to sync the poetry .lock file with one generated using a demo project."""
1+ """Module used to sync the uv .lock file with one generated using a demo project."""
22
33import shutil
44import sys
5+ from functools import partial
56from pathlib import Path
67
7- import click
8+ import typer
9+
10+ from typer .models import OptionInfo
811
912from loguru import logger
1013
1114
12- FOLDER_TYPE : click .Path = click .Path (dir_okay = True , file_okay = False , resolve_path = True , path_type = Path )
15+ FolderOption : partial [OptionInfo ] = partial (
16+ typer .Option , dir_okay = True , file_okay = False , resolve_path = True , path_type = Path
17+ )
1318
1419
15- def sync_poetry_with_demo (template_folder : Path , demos_cache_folder : Path , demo_name : str ) -> None :
20+ def sync_uv_with_demo (template_folder : Path , demos_cache_folder : Path , demo_name : str ) -> None :
1621 demo_root : Path = demos_cache_folder / demo_name
17- demo_poetry_lock_path : Path = _find_poetry_lock_path (demo_root )
18- output_poetry_lock_path : Path = _find_poetry_lock_path (template_folder )
22+ demo_uv_lock_path : Path = _find_uv_lock_path (demo_root )
23+ output_uv_lock_path : Path = _find_uv_lock_path (template_folder )
1924
20- _copy_poetry_lock_from_demo (
21- demo_poetry_lock_path = demo_poetry_lock_path , output_poetry_lock_path = output_poetry_lock_path
25+ _copy_uv_lock_from_demo (
26+ demo_uv_lock_path = demo_uv_lock_path , output_uv_lock_path = output_uv_lock_path
2227 )
23- logger .info (f"Copied demo from { demo_poetry_lock_path = } to { output_poetry_lock_path = } ." )
28+ logger .info (f"Copied demo from { demo_uv_lock_path = } to { output_uv_lock_path = } ." )
29+
2430
2531
26- def _copy_poetry_lock_from_demo ( demo_poetry_lock_path : Path , output_poetry_lock_path : Path ) -> None :
27- """Copies over the poetry .lock file from the provided demo project root."""
32+ def _copy_uv_lock_from_demo ( demo_uv_lock_path : Path , output_uv_lock_path : Path ) -> None :
33+ """Copies over the uv .lock file from the provided demo project root."""
2834 shutil .copy (
29- src = demo_poetry_lock_path ,
30- dst = output_poetry_lock_path ,
35+ src = demo_uv_lock_path ,
36+ dst = output_uv_lock_path ,
3137 )
3238
3339
34- def _find_poetry_lock_path (search_root : Path ) -> Path :
35- for path in search_root .rglob ("poetry .lock" ):
40+ def _find_uv_lock_path (search_root : Path ) -> Path :
41+ for path in search_root .rglob ("uv .lock" ):
3642 return path
37- raise FileNotFoundError (f"Failed to find a poetry.lock within the provided search path: { search_root = } " )
43+ raise FileNotFoundError (f"Failed to find a uv.lock within the provided search path: { search_root = } " )
44+
45+
46+ cli : typer .Typer = typer .Typer ()
3847
3948
40- @click .command ()
41- @click .option ("--template-folder" , "-t" , required = True , type = FOLDER_TYPE )
42- @click .option ("--demos-cache-folder" , "-c" , required = True , type = FOLDER_TYPE )
43- @click .option ("--demo-name" , "-d" , required = True , type = str )
44- def main (template_folder : Path , demos_cache_folder : Path , demo_name : str ) -> None :
45- """Updates the poetry.lock file."""
49+ @cli .callback (invoke_without_command = True )
50+ def main (
51+ template_folder : Annotated [Path , FolderOption ("--template-folder" , "-t" , exist = True )],
52+ demos_cache_folder : Annotated [Path , FolderOption ("--demos-cache-folder" , "-c" , exist = True )],
53+ demo_name : Annotated [str , typer .Option ("--demo-name" , "-d" )]
54+ ) -> None :
55+ """Updates the uv.lock file."""
4656 try :
47- sync_poetry_with_demo (
57+ sync_uv_with_demo (
4858 template_folder = template_folder , demos_cache_folder = demos_cache_folder , demo_name = demo_name
4959 )
5060 except Exception as error :
@@ -53,4 +63,4 @@ def main(template_folder: Path, demos_cache_folder: Path, demo_name: str) -> Non
5363
5464
5565if __name__ == "__main__" :
56- main ( prog_name = "prepare-github-release" )
66+ cli ( )
0 commit comments