Your music, beautifully tracked. All yours. (coming soon) teal.fm
teal-fm atproto
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117use anyhow::Result;use colored::*;
use crate::config::TealConfig;use crate::DevCommands;
pub async fn run(cmd: DevCommands, config: &TealConfig) -> Result<()> { match cmd { DevCommands::Setup { skip_docker, skip_db, } => setup_dev_environment(skip_docker, skip_db, config).await, DevCommands::Clean { all } => clean_dev_artifacts(all).await, DevCommands::Dev { port, watch } => run_dev_server(port, watch, config).await, DevCommands::Seed { count, data_type } => generate_seed_data(count, data_type, config).await, }}
async fn setup_dev_environment( skip_docker: bool, skip_db: bool, config: &TealConfig,) -> Result<()> { println!("{} Setting up development environment...", "🛠️".blue()); println!();
if !skip_docker { println!("{} Docker Setup:", "🐳".blue()); println!(" {} Checking Docker...", "•".bold());
// TODO: Check if Docker is installed and running println!(" {} Docker check not implemented", "⚠️".yellow()); println!(" {} Manually ensure Docker is running", "💡".blue()); println!(); }
if !skip_db { println!("{} Database Setup:", "🗄️".blue()); println!(" {} Database URL: {}", "•".bold(), mask_db_url(&config.database.url));
// TODO: Run database initialization and migrations println!(" {} Database setup not implemented", "⚠️".yellow()); println!(" {} Run: teal database init", "💡".blue()); println!(" {} Run: teal database migrate", "💡".blue()); println!(); }
println!("{} Keys Setup:", "🔐".blue()); let key_path = config.get_key_path(&config.crypto.default_key_name); if key_path.exists() { println!(" {} Default key already exists", "✅".green()); } else { println!(" {} Generating default key...", "•".bold()); // TODO: Auto-generate key println!(" {} Run: teal crypto gen-key", "💡".blue()); } println!();
println!("{} Development environment setup complete!", "✅".green()); println!(); println!("{} Next steps:", "💡".yellow()); println!(" 1. teal crypto gen-key --name dev"); println!(" 2. teal database init"); println!(" 3. teal dev dev --watch");
Ok(())}
async fn clean_dev_artifacts(all: bool) -> Result<()> { println!("{} Cleaning development artifacts...", "🧹".blue()); println!();
let mut cleaned_items = Vec::new();
// Clean logs if let Ok(entries) = std::fs::read_dir("logs") { let mut log_count = 0; for entry in entries.flatten() { if entry.path().extension().map_or(false, |ext| ext == "log") { // TODO: Actually delete log files log_count += 1; } } if log_count > 0 { cleaned_items.push(format!("{} log files", log_count)); } }
// Clean temporary files if let Ok(entries) = std::fs::read_dir(".") { let mut temp_count = 0; for entry in entries.flatten() { let path = entry.path(); if let Some(name) = path.file_name().and_then(|n| n.to_str()) { if name.starts_with("tmp_") || name.ends_with(".tmp") { temp_count += 1; } } } if temp_count > 0 { cleaned_items.push(format!("{} temporary files", temp_count)); } }
if all { // Clean build artifacts cleaned_items.push("build artifacts".to_string()); println!(" {} Would clean: target/ directory", "•".bold());
// Clean Docker artifacts cleaned_items.push("Docker artifacts".to_string()); println!(" {} Would clean: Docker images and containers", "•".bold()); }
if cleaned_items.is_empty() { println!("{} No artifacts to clean", "ℹ️".blue