remove avm use prompt, and insist on user installing a version if it's not yet installed (#1565)
This commit is contained in:
parent
565e9567b5
commit
e567e14154
|
@ -40,6 +40,7 @@ incremented for features.
|
||||||
* lang: Remove space calculation using `#[derive(Default)]` ([#1519](https://github.com/project-serum/anchor/pull/1519)).
|
* lang: Remove space calculation using `#[derive(Default)]` ([#1519](https://github.com/project-serum/anchor/pull/1519)).
|
||||||
* lang: Add support for logging expected and actual values and pubkeys. Add `require_eq` and `require_keys_eq` macros. Add default error code to `require` macro ([#1572](https://github.com/project-serum/anchor/pull/1572)).
|
* lang: Add support for logging expected and actual values and pubkeys. Add `require_eq` and `require_keys_eq` macros. Add default error code to `require` macro ([#1572](https://github.com/project-serum/anchor/pull/1572)).
|
||||||
* lang: Add `system_program` CPI wrapper functions. Make `system_program` module public instead of re-exporting `system_program::System`([#1629](https://github.com/project-serum/anchor/pull/1629)).
|
* lang: Add `system_program` CPI wrapper functions. Make `system_program` module public instead of re-exporting `system_program::System`([#1629](https://github.com/project-serum/anchor/pull/1629)).
|
||||||
|
* cli: `avm use` no long prompts [y/n] if an install is needed first - it just tells the user to `avm install` ([#1565](https://github.com/project-serum/anchor/pull/1565))
|
||||||
|
|
||||||
## [0.22.1] - 2022-02-28
|
## [0.22.1] - 2022-02-28
|
||||||
|
|
||||||
|
|
|
@ -320,8 +320,7 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"clap 3.1.6",
|
"clap 3.1.6",
|
||||||
"dialoguer 0.9.0",
|
"dirs 1.0.5",
|
||||||
"dirs 4.0.0",
|
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"semver 1.0.6",
|
"semver 1.0.6",
|
||||||
|
@ -386,6 +385,17 @@ version = "1.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "blake2b_simd"
|
||||||
|
version = "0.5.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587"
|
||||||
|
dependencies = [
|
||||||
|
"arrayref",
|
||||||
|
"arrayvec",
|
||||||
|
"constant_time_eq",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blake3"
|
name = "blake3"
|
||||||
version = "0.3.8"
|
version = "0.3.8"
|
||||||
|
@ -979,18 +989,6 @@ dependencies = [
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dialoguer"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "61579ada4ec0c6031cfac3f86fdba0d195a7ebeb5e36693bd53cb5999a25beeb"
|
|
||||||
dependencies = [
|
|
||||||
"console 0.15.0",
|
|
||||||
"lazy_static",
|
|
||||||
"tempfile",
|
|
||||||
"zeroize",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
|
@ -1020,18 +1018,20 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs"
|
name = "dirs"
|
||||||
version = "3.0.2"
|
version = "1.0.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-sys",
|
"libc",
|
||||||
|
"redox_users 0.3.5",
|
||||||
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs"
|
name = "dirs"
|
||||||
version = "4.0.0"
|
version = "3.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
|
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-sys",
|
"dirs-sys",
|
||||||
]
|
]
|
||||||
|
@ -1053,7 +1053,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
|
checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"redox_users",
|
"redox_users 0.4.0",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1064,7 +1064,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
|
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"redox_users",
|
"redox_users 0.4.0",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2505,6 +2505,17 @@ dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_users"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom 0.1.16",
|
||||||
|
"redox_syscall 0.1.57",
|
||||||
|
"rust-argon2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_users"
|
name = "redox_users"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
@ -2608,6 +2619,18 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rust-argon2"
|
||||||
|
version = "0.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb"
|
||||||
|
dependencies = [
|
||||||
|
"base64 0.13.0",
|
||||||
|
"blake2b_simd",
|
||||||
|
"constant_time_eq",
|
||||||
|
"crossbeam-utils 0.8.8",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.21"
|
version = "0.1.21"
|
||||||
|
@ -3353,7 +3376,7 @@ checksum = "f009d977623835959420767d1d9db3b19b3cdac9ff57701f2449d453a2c2d7ee"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base32",
|
"base32",
|
||||||
"console 0.14.1",
|
"console 0.14.1",
|
||||||
"dialoguer 0.6.2",
|
"dialoguer",
|
||||||
"hidapi",
|
"hidapi",
|
||||||
"log",
|
"log",
|
||||||
"num-derive",
|
"num-derive",
|
||||||
|
|
|
@ -16,8 +16,7 @@ path = "src/anchor/main.rs"
|
||||||
clap = { version = "3.0.13", features = [ "derive" ]}
|
clap = { version = "3.0.13", features = [ "derive" ]}
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
anyhow = "1.0.32"
|
anyhow = "1.0.32"
|
||||||
dialoguer = "0.9.0"
|
dirs = "1.0.5"
|
||||||
dirs = "4.0"
|
|
||||||
semver = "1.0.4"
|
semver = "1.0.4"
|
||||||
serde = { version = "1.0.136", features = [ "derive" ]}
|
serde = { version = "1.0.136", features = [ "derive" ]}
|
||||||
serde_json = "1.0.78"
|
serde_json = "1.0.78"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use dialoguer::Input;
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use reqwest::header::USER_AGENT;
|
use reqwest::header::USER_AGENT;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
|
@ -50,27 +49,24 @@ pub fn use_version(version: &Version) -> Result<()> {
|
||||||
let installed_versions = read_installed_versions();
|
let installed_versions = read_installed_versions();
|
||||||
// Make sure the requested version is installed
|
// Make sure the requested version is installed
|
||||||
if !installed_versions.contains(version) {
|
if !installed_versions.contains(version) {
|
||||||
let input: String = Input::new()
|
if let Ok(current) = current_version() {
|
||||||
.with_prompt(format!(
|
|
||||||
"anchor-cli {} is not installed, would you like to install it? (y/n)",
|
|
||||||
version
|
|
||||||
))
|
|
||||||
.default("n".into())
|
|
||||||
.interact_text()?;
|
|
||||||
if matches!(input.as_str(), "y" | "yy" | "Y" | "yes" | "Yes") {
|
|
||||||
install_version(version)?;
|
|
||||||
} else {
|
|
||||||
println!(
|
println!(
|
||||||
"Version {} is not installed, staying on version {}.",
|
"Version {} is not installed, staying on version {}.",
|
||||||
version,
|
version, current
|
||||||
current_version()?
|
|
||||||
);
|
);
|
||||||
return Ok(());
|
} else {
|
||||||
|
println!("Version {} is not installed, no current version.", version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Err(anyhow!(
|
||||||
|
"You need to run 'avm install {}' to install it before using it.",
|
||||||
|
version
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut current_version_file = fs::File::create(current_version_file_path().as_path())?;
|
let mut current_version_file = fs::File::create(current_version_file_path().as_path())?;
|
||||||
current_version_file.write_all(version.to_string().as_bytes())?;
|
current_version_file.write_all(version.to_string().as_bytes())?;
|
||||||
|
println!("Now using anchor version {}.", current_version()?);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue