#!/usr/bin/env python3
"""Create the same synthetic GitLab project through each dev server's CLI.
Run the server first with T3CODE_DEV_SEED=0 vp run dev.
Usage: python3 seed.py CHECKOUT NEW_PROJECT_DIRECTORY
"""
import pathlib
import subprocess
import sys
checkout, project = map(lambda p: pathlib.Path(p).resolve(), sys.argv[1:])
project.mkdir(parents=True)
def run(args, cwd=project):
    subprocess.run(args, cwd=cwd, check=True)
run(['git', 'init', '--quiet', '--initial-branch=main'])
run(['git', 'remote', 'add', 'origin', 'https://gitlab.com/gitlab-org/cli.git'])
run(['git', '-c', 'user.name=Scenario', '-c', 'user.email=scenario@example.invalid', 'commit', '--allow-empty', '-qm', 'Initial'])
run(['node', 'apps/server/src/bin.ts', 'project', 'add', str(project), '--title', 'GitLab CLI', '--base-dir', '.t3'], cwd=checkout)
