diff --git a/CHANGELOG.md b/CHANGELOG.md index 027acf0dee1515b49ac39e22f565f0e93cbf72c3..dd54f1e403571e6b5d9455203bd1f5c598a16774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - `--skip-linting` flag that allows to skip the linting step during build process - [#468](https://github.com/paritytech/cargo-contract/pull/468) +## [1.0.1] - 2022-03-18 +- Improved error reporting during installation - [#468](https://github.com/paritytech/cargo-contract/pull/468) + ## [1.0.0] - 2022-03-17 ### Changed diff --git a/Cargo.lock b/Cargo.lock index 4285af3d371a26d849fa7fc5301dcb457f230bc1..f152bfdcc037e707598c65e50db5e9cc63a14bd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,7 +465,7 @@ dependencies = [ [[package]] name = "cargo-contract" -version = "1.0.0" +version = "1.0.1" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 9d2b74741ffe30ce31b3f4b8ba05bd4cd0b2db8a..130aef9811ae76510ac98130e731793cee858aa6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = [".", "metadata"] [package] name = "cargo-contract" -version = "1.0.0" +version = "1.0.1" authors = ["Parity Technologies "] build = "build.rs" edition = "2021" diff --git a/build.rs b/build.rs index 23b0871112d17fdf8b27a1729b11207a2ea796cf..7b5618ed2eaf0b71b78be38456691ae31fa10628 100644 --- a/build.rs +++ b/build.rs @@ -70,6 +70,14 @@ fn zip_template_and_build_dylint_driver(manifest_dir: PathBuf, out_dir: PathBuf) let dylint_driver_dst_file = out_dir.join("ink-dylint-driver.zip"); let ink_dylint_driver_dir = manifest_dir.join("ink_linting"); + let ink_dylint_driver_dir = ink_dylint_driver_dir.canonicalize().map_err(|err| { + anyhow::anyhow!( + "Unable to canonicalize '{:?}': {:?}\nDoes the folder exist? {}", + ink_dylint_driver_dir, + err, + ink_dylint_driver_dir.exists() + ) + })?; // The `ink_linting/Cargo.toml` file is named `_Cargo.toml` in the repository. // This is because we need to have the `ink_linting` folder part of the release, @@ -85,24 +93,34 @@ fn zip_template_and_build_dylint_driver(manifest_dir: PathBuf, out_dir: PathBuf) // > * Any sub-packages will be skipped (any subdirectory that contains a Cargo.toml file). // // (from https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields) - std::fs::rename( - ink_dylint_driver_dir.join("_Cargo.toml"), - ink_dylint_driver_dir.join("Cargo.toml"), - )?; - - let res = build_and_zip_dylint_driver( - ink_dylint_driver_dir.clone(), - out_dir, - dylint_driver_dst_file, - ); + let original_name = ink_dylint_driver_dir.join("_Cargo.toml"); + if !original_name.exists() { + anyhow::bail!("'{:?}' does not exist", original_name); + } + + let tmp_name = ink_dylint_driver_dir.join("Cargo.toml"); + std::fs::rename(&original_name, &tmp_name).map_err(|err| { + anyhow::anyhow!( + "Failed renaming '{:?}' to '{:?}': {:?}", + original_name, + tmp_name, + err + ) + })?; + + let res = build_and_zip_dylint_driver(ink_dylint_driver_dir, out_dir, dylint_driver_dst_file); // After the build process of `ink_linting` happened we need to name back to the original // `_Cargo.toml` name, otherwise the directory would be "dirty" and `cargo publish` would // fail with `Source directory was modified by build.rs during cargo publish`. - std::fs::rename( - ink_dylint_driver_dir.join("Cargo.toml"), - ink_dylint_driver_dir.join("_Cargo.toml"), - )?; + std::fs::rename(&tmp_name, &original_name).map_err(|err| { + anyhow::anyhow!( + "Failed renaming '{:?}' to '{:?}': {:?}", + tmp_name, + original_name, + err + ) + })?; res }