@@ -57,6 +57,26 @@ def replace_in_file(file_path: Path, variables: Dict[str, str]) -> None:
5757 print (f"Error updating { file_path } : { e } " )
5858
5959
60+ def handle_codeowners_file (base_path : Path ) -> None :
61+ """Handle CODEOWNERS file transformation."""
62+ github_path = base_path / ".github"
63+ if not github_path .exists ():
64+ return
65+
66+ codeowners_path = github_path / "CODEOWNERS"
67+ codeowners_template_path = github_path / "CODEOWNERS_TEMPLATE"
68+
69+ # Remove existing CODEOWNERS (if it exists)
70+ if codeowners_path .exists ():
71+ codeowners_path .unlink ()
72+ print (f"Removed: { codeowners_path } " )
73+
74+ # Rename CODEOWNERS_TEMPLATE to CODEOWNERS
75+ if codeowners_template_path .exists ():
76+ codeowners_template_path .rename (codeowners_path )
77+ print (f"Renamed: { codeowners_template_path } -> { codeowners_path } " )
78+
79+
6080def rename_directories (base_path : Path , variables : Dict [str , str ]) -> None :
6181 """Rename directories that contain template variables."""
6282 # Rename source directories
@@ -86,7 +106,7 @@ def rename_directories(base_path: Path, variables: Dict[str, str]) -> None:
86106 print (f"Renamed: { old_workflow } -> { new_workflow } " )
87107
88108
89- def main ():
109+ def main () -> int :
90110 """Main function."""
91111 parser = argparse .ArgumentParser (description = "Replace template variables" )
92112 parser .add_argument ("--template-dir" , default = "." , help = "Template directory path" )
@@ -138,6 +158,10 @@ def main():
138158 print ("\n Renaming directories..." )
139159 rename_directories (output_dir , variables )
140160
161+ # Handle CODEOWNERS file transformation
162+ print ("\n Handling CODEOWNERS files..." )
163+ handle_codeowners_file (output_dir )
164+
141165 print ("\n Template replacement complete!" )
142166 print (f"Project created in: { output_dir } " )
143167 print ("\n Next steps:" )
0 commit comments