Skip to content

Commit

Permalink
refactor: remove migration code as it's no longer needed and causes e…
Browse files Browse the repository at this point in the history
…rrors (#1795)
  • Loading branch information
sxyazi authored Oct 16, 2024
1 parent e58cf55 commit a6c9c93
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
11 changes: 1 addition & 10 deletions yazi-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand All @@ -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?;
}
}
Expand Down
27 changes: 0 additions & 27 deletions yazi-cli/src/package/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`") };
Expand Down

0 comments on commit a6c9c93

Please sign in to comment.