File size: 4,445 Bytes
32e4bbf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
#!/usr/bin/env python3
"""
Quick Start Script for Cloudflare Manager
This script provides the fastest way to:
1. Deploy a Pages project
2. Bind a domain
3. Get nameservers
"""
import sys
from cloudflare_manager import CloudflareManager, CloudflareAccount
def quickstart():
"""Quick start deployment"""
print("""
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Cloudflare Manager - Quick Start β
β Deploy Pages + Bind Domain + Get Nameservers β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
""")
# Configuration
print("\nπ Configuration")
print("="*60)
email = input("Cloudflare Email: ").strip()
token = input("Cloudflare API Token: ").strip()
if not email or not token:
print("β Email and Token are required!")
return
print("\nπ Project Information")
print("="*60)
project_name = input("Pages Project Name: ").strip()
directory = input("Directory to deploy (default: .): ").strip() or "."
domain = input("Domain to bind (optional): ").strip()
if not project_name:
print("β Project name is required!")
return
# Initialize
print("\nπ§ Initializing Cloudflare Manager...")
account = CloudflareAccount(email=email, token=token)
cf = CloudflareManager(account)
# Step 1: Create project
print(f"\nπ Step 1/4: Creating Pages project '{project_name}'...")
project = cf.create_pages_project(project_name, "main")
if not project:
print("β Failed to create project")
return
print(f"β Project created: https://{project.get('subdomain')}")
# Step 2: Deploy
print(f"\nπ¦ Step 2/4: Deploying from '{directory}'...")
deployment = cf.deploy_pages_project(
project_name=project_name,
directory=directory,
branch="main",
commit_message="Quickstart deployment"
)
if not deployment:
print("β Failed to deploy")
return
print(f"β Deployed: {deployment.get('url')}")
# Step 3: Domain (if provided)
zone_id = None
if domain:
print(f"\nπ Step 3/4: Setting up domain '{domain}'...")
# Create zone
zone = cf.create_zone(domain)
if zone:
zone_id = zone.get("id")
nameservers = zone.get("name_servers", [])
print(f"\nπ Nameservers (add these to your domain registrar):")
print("="*60)
for ns in nameservers:
print(f" {ns}")
print("="*60)
# Bind to Pages
result = cf.add_pages_domain(project_name, domain)
if result:
print(f"β Domain bound to Pages project")
if result.get('validation_data'):
val = result['validation_data']
print(f"\nπ DNS Validation Record:")
print(f" Type: {val.get('type')}")
print(f" Name: {val.get('name')}")
print(f" Value: {val.get('value')}")
else:
print("\nβοΈ Step 3/4: Skipping domain setup (no domain provided)")
# Step 4: Summary
print(f"\nβ
Step 4/4: Summary")
print("="*60)
print(f"β Project: {project_name}")
print(f"β URL: {deployment.get('url')}")
if domain:
print(f"β Domain: {domain}")
print(f"\nπ Next steps:")
print(f" 1. Update nameservers at your domain registrar")
print(f" 2. Wait for DNS propagation (5-30 minutes)")
print(f" 3. Visit https://{domain}")
else:
print(f"\nπ Next steps:")
print(f" 1. Visit {deployment.get('url')}")
print(f" 2. (Optional) Add a custom domain later")
print("="*60)
print("\nπ Quickstart completed successfully!")
if __name__ == "__main__":
try:
quickstart()
except KeyboardInterrupt:
print("\n\nβ οΈ Interrupted by user")
sys.exit(0)
except Exception as e:
print(f"\nβ Error: {e}")
sys.exit(1)
|