Fix built-in template rename order

This commit is contained in:
2026-04-26 20:48:26 +08:00
parent 8da042ccd3
commit 11576a8693
12 changed files with 220 additions and 1582 deletions

View File

@@ -2,29 +2,6 @@ use crate::error::Result;
use serde_json::Value;
use std::{fs, path::PathBuf};
pub fn copy_folder(src: &PathBuf, dest: &PathBuf) -> Result<()> {
if !src.exists() || !src.is_dir() {
return Err(crate::error::CliError::NotFound(format!(
"源目录不存在: {}",
src.display()
)));
}
if !dest.exists() {
fs::create_dir_all(dest)?;
}
for entry in fs::read_dir(src)? {
let entry = entry?;
let src_path = entry.path();
let dest_path = dest.join(src_path.file_name().unwrap());
if src_path.is_file() {
fs::copy(&src_path, &dest_path)?;
} else if src_path.is_dir() {
copy_folder(&src_path, &dest_path)?;
}
}
Ok(())
}
pub fn read_file_to_json(path: &PathBuf) -> Result<Value> {
let file = fs::read_to_string(path)?;
let json: Value = serde_json::from_str(&file)?;