feat: Weevil v1.0.0-beta1 - FTC Project Generator
Cross-platform tool for generating clean, testable FTC robot projects without editing the SDK installation. Features: - Standalone project generation with proper separation from SDK - Per-project SDK configuration via .weevil.toml - Local unit testing support (no robot required) - Cross-platform build/deploy scripts (Linux/macOS/Windows) - Project upgrade system preserving user code - Configuration management commands - Comprehensive test suite (11 passing tests) - Zero-warning builds Architecture: - Pure Rust implementation with embedded Gradle wrapper - Projects use deployToSDK task to copy code to FTC SDK TeamCode - Git-ready projects with automatic initialization - USB and WiFi deployment with auto-detection Commands: - weevil new <name> - Create new project - weevil upgrade <path> - Update project infrastructure - weevil config <path> - View/modify project configuration - weevil sdk status/install/update - Manage SDKs Addresses the core problem: FTC's SDK structure forces students to edit framework internals instead of separating concerns like industry standard practices. Weevil enables proper software engineering workflows for robotics education.
This commit is contained in:
82
src/project/config.rs
Normal file
82
src/project/config.rs
Normal file
@@ -0,0 +1,82 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::fs;
|
||||
use anyhow::{Result, Context, bail};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ProjectConfig {
|
||||
pub project_name: String,
|
||||
pub weevil_version: String,
|
||||
pub ftc_sdk_path: PathBuf,
|
||||
pub ftc_sdk_version: String,
|
||||
}
|
||||
|
||||
impl ProjectConfig {
|
||||
pub fn new(project_name: &str, ftc_sdk_path: PathBuf) -> Result<Self> {
|
||||
let ftc_sdk_version = crate::sdk::ftc::get_version(&ftc_sdk_path)
|
||||
.unwrap_or_else(|_| "unknown".to_string());
|
||||
|
||||
Ok(Self {
|
||||
project_name: project_name.to_string(),
|
||||
weevil_version: "1.0.0".to_string(),
|
||||
ftc_sdk_path,
|
||||
ftc_sdk_version,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn load(project_path: &Path) -> Result<Self> {
|
||||
let config_path = project_path.join(".weevil.toml");
|
||||
|
||||
if !config_path.exists() {
|
||||
bail!("Not a weevil project (missing .weevil.toml)");
|
||||
}
|
||||
|
||||
let contents = fs::read_to_string(&config_path)
|
||||
.context("Failed to read .weevil.toml")?;
|
||||
|
||||
let config: ProjectConfig = toml::from_str(&contents)
|
||||
.context("Failed to parse .weevil.toml")?;
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
pub fn save(&self, project_path: &Path) -> Result<()> {
|
||||
let config_path = project_path.join(".weevil.toml");
|
||||
let contents = toml::to_string_pretty(self)
|
||||
.context("Failed to serialize config")?;
|
||||
|
||||
fs::write(&config_path, contents)
|
||||
.context("Failed to write .weevil.toml")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn update_sdk_path(&mut self, new_path: PathBuf) -> Result<()> {
|
||||
// Verify the SDK exists
|
||||
crate::sdk::ftc::verify(&new_path)?;
|
||||
|
||||
// Update version
|
||||
self.ftc_sdk_version = crate::sdk::ftc::get_version(&new_path)
|
||||
.unwrap_or_else(|_| "unknown".to_string());
|
||||
|
||||
self.ftc_sdk_path = new_path;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn display(&self) {
|
||||
use colored::*;
|
||||
|
||||
println!();
|
||||
println!("{}", "═══════════════════════════════════════════════════════════".bright_cyan());
|
||||
println!("{}", " Project Configuration".bright_cyan().bold());
|
||||
println!("{}", "═══════════════════════════════════════════════════════════".bright_cyan());
|
||||
println!();
|
||||
println!("{:.<20} {}", "Project Name", self.project_name.bright_white());
|
||||
println!("{:.<20} {}", "Weevil Version", self.weevil_version.bright_white());
|
||||
println!();
|
||||
println!("{:.<20} {}", "FTC SDK Path", self.ftc_sdk_path.display().to_string().bright_white());
|
||||
println!("{:.<20} {}", "FTC SDK Version", self.ftc_sdk_version.bright_white());
|
||||
println!();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user