|
|
|
|
|
""" |
|
|
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 β |
|
|
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
|
|
""") |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
print("\nπ§ Initializing Cloudflare Manager...") |
|
|
account = CloudflareAccount(email=email, token=token) |
|
|
cf = CloudflareManager(account) |
|
|
|
|
|
|
|
|
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')}") |
|
|
|
|
|
|
|
|
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')}") |
|
|
|
|
|
|
|
|
zone_id = None |
|
|
if domain: |
|
|
print(f"\nπ Step 3/4: Setting up domain '{domain}'...") |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
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)") |
|
|
|
|
|
|
|
|
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) |
|
|
|