Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{{code_owner_handle}}
{{code_owner_handle_2}}
@dixonjoel
2 changes: 2 additions & 0 deletions .github/CODEOWNERS_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{code_owner_handle}}
{{code_owner_handle_2}}
26 changes: 25 additions & 1 deletion replace_template_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ def replace_in_file(file_path: Path, variables: Dict[str, str]) -> None:
print(f"Error updating {file_path}: {e}")


def handle_codeowners_file(base_path: Path) -> None:
"""Handle CODEOWNERS file transformation."""
github_path = base_path / ".github"
if not github_path.exists():
return

codeowners_path = github_path / "CODEOWNERS"
codeowners_template_path = github_path / "CODEOWNERS_TEMPLATE"

# Remove existing CODEOWNERS (if it exists)
if codeowners_path.exists():
codeowners_path.unlink()
print(f"Removed: {codeowners_path}")

# Rename CODEOWNERS_TEMPLATE to CODEOWNERS
if codeowners_template_path.exists():
codeowners_template_path.rename(codeowners_path)
print(f"Renamed: {codeowners_template_path} -> {codeowners_path}")


def rename_directories(base_path: Path, variables: Dict[str, str]) -> None:
"""Rename directories that contain template variables."""
# Rename source directories
Expand Down Expand Up @@ -86,7 +106,7 @@ def rename_directories(base_path: Path, variables: Dict[str, str]) -> None:
print(f"Renamed: {old_workflow} -> {new_workflow}")


def main():
def main() -> int:
"""Main function."""
parser = argparse.ArgumentParser(description="Replace template variables")
parser.add_argument("--template-dir", default=".", help="Template directory path")
Expand Down Expand Up @@ -138,6 +158,10 @@ def main():
print("\nRenaming directories...")
rename_directories(output_dir, variables)

# Handle CODEOWNERS file transformation
print("\nHandling CODEOWNERS files...")
handle_codeowners_file(output_dir)

print("\nTemplate replacement complete!")
print(f"Project created in: {output_dir}")
print("\nNext steps:")
Expand Down
Loading