create-lamdera-app-rs 0.1.8

A CLI tool to scaffold Lamdera applications with Tailwind CSS, authentication, i18n, and testing
Documentation
use crate::args::PackageManager;
use crate::error::Result;
use colored::*;
use std::path::Path;
use std::process::Command;

pub fn install_dependencies(project_path: &Path, package_manager: &PackageManager) -> Result<()> {
    let pm_str = package_manager.as_str();
    println!("\n{}", format!("📦 Installing dependencies with {}...", pm_str).yellow());

    let status = Command::new(pm_str)
        .arg("install")
        .current_dir(project_path)
        .status()?;

    if !status.success() {
        return Err(anyhow::anyhow!("{} install failed", pm_str));
    }

    Ok(())
}

pub fn detect_package_manager() -> PackageManager {
    // Check if bun is available
    if Command::new("bun").arg("--version").output().is_ok() {
        PackageManager::Bun
    } else {
        PackageManager::Npm
    }
}