refactor: Remove SDK installation from weevil new
Project creation now requires environment setup first. Checks system health and directs users to `weevil setup` if needed. Separates concerns: setup installs, new creates projects.
This commit is contained in:
@@ -34,14 +34,47 @@ pub fn create_project(
|
|||||||
println!("{}", format!("Creating FTC project: {}", name).bright_green().bold());
|
println!("{}", format!("Creating FTC project: {}", name).bright_green().bold());
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
|
// Check system health FIRST
|
||||||
|
println!("{}", "Checking system prerequisites...".bright_yellow());
|
||||||
|
let health = crate::commands::doctor::check_system_health()?;
|
||||||
|
|
||||||
|
if !health.is_healthy() {
|
||||||
|
println!();
|
||||||
|
println!("{}", "═══════════════════════════════════════════════════════════".bright_red());
|
||||||
|
println!("{}", " ✗ System Setup Required".bright_red().bold());
|
||||||
|
println!("{}", "═══════════════════════════════════════════════════════════".bright_red());
|
||||||
|
println!();
|
||||||
|
println!("{}", "Missing required components:".bright_yellow().bold());
|
||||||
|
|
||||||
|
if !health.java_ok {
|
||||||
|
println!(" {} Java JDK", "✗".red());
|
||||||
|
}
|
||||||
|
if !health.ftc_sdk_ok {
|
||||||
|
println!(" {} FTC SDK", "✗".red());
|
||||||
|
}
|
||||||
|
if !health.android_sdk_ok {
|
||||||
|
println!(" {} Android SDK", "✗".red());
|
||||||
|
}
|
||||||
|
|
||||||
|
println!();
|
||||||
|
println!("{}", "Before creating a project, you need to set up your development environment.".bright_yellow());
|
||||||
|
println!();
|
||||||
|
println!("{}", "Run this command to install required components:".bright_yellow().bold());
|
||||||
|
println!(" {}", "weevil setup".bright_cyan());
|
||||||
|
println!();
|
||||||
|
println!("{}", "Then try creating your project again:".bright_yellow().bold());
|
||||||
|
println!(" {}", format!("weevil new {}", name).bright_cyan());
|
||||||
|
println!();
|
||||||
|
|
||||||
|
bail!("System setup required");
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("{} All prerequisites met", "✓".green());
|
||||||
|
println!();
|
||||||
|
|
||||||
// Setup or verify SDK configuration
|
// Setup or verify SDK configuration
|
||||||
let sdk_config = SdkConfig::with_paths(ftc_sdk, android_sdk)?;
|
let sdk_config = SdkConfig::with_paths(ftc_sdk, android_sdk)?;
|
||||||
|
|
||||||
// Install SDKs if needed
|
|
||||||
println!("{}", "Checking SDKs...".bright_yellow());
|
|
||||||
ensure_sdks(&sdk_config)?;
|
|
||||||
|
|
||||||
println!();
|
|
||||||
println!("{}", "Creating project structure...".bright_yellow());
|
println!("{}", "Creating project structure...".bright_yellow());
|
||||||
|
|
||||||
// Build the project
|
// Build the project
|
||||||
@@ -57,34 +90,12 @@ pub fn create_project(
|
|||||||
println!("Version: {}", crate::sdk::ftc::get_version(&sdk_config.ftc_sdk_path).unwrap_or_else(|_| "unknown".to_string()));
|
println!("Version: {}", crate::sdk::ftc::get_version(&sdk_config.ftc_sdk_path).unwrap_or_else(|_| "unknown".to_string()));
|
||||||
println!();
|
println!();
|
||||||
println!("{}", "Next steps:".bright_yellow().bold());
|
println!("{}", "Next steps:".bright_yellow().bold());
|
||||||
println!(" 1. cd {}", name);
|
println!(" 1. {}", format!("cd {}", name).bright_cyan());
|
||||||
println!(" 2. Review README.md for project structure");
|
println!(" 2. Review README.md for project structure");
|
||||||
println!(" 3. Start coding in src/main/java/robot/");
|
println!(" 3. Start coding in src/main/java/robot/");
|
||||||
println!(" 4. Run: ./gradlew test");
|
println!(" 4. Run tests: {}", "./gradlew test".bright_cyan());
|
||||||
println!(" 5. Deploy: weevil deploy {}", name);
|
println!(" 5. Deploy to robot: {}", format!("weevil deploy {}", name).bright_cyan());
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_sdks(config: &SdkConfig) -> Result<()> {
|
|
||||||
// Check FTC SDK
|
|
||||||
if !config.ftc_sdk_path.exists() {
|
|
||||||
println!("FTC SDK not found. Installing...");
|
|
||||||
crate::sdk::ftc::install(&config.ftc_sdk_path, &config.android_sdk_path)?;
|
|
||||||
} else {
|
|
||||||
println!("{} FTC SDK found at: {}", "✓".green(), config.ftc_sdk_path.display());
|
|
||||||
crate::sdk::ftc::verify(&config.ftc_sdk_path)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check Android SDK
|
|
||||||
if !config.android_sdk_path.exists() {
|
|
||||||
println!("Android SDK not found. Installing...");
|
|
||||||
crate::sdk::android::install(&config.android_sdk_path)?;
|
|
||||||
} else {
|
|
||||||
println!("{} Android SDK found at: {}", "✓".green(), config.android_sdk_path.display());
|
|
||||||
crate::sdk::android::verify(&config.android_sdk_path)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user