python <<EOF
import morph
import os
import shutil
import subprocess
morph_data_installed_dir = os.path.dirname(morph.__file__)
starter_template_dir = os.path.join(
    morph_data_installed_dir, "include", "starter_template"
)
def migrate_frontend():
    def copy_starter_template_file(path: str):
        src = os.path.join(starter_template_dir, path)
        dst = os.path.join(os.getcwd(), path)
        os.makedirs(os.path.dirname(dst), exist_ok=True)
        shutil.copy(src, dst)
    # Copy files
    copy_starter_template_file("vite.config.ts")
    copy_starter_template_file("tsconfig.json")
    copy_starter_template_file("package.json")
    copy_starter_template_file("components.json")
    copy_starter_template_file("src/pages/_app.tsx")
    copy_starter_template_file("src/pages/404.tsx")
    copy_starter_template_file("src/pages/index.css")
    copy_starter_template_file("src/pages/_lib/utils.ts")
    copy_starter_template_file("src/pages/_components/table-of-contents.tsx")
    copy_starter_template_file("src/pages/_components/header.tsx")
    # Init components
    subprocess.run(
        [
            "npx",
            "shadcn@latest",
            "add",
            "--yes",
            "https://morph-components.vercel.app/r/morph-components.json",
        ],
    )
    subprocess.run(
        [
            "npm",
            "install",
        ],
    )
if __name__ == "__main__":
    migrate_frontend()
EOF