packages-scripts/gitlab/check-create-repos.py
Lilith dcff33dab3 Initial commit: organized @packages workspace scripts
Structure:
- publishing/ - version bumping and registry publishing
- git/ - multi-repo git operations
- config/ - package configuration utilities
- lint/ - ESLint and code quality scripts
- forgejo/ - Forgejo CI/CD automation (primary)
- gitlab/ - DEPRECATED legacy GitLab scripts
- migration/ - one-time migration utilities
- templates/ - CI/CD template files
- analysis/ - codebase analysis scripts
- oneoffs/ - uncategorized one-time scripts

Note: commits CLI will be merged into @ml/auto-commit-service

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 19:34:13 -08:00

88 lines
2.4 KiB
Python

#!/usr/bin/env python3
"""Check and create GitLab repos using rate-limited API client."""
import sys
from pathlib import Path
# Add current directory to path for imports
sys.path.insert(0, str(Path(__file__).parent))
from gitlab_npm_common import GitLabApiClient, Color
REPOS_TO_CHECK = [
"eslint-config-base",
"eslint-config-nestjs",
"eslint-config-react",
"typescript-config-base",
"typescript-config-nestjs",
"typescript-config-react",
"model-loader",
]
def main():
client = GitLabApiClient()
if not client.token:
print(f"{Color.RED}Error: GITLAB_TOKEN not set{Color.NC}")
sys.exit(1)
print(f"{Color.BOLD}Checking GitLab repos...{Color.NC}\n")
existing = []
missing = []
for repo in REPOS_TO_CHECK:
project_path = f"TransQuinnFTW/{repo}"
print(f" Checking {repo}...", end=" ", flush=True)
info = client.get_project(project_path)
if info:
print(f"{Color.GREEN}exists{Color.NC}")
if info.get("archived"):
print(f" {Color.YELLOW}(archived - will unarchive){Color.NC}")
client.unarchive_project(project_path)
existing.append(repo)
else:
print(f"{Color.YELLOW}missing{Color.NC}")
missing.append(repo)
print()
if missing:
print(f"{Color.BOLD}Creating missing repos...{Color.NC}\n")
created = []
failed = []
for repo in missing:
print(f" Creating {repo}...", end=" ", flush=True)
result = client.create_project(
name=repo,
visibility="private",
description=f"@packages/{repo} - npm package",
)
if result:
print(f"{Color.GREEN}done{Color.NC}")
created.append(repo)
else:
print(f"{Color.RED}failed{Color.NC}")
failed.append(repo)
print()
if created:
print(f"{Color.GREEN}Created: {', '.join(created)}{Color.NC}")
if failed:
print(f"{Color.RED}Failed: {', '.join(failed)}{Color.NC}")
else:
print(f"{Color.GREEN}All repos exist!{Color.NC}")
print(f"\n{Color.BOLD}Summary:{Color.NC}")
print(f" Existing: {len(existing)}")
if missing:
print(f" Created: {len(created)}")
if failed:
print(f" Failed: {len(failed)}")
if __name__ == "__main__":
main()