mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-03-11 17:49:25 -05:00
feat(binder): enhance publishing UI with guided versioning and better spacing
- Add comprehensive version type guidance (patch/minor/major/custom) - Improve spacing and line breaks throughout publishing flow - Add helpful explanations for GitHub Pages and release creation - Enhance confirmation dialogs with clear action descriptions - Add contextual prompts explaining what each choice does - Show version transitions (Previous → New) for clarity - Provide skip confirmations for optional deployment steps
This commit is contained in:
83
binder
83
binder
@@ -998,6 +998,19 @@ class BookBinder:
|
||||
"""Enhanced manual publisher with integrated functionality"""
|
||||
self._show_publisher_header()
|
||||
|
||||
# Step 0: Production Publishing Confirmation
|
||||
console.print("[bold red]⚠️ You are about to publish to LIVE PRODUCTION systems.[/bold red]")
|
||||
console.print("[red]This will create public releases and deploy to GitHub Pages.[/red]")
|
||||
console.print("[yellow]Type 'PUBLISH' (all caps) to confirm: [/yellow]", end="")
|
||||
confirmation = input().strip()
|
||||
|
||||
if confirmation != "PUBLISH":
|
||||
console.print("[blue]ℹ️ Publishing cancelled - confirmation not received[/blue]")
|
||||
console.print("[dim]To publish, you must type exactly: PUBLISH[/dim]")
|
||||
return False
|
||||
|
||||
console.print("[green]✅ Production publishing confirmed[/green]")
|
||||
|
||||
# Step 1: Git Status Check
|
||||
if not self._validate_git_status():
|
||||
return False
|
||||
@@ -1028,7 +1041,25 @@ class BookBinder:
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
def _show_publisher_header(self):
|
||||
"""Display the publisher header"""
|
||||
"""Display the publisher header with prominent warning"""
|
||||
# Big red warning box
|
||||
warning = Panel(
|
||||
"[bold red]⚠️ LIVE PUBLISHING WARNING ⚠️[/bold red]\n\n"
|
||||
"[red]This tool publishes to PRODUCTION systems:[/red]\n"
|
||||
"[red]• Creates public GitHub releases[/red]\n"
|
||||
"[red]• Deploys to live GitHub Pages[/red]\n"
|
||||
"[red]• Pushes changes to main branch[/red]\n"
|
||||
"[red]• Updates public documentation[/red]\n\n"
|
||||
"[bold yellow]⚡ USE WITH CAUTION ⚡[/bold yellow]\n"
|
||||
"[dim]Only run when you're ready to publish changes publicly[/dim]",
|
||||
title="[bold red]🚨 PRODUCTION DEPLOYMENT 🚨[/bold red]",
|
||||
border_style="red",
|
||||
padding=(1, 2)
|
||||
)
|
||||
console.print(warning)
|
||||
console.print() # Add space
|
||||
|
||||
# Regular header below warning
|
||||
header = Panel.fit(
|
||||
"[bold blue]📚 MLSysBook Manual Publisher[/bold blue]\n"
|
||||
"[dim]⚡ I build, compress, and publish your book[/dim]",
|
||||
@@ -1060,6 +1091,7 @@ class BookBinder:
|
||||
console.print("[yellow]⚠️ You are not on the main branch[/yellow]")
|
||||
console.print(f"[blue]ℹ️ Current branch: {current_branch}[/blue]")
|
||||
console.print("[blue]ℹ️ Publishing requires being on main branch with latest dev changes[/blue]")
|
||||
console.print()
|
||||
console.print("[yellow]Move to main branch and pull in dev changes? [y/N]: [/yellow]", end="")
|
||||
choice = input().strip().lower()
|
||||
|
||||
@@ -1140,16 +1172,21 @@ class BookBinder:
|
||||
# Get current version
|
||||
current_version = self._get_current_version()
|
||||
console.print(f"[blue]ℹ️ Current version: {current_version}[/blue]")
|
||||
console.print()
|
||||
|
||||
# Suggest release type
|
||||
release_types = ["patch", "minor", "major", "custom"]
|
||||
console.print("\n[white]Select release type:[/white]")
|
||||
for i, rt in enumerate(release_types, 1):
|
||||
console.print(f"[cyan] {i}. {rt}[/cyan]")
|
||||
# Show version type guide
|
||||
console.print("[bold white]📋 Version Type Guide:[/bold white]")
|
||||
console.print("[green] 1. patch[/green] - Bug fixes, typos, small corrections (v1.0.0 → v1.0.1)")
|
||||
console.print("[yellow] 2. minor[/yellow] - New content, features, improvements (v1.0.0 → v1.1.0)")
|
||||
console.print("[red] 3. major[/red] - Breaking changes, major restructuring (v1.0.0 → v2.0.0)")
|
||||
console.print("[blue] 4. custom[/blue] - Specify your own version number")
|
||||
console.print()
|
||||
|
||||
console.print("[white]Select option [1-4] [2]: [/white]", end="")
|
||||
console.print("[white]What type of changes are you publishing?[/white]")
|
||||
console.print("[white]Select option [1-4] [2 for minor]: [/white]", end="")
|
||||
choice = input().strip() or "2"
|
||||
|
||||
release_types = ["patch", "minor", "major", "custom"]
|
||||
try:
|
||||
choice_idx = int(choice) - 1
|
||||
if 0 <= choice_idx < len(release_types):
|
||||
@@ -1161,14 +1198,18 @@ class BookBinder:
|
||||
|
||||
# Calculate new version
|
||||
if release_type == "custom":
|
||||
console.print("[white]Enter version (e.g., v1.0.0): [/white]", end="")
|
||||
console.print()
|
||||
console.print("[blue]ℹ️ Custom version format: vX.Y.Z (e.g., v1.2.3)[/blue]")
|
||||
console.print("[white]Enter your custom version: [/white]", end="")
|
||||
new_version = input().strip()
|
||||
if not new_version.startswith('v'):
|
||||
new_version = f"v{new_version}"
|
||||
else:
|
||||
new_version = self._calculate_next_version(current_version, release_type)
|
||||
|
||||
console.print(f"[blue]ℹ️ New version will be: {new_version}[/blue]")
|
||||
console.print()
|
||||
console.print(f"[bold green]📌 New version will be: {new_version}[/bold green]")
|
||||
console.print(f"[dim] Previous: {current_version} → New: {new_version}[/dim]")
|
||||
|
||||
# Check if version exists
|
||||
if self._version_exists(new_version):
|
||||
@@ -1183,7 +1224,10 @@ class BookBinder:
|
||||
return None
|
||||
|
||||
# Get release description
|
||||
console.print("[white]Release description [Content updates and improvements]: [/white]", end="")
|
||||
console.print()
|
||||
console.print("[bold white]📝 Release Description:[/bold white]")
|
||||
console.print("[dim] This will appear in the GitHub release and help users understand what changed[/dim]")
|
||||
console.print("[white]Enter description [Content updates and improvements]: [/white]", end="")
|
||||
description = input().strip() or "Content updates and improvements"
|
||||
|
||||
return {
|
||||
@@ -1210,6 +1254,15 @@ class BookBinder:
|
||||
table.add_row("Repository:", self._get_repo_info() or "Unknown")
|
||||
|
||||
console.print(table)
|
||||
console.print()
|
||||
|
||||
console.print("[bold white]🚀 This will:[/bold white]")
|
||||
console.print("[green] • Build PDF and HTML versions[/green]")
|
||||
console.print("[green] • Compress PDF for distribution[/green]")
|
||||
console.print("[green] • Create git tag: {version}[/green]".format(version=version_info['version']))
|
||||
console.print("[green] • Deploy to GitHub Pages (optional)[/green]")
|
||||
console.print("[green] • Create GitHub release with PDF (optional)[/green]")
|
||||
console.print()
|
||||
|
||||
console.print("[yellow]Proceed with publishing? [y/N]: [/yellow]", end="")
|
||||
choice = input().strip().lower()
|
||||
@@ -1411,6 +1464,9 @@ class BookBinder:
|
||||
console.print("[green]✅ Git tag created and pushed[/green]")
|
||||
|
||||
# GitHub Pages deployment
|
||||
console.print()
|
||||
console.print("[bold white]🌐 GitHub Pages Deployment:[/bold white]")
|
||||
console.print("[dim] Deploy the website to your public GitHub Pages (recommended)[/dim]")
|
||||
console.print("[yellow]Deploy to GitHub Pages? [y/N]: [/yellow]", end="")
|
||||
choice = input().strip().lower()
|
||||
if choice in ['y', 'yes']:
|
||||
@@ -1419,8 +1475,13 @@ class BookBinder:
|
||||
console.print("[green]✅ Deployed to GitHub Pages[/green]")
|
||||
else:
|
||||
console.print("[yellow]⚠️ GitHub Pages deployment failed[/yellow]")
|
||||
else:
|
||||
console.print("[blue]ℹ️ Skipping GitHub Pages deployment[/blue]")
|
||||
|
||||
# GitHub release creation
|
||||
console.print()
|
||||
console.print("[bold white]📦 GitHub Release Creation:[/bold white]")
|
||||
console.print("[dim] Create a public release with downloadable PDF and AI-generated release notes[/dim]")
|
||||
console.print("[yellow]Create GitHub release? [y/N]: [/yellow]", end="")
|
||||
choice = input().strip().lower()
|
||||
if choice in ['y', 'yes']:
|
||||
@@ -1429,6 +1490,8 @@ class BookBinder:
|
||||
console.print("[green]✅ GitHub release created[/green]")
|
||||
else:
|
||||
console.print("[yellow]⚠️ GitHub release creation failed[/yellow]")
|
||||
else:
|
||||
console.print("[blue]ℹ️ Skipping GitHub release creation[/blue]")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user