From a6c9c93d586422fbb212707bfb09c9039585b40b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Wed, 16 Oct 2024 20:26:39 +0800 Subject: [PATCH] refactor: remove migration code as it's no longer needed and causes errors (#1795) --- yazi-cli/src/main.rs | 11 +---------- yazi-cli/src/package/parser.rs | 27 --------------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/yazi-cli/src/main.rs b/yazi-cli/src/main.rs index 4adade6f..dd8807df 100644 --- a/yazi-cli/src/main.rs +++ b/yazi-cli/src/main.rs @@ -47,7 +47,6 @@ async fn main() -> anyhow::Result<()> { Command::Pack(cmd) => { package::init()?; - package::Package::migrate().await?; if cmd.install { package::Package::install_from_config("plugin", false).await?; package::Package::install_from_config("flavor", false).await?; @@ -57,15 +56,7 @@ async fn main() -> anyhow::Result<()> { } else if cmd.upgrade { package::Package::install_from_config("plugin", true).await?; package::Package::install_from_config("flavor", true).await?; - } else if let Some(mut repo) = cmd.add { - // TODO: remove this in the future - if repo.contains("#") { - repo = repo.replace("#", ":"); - println!( - "WARNING: `#` has been deprecated in Yazi 0.3.1, please use `:` instead. See https://github.com/sxyazi/yazi/issues/1471 for more information." - ); - } - + } else if let Some(repo) = cmd.add { package::Package::add_to_config(&repo).await?; } } diff --git a/yazi-cli/src/package/parser.rs b/yazi-cli/src/package/parser.rs index c58020e8..49a22a40 100644 --- a/yazi-cli/src/package/parser.rs +++ b/yazi-cli/src/package/parser.rs @@ -6,33 +6,6 @@ use yazi_shared::Xdg; use super::Package; impl Package { - // TODO: remove this in the future - pub(crate) async fn migrate() -> Result<()> { - let path = Xdg::config_dir().join("package.toml"); - let mut doc = Self::ensure_config(&fs::read_to_string(&path).await.unwrap_or_default())?; - - fn impl_(deps: &mut Array) -> Result<()> { - for dep in deps.iter_mut() { - let dep = dep.as_inline_table_mut().context("Dependency must be an inline table")?; - let use_ = dep.get("use").and_then(|d| d.as_str()).context("Missing `use` field")?; - if use_.contains("#") { - dep["use"] = use_.replace("#", ":").into(); - } - if let Some(commit) = dep.get("commit").map(ToOwned::to_owned) { - dep.remove("commit"); - dep.insert("rev", commit); - } - } - Ok(()) - } - - impl_(doc["plugin"]["deps"].as_array_mut().unwrap())?; - impl_(doc["flavor"]["deps"].as_array_mut().unwrap())?; - - fs::write(path, doc.to_string()).await?; - Ok(()) - } - pub(crate) async fn add_to_config(use_: &str) -> Result<()> { let mut package = Self::new(use_, None); let Some(name) = package.name() else { bail!("Invalid package `use`") };