From f3b5f4a7336d2a65dde18f8d6f0f04dd20a436b8 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 27 Mar 2024 22:43:26 +0200 Subject: [PATCH] Added the dependency name as dependency key in the config --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 8 ++++++-- src/config.rs | 12 +++--------- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c046d1..1e7a50c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1514,7 +1514,7 @@ dependencies = [ [[package]] name = "soldeer" -version = "0.2.6" +version = "0.2.7" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 7770150..92bcc80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" name = "soldeer" readme = "./README.md" repository = "https://github.com/mario-eth/soldeer" -version = "0.2.6" +version = "0.2.7" [dependencies] chrono = {version = "0.4.34", features = ["serde"]} diff --git a/README.md b/README.md index 499d458..79341ae 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,13 @@ This project was started to solve the following issues: - npmjs was built for the js ecosystem not for solidity - github versioning of the releases is a pain and not all the projects are using it correctly -## Version 0.2.6 +## Version 0.2.7 -#### Breaking Changes introduced in 0.2.6 +#### Version 0.2.7 introduces the following changes: + +Save the dependency key as the dependency name to respect the Cargo.toml format. For multiple versions for the same dependency an issue has been created to be added as a feature [#34](https://github.com/mario-eth/soldeer/issues/34). For now the dependency name is the key in the toml file. + +### Breaking Changes introduced in 0.2.6 In 0.2.6 the `sdependencies` has been renamed to `dependencies`. Furthermore a dependency now stored in the toml respects Cargo toml format with `version` and `url` included. diff --git a/src/config.rs b/src/config.rs index a45bb9b..67b0c81 100644 --- a/src/config.rs +++ b/src/config.rs @@ -80,9 +80,8 @@ pub fn read_config(filename: String) -> Result, ConfigError> { let mut dependencies: Vec = Vec::new(); data.dependencies.iter().for_each(|(k, v)| { - let parts: Vec<&str> = k.split('~').collect::>(); dependencies.push(Dependency { - name: parts[0].to_string(), + name: k.to_string(), version: v["version"].to_string().replace('"', ""), url: v["url"].to_string().replace('\"', ""), }); @@ -185,7 +184,7 @@ pub fn add_to_config( let dir = get_current_working_dir() .unwrap() .join("dependencies") - .join(format!("{}-{}", dependency_name, dependency_version)); + .join(dependency_name); remove_dir_all(dir).unwrap(); match cleanup_dependency(dependency_name, dependency_version) { Ok(_) => {} @@ -257,15 +256,10 @@ pub fn add_to_config( let mut new_item: Item = Item::None; new_item["version"] = value(dependency_version); new_item["url"] = value(dependency_url); - let dependency_name = format!( - "{}~{}", - dependency_name.to_string().as_str(), - dependency_version.to_string().as_str() - ); doc["dependencies"] .as_table_mut() .unwrap() - .insert(dependency_name.as_str(), new_item); + .insert(dependency_name.to_string().as_str(), new_item); let mut file: std::fs::File = fs::OpenOptions::new() .write(true) .append(false)