From d9e7e76482b1e621c4e4fb2ede2438a0e20dabbb Mon Sep 17 00:00:00 2001 From: ityuany <519495771@qq.com> Date: Fri, 12 Jul 2024 16:50:31 +0800 Subject: [PATCH] delete unused code --- crates/snm_core/src/model/dispatch_manage.rs | 9 +------ crates/snm_core/src/traits/atom.rs | 10 -------- crates/snm_node/src/snm_node.rs | 23 ----------------- .../src/snm_package_manager.rs | 25 ------------------- 4 files changed, 1 insertion(+), 66 deletions(-) diff --git a/crates/snm_core/src/model/dispatch_manage.rs b/crates/snm_core/src/model/dispatch_manage.rs index 239f96cc..071b5e42 100644 --- a/crates/snm_core/src/model/dispatch_manage.rs +++ b/crates/snm_core/src/model/dispatch_manage.rs @@ -144,14 +144,7 @@ impl DispatchManage { let from_dir_path_buf = self.manager.get_runtime_dir_path_buf(&v)?; let to_dir_path_buf = self.manager.get_runtime_dir_for_default_path_buf(&v)?; - create_symlink(&from_dir_path_buf, &to_dir_path_buf).expect( - format!( - "set_default create_symlink error from: {:?} to: {:?}", - &from_dir_path_buf.display(), - &to_dir_path_buf.display() - ) - .as_str(), - ); + create_symlink(&from_dir_path_buf, &to_dir_path_buf)?; Ok(()) } diff --git a/crates/snm_core/src/traits/atom.rs b/crates/snm_core/src/traits/atom.rs index 749be1b4..67d8d6c3 100644 --- a/crates/snm_core/src/traits/atom.rs +++ b/crates/snm_core/src/traits/atom.rs @@ -8,8 +8,6 @@ pub trait AtomTrait { fn get_downloaded_file_path_buf(&self, v: &str) -> Result; - // fn get_downloaded_dir_path_buf(&self, v: &str) -> Result; - fn get_runtime_dir_path_buf(&self, v: &str) -> Result; fn get_runtime_dir_for_default_path_buf(&self, v: &str) -> Result; @@ -26,8 +24,6 @@ pub trait AtomTrait { downloaded_file_path_buf: &'a PathBuf, ) -> Pin> + Send + 'a>>; - // fn get_host(&self) -> Option; - fn show_list<'a>( &'a self, dir_tuple: &'a (Vec, Option), @@ -50,12 +46,6 @@ pub trait AtomTrait { output_dir_path_buf: &PathBuf, ) -> Result<(), SnmError>; - // fn get_strict_shim_binary_path_buf( - // &self, - // bin_name: &str, - // version: &str, - // ) -> Result; - fn download_condition(&self, version: &str) -> bool; fn get_runtime_binary_dir_string(&self, version: &str) -> Result; diff --git a/crates/snm_node/src/snm_node.rs b/crates/snm_node/src/snm_node.rs index ea4e8cd4..fdccae56 100644 --- a/crates/snm_node/src/snm_node.rs +++ b/crates/snm_node/src/snm_node.rs @@ -162,20 +162,11 @@ impl AtomTrait for SnmNode { self.snm_config .get_node_bin_dir()? .join(&version) - // .join(format!("node-v{}-{}-{}", &version, get_os(), get_arch())) .join("bin") .join("node") .to_ok() } - // fn get_strict_shim_binary_path_buf( - // &self, - // bin_name: &str, - // version: &str, - // ) -> Result { - // self.get_runtime_binary_file_path_buf(&bin_name, &version) - // } - fn download_condition(&self, version: &str) -> bool { match self.snm_config.get_node_install_strategy() { InstallStrategy::Ask => Confirm::new() @@ -196,7 +187,6 @@ impl AtomTrait for SnmNode { fn get_runtime_binary_dir_string(&self, version: &str) -> Result { Ok(self .get_runtime_dir_path_buf(&version)? - // .join(format!("node-v{}-{}-{}", &version, get_os(), get_arch())) .join("bin") .display() .to_string()) @@ -208,7 +198,6 @@ impl AtomTrait for SnmNode { version: &str, ) -> Result { self.get_runtime_dir_path_buf(&version)? - // .join(format!("node-v{}-{}-{}", &version, get_os(), get_arch())) .join("bin") .join(bin_name) .to_ok() @@ -228,14 +217,6 @@ impl AtomTrait for SnmNode { download_url } - // fn get_downloaded_dir_path_buf(&self, v: &str) -> Result { - // self.snm_config - // .get_download_dir()? - // .join("node") - // .join(v) - // .to_ok() - // } - fn get_downloaded_file_path_buf(&self, v: &str) -> Result { self.snm_config .get_download_dir()? @@ -307,10 +288,6 @@ impl AtomTrait for SnmNode { }) } - // fn get_host(&self) -> Option { - // None - // } - fn show_list<'a>( &'a self, dir_tuple: &'a (Vec, Option), diff --git a/crates/snm_package_manager/src/snm_package_manager.rs b/crates/snm_package_manager/src/snm_package_manager.rs index b50953e0..90ad805c 100644 --- a/crates/snm_package_manager/src/snm_package_manager.rs +++ b/crates/snm_package_manager/src/snm_package_manager.rs @@ -45,20 +45,10 @@ impl AtomTrait for SnmPackageManager { .get_node_modules_dir()? .join(&self.library_name) .join(v) - // .join("package") .join("package.json") .to_ok() } - // fn get_strict_shim_binary_path_buf( - // &self, - // bin_name: &str, - // version: &str, - // ) -> Result { - // self.get_runtime_binary_file_path_buf(&bin_name, &version)? - // .to_ok() - // } - fn download_condition(&self, version: &str) -> bool { match self.snm_config.get_package_manager_install_strategy() { InstallStrategy::Ask => { @@ -88,7 +78,6 @@ impl AtomTrait for SnmPackageManager { .get_node_modules_dir()? .join(self.library_name.to_string()) .join(&version) - // .join("package") .join("bin") .display() .to_string()) @@ -104,7 +93,6 @@ impl AtomTrait for SnmPackageManager { .get_node_modules_dir()? .join(self.library_name.to_string()) .join(&version); - // .join("package"); match parse_package_json(&package_json_dir_buf_path)? { Some(mut p) if p.bin.contains_key(bin_name) => Ok(p.bin.remove(bin_name).unwrap()), @@ -144,14 +132,6 @@ impl AtomTrait for SnmPackageManager { .to_ok() } - // fn get_downloaded_dir_path_buf(&self, v: &str) -> Result { - // self.snm_config - // .get_download_dir()? - // .join(&self.library_name) - // .join(&v) - // .to_ok() - // } - fn get_runtime_dir_path_buf(&self, v: &str) -> Result { let library_name = if &self.library_name == "@yarnpkg/cli-dist" { "yarn" @@ -237,10 +217,6 @@ impl AtomTrait for SnmPackageManager { }) } - // fn get_host(&self) -> Option { - // todo!("get_host") - // } - fn show_list<'a>( &'a self, dir_tuple: &'a (Vec, Option), @@ -322,7 +298,6 @@ impl AtomTrait for SnmPackageManager { output_dir_path_buf: &PathBuf, ) -> Result<(), SnmError> { decompress(&input_file_path_buf, &output_dir_path_buf)?; - // let package_dir_path_buf = output_dir_path_buf.join("package"); if let Some(package_json) = parse_package_json(&output_dir_path_buf)? { let bin = output_dir_path_buf.join("bin");