Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/cli/src/models/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl ProjectGenerationResult {
}

pub fn add_error(&mut self, error: String) {
self.success = false;
self.errors.push(error);
}
}
}
16 changes: 6 additions & 10 deletions apps/cli/src/services/project_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl DefaultProjectService {

impl ProjectService for DefaultProjectService {
fn create_project(&self, config: &ProjectConfig) -> Result<ProjectGenerationResult> {
let mut result = ProjectGenerationResult::failure(vec![]);
let mut result = ProjectGenerationResult::success(config.name.clone(), Vec::new());

// Validate project name
if let Err(e) = self.validate_project_name(&config.name) {
Expand Down Expand Up @@ -167,16 +167,14 @@ impl ProjectService for DefaultProjectService {
return Ok(result);
}

let mut files_created = Vec::new();

// Create directories
for dir in &template.structure.directories {
let dir_path = project_path.join(dir);
if let Err(e) = fs::create_dir_all(&dir_path) {
result.add_error(format!("Failed to create directory '{}': {}", dir, e));
continue;
}
files_created.push(format!("📁 {}", dir));
result.files_created.push(format!("📁 {}", dir));
}

// Create files
Expand All @@ -202,7 +200,7 @@ impl ProjectService for DefaultProjectService {
continue;
}

files_created.push(format!("📄 {}", file.path));
result.files_created.push(format!("📄 {}", file.path));
}

// Create config files
Expand All @@ -215,13 +213,11 @@ impl ProjectService for DefaultProjectService {
continue;
}

files_created.push(format!("⚙️ {}", config_file.name));
result.files_created.push(format!("⚙️ {}", config_file.name));
}
result.project_path = Some(config.name.clone());

Ok(ProjectGenerationResult::success(
config.name.clone(),
files_created,
))
Ok(result)
}

fn list_templates(&self) -> Vec<ProjectTemplate> {
Expand Down
Loading