From b3e8a861ae035f9f3c7d810bb12699cad92a88c7 Mon Sep 17 00:00:00 2001 From: Chris O'Neil Date: Sun, 20 Oct 2024 16:07:51 +0100 Subject: [PATCH] feat: `client` cmd now uses the `autonomi` binary The `client` command will now retrieve and install the `autonomi` binary rather than `safe`. The installer scripts have also been updated to use the new settings locations. BREAKING CHANGE: the binaries and settings now use a path with `autonomi` rather than `safe`. The old settings file is now also incompatible because it is at a different location and the field names have changed, so they will serialize/deserialize to/from different values. Fetching a different binary itself is also a breaking change. The tests in the PR workflow are updated to work with the newer versions of the `safenode` and `safenode-manager` binaries, which have new output for `--version`. We need to use RC versions just now because those are the only ones that have been released with the new versioning information. --- .github/workflows/pr.yml | 63 +++++++++++++------------- Cargo.toml | 2 +- README.md | 6 +-- install.ps1 | 18 ++++---- install.sh | 10 ++--- src/cmd.rs | 42 +++++++++--------- src/install.rs | 96 ++++++++++++++++++++-------------------- src/main.rs | 16 +++---- src/update.rs | 32 +++++++------- 9 files changed, 142 insertions(+), 143 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a3fc36c..72ee4cf 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,9 +10,9 @@ on: pull_request env: RUST_BACKTRACE: 1 RUSTFLAGS: "-D warnings" - CLIENT_VERSION: 0.94.0 - NODE_VERSION: 0.110.0 - NODE_MANAGER_VERSION: 0.10.1 + CLIENT_VERSION: 0.1.1-rc.1 + NODE_VERSION: 0.112.0-rc.1 + NODE_MANAGER_VERSION: 0.11.0-rc.1 jobs: # The code in this crate uses lots of conditional compilation for cross-platform capabilities. @@ -146,15 +146,15 @@ jobs: - name: Check if binaries are available in new shell session shell: pwsh run: | - if (!(Test-Path "$env:USERPROFILE\safe\safe.exe")) { - Write-Host "safe.exe does not exist" + if (!(Test-Path "$env:USERPROFILE\autonomi\autonomi.exe")) { + Write-Host "autonomi.exe does not exist" exit 1 } - if (!(Test-Path "$env:USERPROFILE\safe\safenode.exe")) { + if (!(Test-Path "$env:USERPROFILE\autonomi\safenode.exe")) { Write-Host "safenode.exe does not exist" exit 1 } - if (!(Test-Path "$env:USERPROFILE\safe\safenode-manager.exe")) { + if (!(Test-Path "$env:USERPROFILE\autonomi\safenode-manager.exe")) { Write-Host "safenode-manager.exe does not exist" exit 1 } @@ -163,21 +163,21 @@ jobs: # being modified easily, so we need to refer to the binaries with their full paths. # Other manual testing has proven that the changes to the Path environment variable do # take effect. - $output = & "${env:USERPROFILE}\safe\safe.exe" --version - $version = $output | Select-String -Pattern "sn_cli (\d+\.\d+\.\d+)" + $output = & "${env:USERPROFILE}\autonomi\autonomi.exe" --version + $version = $output | Select-String -Pattern "autonomi-cli (\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+(?:\.[0-9]+)?)?)" $versionNumber = $version.Matches.Groups[1].Value if ($versionNumber -eq "$env:CLIENT_VERSION") { - Write-Host "The correct version of safe has been installed" + Write-Host "The correct version of autonomi has been installed" } else { - Write-Host "The correct version of safe has not been installed" + Write-Host "The correct version of autonomi has not been installed" Write-Host "We expected version $env:CLIENT_VERSION" Write-Host "The downloaded binary has $versionNumber" exit 1 } - $output = & "${env:USERPROFILE}\safe\safenode.exe" --version - $version = $output | Select-String -Pattern "safenode cli (\d+\.\d+\.\d+)" - $versionNumber = $version.Matches.Groups[1].Value + $output = & "${env:USERPROFILE}\autonomi\safenode.exe" --version + $version = $output -split "`n" | Select-Object -First 1 + $versionNumber = ($version -split "v")[1].Trim() if ($versionNumber -eq "$env:NODE_VERSION") { Write-Host "The correct version of safenode has been installed" } else { @@ -187,9 +187,9 @@ jobs: exit 1 } - $output = & "${env:USERPROFILE}\safe\safenode-manager.exe" --version - $version = $output | Select-String -Pattern "sn-node-manager (\d+\.\d+\.\d+)" - $versionNumber = $version.Matches.Groups[1].Value + $output = & "${env:USERPROFILE}\autonomi\safenode-manager.exe" --version + $version = $output -split "`n" | Select-Object -First 1 + $versionNumber = ($version -split "v")[1].Trim() if ($versionNumber -eq "$env:NODE_MANAGER_VERSION") { Write-Host "The correct version of safenode-manager has been installed" } else { @@ -226,23 +226,23 @@ jobs: # the test does prove that the env file modifies PATH correctly and # that the installs of the binaries are available from their local # locations. - source ~/.config/safe/env + source ~/.config/autonomi/env - [[ -f "$HOME/.local/bin/safe" ]] || { echo "safe not in expected location"; exit 1; } + [[ -f "$HOME/.local/bin/autonomi" ]] || { echo "autonomi not in expected location"; exit 1; } [[ -f "$HOME/.local/bin/safenode" ]] || { echo "safenode not in expected location"; exit 1; } [[ -f "$HOME/.local/bin/safenode-manager" ]] || { echo "safenode-manager not in expected location"; exit 1; } - version=$(safe --version | awk '{ print $2 }') + version=$(autonomi --version | awk '{ print $2 }') if [[ "$version" == "$CLIENT_VERSION" ]]; then - echo "The correct version of safe has been installed" + echo "The correct version of autonomi has been installed" else - echo "The correct version of safe has not been installed" + echo "The correct version of autonomi has not been installed" echo "We expected $CLIENT_VERSION" echo "The downloaded binary has $version" exit 1 fi - version=$(safenode --version | awk '{ print $3 }') + version=$(safenode --version | head -n 1 | awk '{print $3}' | sed 's/^v//') if [[ "$version" == "$NODE_VERSION" ]]; then echo "The correct version of safenode has been installed" else @@ -252,7 +252,7 @@ jobs: exit 1 fi - version=$(safenode-manager --version | awk '{ print $2 }') + version=$(safenode-manager --version | head -n 1 | awk '{print $4}' | sed 's/^v//') if [[ "$version" == "$NODE_MANAGER_VERSION" ]]; then echo "The correct version of safenode-manager has been installed" else @@ -281,23 +281,23 @@ jobs: - name: Check if binaries are available in new shell session run: | # As with the Ubuntu test, we need to source the env file to get the binaries on PATH. - source "/Users/runner/Library/Application Support/safe/env" + source "/Users/runner/Library/Application Support/autonomi/env" - [[ -f "$HOME/.local/bin/safe" ]] || { echo "safe not in expected location"; exit 1; } + [[ -f "$HOME/.local/bin/autonomi" ]] || { echo "autonomi not in expected location"; exit 1; } [[ -f "$HOME/.local/bin/safenode" ]] || { echo "safenode not in expected location"; exit 1; } [[ -f "$HOME/.local/bin/safenode-manager" ]] || { echo "safenode-manager not in expected location"; exit 1; } - version=$(safe --version | awk '{ print $2 }') + version=$(autonomi --version | awk '{ print $2 }') if [[ "$version" == "$CLIENT_VERSION" ]]; then - echo "The correct version of safe has been installed" + echo "The correct version of autonomi has been installed" else - echo "The correct version of safe has not been installed" + echo "The correct version of autonomi has not been installed" echo "We expected $CLIENT_VERSION" echo "The downloaded binary has $version" exit 1 fi - version=$(safenode --version | awk '{ print $3 }') + version=$(safenode --version | head -n 1 | awk '{print $3}' | sed 's/^v//') if [[ "$version" == "$NODE_VERSION" ]]; then echo "The correct version of safenode has been installed" else @@ -307,7 +307,7 @@ jobs: exit 1 fi - version=$(safenode-manager --version | awk '{ print $2 }') + version=$(safenode-manager --version | head -n 1 | awk '{print $4}' | sed 's/^v//') if [[ "$version" == "$NODE_MANAGER_VERSION" ]]; then echo "The correct version of safenode-manager has been installed" else @@ -331,3 +331,4 @@ jobs: - name: dry run publish run: cargo publish --dry-run + diff --git a/Cargo.toml b/Cargo.toml index 858af1e..13e4a2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ semver = "1.0.4" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" -sn-releases = "0.2.7" +sn-releases = "0.3.0" tempfile = "3.8.1" textwrap = "0.16.0" tokio = { version = "1.26", features = ["full"] } diff --git a/README.md b/README.md index 7ce8c81..c9ba64e 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Otherwise: curl -sSL https://raw.githubusercontent.com/maidsafe/safeup/main/install.sh | bash ``` -This process will download and install `safeup` for your platform, then run it to have it install the `safe` client binary. +This process will download and install `safeup` for your platform. -The install script also accepts two flag arguments, namely `--client` and `--node`. If either are used, the script will invoke the installed `safeup` binary to install `safe` and `safenode`, respectively, without having to run either as an additional post-install step. +The install script also accepts two flag arguments, namely `--client` and `--node`. If either are used, the script will invoke the installed `safeup` binary to install `autonomi` and `safenode`, respectively, without having to run either as an additional post-install step. To use these options as `sudo`: ``` @@ -45,7 +45,7 @@ Therefore, installing any components on Windows is an additional post-safeup-ins ## Usage -Use the `client`, `node` or `testnet` commands to install the latest versions of the `safe`, `safenode` or `testnet` binaries, respectively. +Use the `client`, `node` or `testnet` commands to install the latest versions of the `autonomi`, `safenode` or `testnet` binaries, respectively. As above, you can choose to run `safeup` using `sudo`, depending on where you'd like your binaries installed. Again, this does not apply to Windows, where we don't support running with Administrator privileges. diff --git a/install.ps1 b/install.ps1 index 546d58f..bdc210b 100644 --- a/install.ps1 +++ b/install.ps1 @@ -18,20 +18,20 @@ $downloadUrl = $asset.browser_download_url $archivePath = Join-Path $env:TEMP "safeup.zip" Invoke-WebRequest -Uri $downloadUrl -OutFile $archivePath -$safePath = Join-Path $env:USERPROFILE "safe" -New-Item -ItemType Directory -Force -Path $safePath -Expand-Archive -Path $archivePath -DestinationPath $safePath -Force +$autonomiPath = Join-Path $env:USERPROFILE "autonomi" +New-Item -ItemType Directory -Force -Path $autonomiPath +Expand-Archive -Path $archivePath -DestinationPath $autonomiPath -Force Remove-Item $archivePath -$safeupExePath = Join-Path $safePath "safeup.exe" +$safeupExePath = Join-Path $autonomiPath "safeup.exe" $currentPath = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::User) -if ($currentPath -notlike "*$safePath*") { - $newPath = $currentPath + ";" + $safePath +if ($currentPath -notlike "*$autonomiPath*") { + $newPath = $currentPath + ";" + $autonomiPath [Environment]::SetEnvironmentVariable("PATH", $newPath, [EnvironmentVariableTarget]::User) - Write-Host "Added $safePath to user PATH" + Write-Host "Added $autonomiPath to user PATH" } else { - Write-Host "Path $safePath is already in user PATH" + Write-Host "Path $autonomiPath is already in user PATH" } Write-Host "You may need to start a new session for safeup to become available." -Write-Host "When safeup is available, please run 'safeup --help' to see how to install network components." +Write-Host "When safeup is available, please run 'safeup --help' to see how to install network components." \ No newline at end of file diff --git a/install.sh b/install.sh index 3bd0d06..7f563e3 100755 --- a/install.sh +++ b/install.sh @@ -92,8 +92,8 @@ function install_safeup() { else target_dir="$HOME/.local/bin" mkdir -p "$target_dir" - mkdir -p "$HOME/.config/safe" - cat << 'EOF' > ~/.config/safe/env + mkdir -p "$HOME/.config/autonomi" + cat << 'EOF' > ~/.config/autonomi/env #!/bin/sh case ":${PATH}:" in *:"$HOME/.local/bin":*) @@ -103,7 +103,7 @@ case ":${PATH}:" in ;; esac EOF - echo "source $HOME/.config/safe/env" >> "$HOME/.bashrc" + echo "source $HOME/.config/autonomi/env" >> "$HOME/.bashrc" fi temp_dir=$(mktemp -d) @@ -129,7 +129,7 @@ function post_install() { else printf "\n" echo "The safeup binary has been installed, but it's not available in this session." - echo "You must either run 'source ~/.config/safe/env' in this session, or start a new session." + echo "You must either run 'source ~/.config/autonomi/env' in this session, or start a new session." echo "When safeup is available, please run 'safeup --help' to see how to install network components." fi } @@ -139,4 +139,4 @@ detect_os detect_arch get_latest_version install_safeup -post_install +post_install \ No newline at end of file diff --git a/src/cmd.rs b/src/cmd.rs index 6248925..526207a 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -24,7 +24,7 @@ lazy_static! { let mut m = HashMap::new(); m.insert( AssetType::Client, - "https://sn-cli.s3.eu-west-2.amazonaws.com", + "https://autonomi-cli.s3.eu-west-2.amazonaws.com", ); m.insert( AssetType::Node, @@ -44,7 +44,7 @@ pub(crate) async fn process_install_cmd( version: Option, no_modify_shell_profile: bool, ) -> Result<()> { - let safe_config_dir_path = get_safe_config_dir_path()?; + let autonomi_config_dir_path = get_autonomi_config_dir_path()?; let dest_dir_path = if let Some(path) = custom_path { path } else { @@ -62,7 +62,7 @@ pub(crate) async fn process_install_cmd( crate::install::configure_shell_profile( &dest_dir_path.clone(), &get_shell_profile_path()?, - &safe_config_dir_path.join("env"), + &autonomi_config_dir_path.join("env"), ) .await? } @@ -71,8 +71,8 @@ pub(crate) async fn process_install_cmd( } pub(crate) async fn process_update_cmd() -> Result<()> { - let safe_config_dir_path = get_safe_config_dir_path()?; - let settings_file_path = safe_config_dir_path.join("safeup.json"); + let autonomi_config_dir_path = get_autonomi_config_dir_path()?; + let settings_file_path = autonomi_config_dir_path.join("safeup.json"); let settings = Settings::read(&settings_file_path)?; let release_repo = ::default_config(); @@ -115,8 +115,8 @@ pub(crate) async fn process_update_cmd() -> Result<()> { } pub(crate) fn process_ls_command() -> Result<()> { - let safe_config_dir_path = get_safe_config_dir_path()?; - let settings_file_path = safe_config_dir_path.join("safeup.json"); + let autonomi_config_dir_path = get_autonomi_config_dir_path()?; + let settings_file_path = autonomi_config_dir_path.join("safeup.json"); let settings = Settings::read(&settings_file_path)?; let mut table = Table::new(); table.add_row(Row::new(vec![ @@ -161,13 +161,13 @@ async fn do_install_binary( ) .await?; - let safe_config_dir_path = get_safe_config_dir_path()?; - let settings_file_path = safe_config_dir_path.join("safeup.json"); + let autonomi_config_dir_path = get_autonomi_config_dir_path()?; + let settings_file_path = autonomi_config_dir_path.join("safeup.json"); let mut settings = Settings::read(&settings_file_path)?; match asset_type { AssetType::Client => { - settings.safe_path = Some(bin_path); - settings.safe_version = Some(installed_version); + settings.autonomi_path = Some(bin_path); + settings.autonomi_version = Some(installed_version); } AssetType::Node => { settings.safenode_path = Some(bin_path); @@ -253,28 +253,28 @@ fn get_shell_profile_path() -> Result { Ok(home_dir_path.join(profile_file_name)) } -fn get_safe_config_dir_path() -> Result { +fn get_autonomi_config_dir_path() -> Result { let config_dir_path = dirs_next::config_dir() .ok_or_else(|| eyre!("Could not retrieve user's config directory"))?; - let safe_config_dir_path = config_dir_path.join("safe"); - std::fs::create_dir_all(safe_config_dir_path.clone())?; - Ok(safe_config_dir_path) + let autonomi_config_dir_path = config_dir_path.join("autonomi"); + std::fs::create_dir_all(autonomi_config_dir_path.clone())?; + Ok(autonomi_config_dir_path) } #[cfg(target_os = "windows")] fn get_default_install_path() -> Result { let home_dir_path = dirs_next::home_dir().ok_or_else(|| eyre!("Could not retrieve user's home directory"))?; - let safe_dir_path = home_dir_path.join("safe"); - std::fs::create_dir_all(safe_dir_path.clone())?; - Ok(safe_dir_path) + let autonomi_dir_path = home_dir_path.join("autonomi"); + std::fs::create_dir_all(autonomi_dir_path.clone())?; + Ok(autonomi_dir_path) } #[cfg(target_family = "unix")] fn get_default_install_path() -> Result { let home_dir_path = dirs_next::home_dir().ok_or_else(|| eyre!("Could not retrieve user's home directory"))?; - let safe_dir_path = home_dir_path.join(".local").join("bin"); - std::fs::create_dir_all(safe_dir_path.clone())?; - Ok(safe_dir_path) + let autonomi_dir_path = home_dir_path.join(".local").join("bin"); + std::fs::create_dir_all(autonomi_dir_path.clone())?; + Ok(autonomi_dir_path) } diff --git a/src/install.rs b/src/install.rs index 83b252e..b8f68a4 100644 --- a/src/install.rs +++ b/src/install.rs @@ -63,7 +63,7 @@ impl AssetType { pub fn get_release_type(&self) -> ReleaseType { match self { - AssetType::Client => ReleaseType::Safe, + AssetType::Client => ReleaseType::Autonomi, AssetType::Node => ReleaseType::Safenode, AssetType::NodeManager => ReleaseType::SafenodeManager, } @@ -73,7 +73,7 @@ impl AssetType { impl std::fmt::Display for AssetType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match *self { - AssetType::Client => write!(f, "safe"), + AssetType::Client => write!(f, "autonomi"), AssetType::Node => write!(f, "safenode"), AssetType::NodeManager => write!(f, "safenode-manager"), } @@ -82,12 +82,12 @@ impl std::fmt::Display for AssetType { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Settings { - pub safe_path: Option, + pub autonomi_path: Option, #[serde( serialize_with = "serialize_version", deserialize_with = "deserialize_version" )] - pub safe_version: Option, + pub autonomi_version: Option, pub safenode_path: Option, #[serde( serialize_with = "serialize_version", @@ -166,8 +166,8 @@ impl Settings { let mut contents = String::new(); file.read_to_string(&mut contents)?; serde_json::from_str(&contents).unwrap_or_else(|_| Settings { - safe_path: None, - safe_version: None, + autonomi_path: None, + autonomi_version: None, safenode_path: None, safenode_version: None, safenode_manager_path: None, @@ -175,8 +175,8 @@ impl Settings { }) } else { Settings { - safe_path: None, - safe_version: None, + autonomi_path: None, + autonomi_version: None, safenode_path: None, safenode_version: None, safenode_manager_path: None, @@ -187,13 +187,11 @@ impl Settings { } pub fn get_install_details(&self, asset_type: &AssetType) -> Option<(PathBuf, Version)> { - // In each of these cases, if either the path or the version is set, both of them have to - // be set, so the unwrap seems justified. If only one of them is set, that's a bug. match asset_type { AssetType::Client => { - if self.safe_path.is_some() { - let path = self.safe_path.as_ref().unwrap(); - let version = self.safe_version.as_ref().unwrap(); + if self.autonomi_path.is_some() { + let path = self.autonomi_path.as_ref().unwrap(); + let version = self.autonomi_version.as_ref().unwrap(); return Some((path.clone(), version.clone())); } None @@ -420,7 +418,7 @@ pub async fn configure_shell_profile( fn get_bin_name(asset_type: &AssetType) -> String { let mut bin_name = match asset_type { - AssetType::Client => "safe".to_string(), + AssetType::Client => "autonomi".to_string(), AssetType::Node => "safenode".to_string(), AssetType::NodeManager => "safenode-manager".to_string(), }; @@ -461,9 +459,9 @@ mod test { /// These may seem pointless, but they are useful for when the tests run on different /// platforms. #[cfg(unix)] - const SAFE_BIN_NAME: &str = "safe"; + const AUTONOMI_BIN_NAME: &str = "autonomi"; #[cfg(windows)] - const SAFE_BIN_NAME: &str = "safe.exe"; + const AUTONOMI_BIN_NAME: &str = "autonomi.exe"; #[cfg(unix)] const PLATFORM: &str = "x86_64-unknown-linux-musl"; #[cfg(windows)] @@ -502,10 +500,10 @@ mod test { let temp_dir = assert_fs::TempDir::new()?; let install_dir = temp_dir.child("install"); - let installed_safe = install_dir.child("safe"); + let installed_autonomi = install_dir.child("autonomi"); // By creating this file we are 'pretending' that it was extracted to the specified // location. It's done so we can assert that the file is made executable. - installed_safe.write_binary(b"fake safe bin")?; + installed_autonomi.write_binary(b"fake autonomi bin")?; let mut mock_release_repo = MockSafeReleaseRepository::new(); let mut seq = Sequence::new(); @@ -518,7 +516,7 @@ mod test { mock_release_repo .expect_download_release_from_s3() .with( - eq(&ReleaseType::Safe), + eq(&ReleaseType::Autonomi), eq(latest_version.clone()), always(), // Varies per platform eq(&ArchiveType::TarGz), @@ -528,19 +526,19 @@ mod test { .times(1) .returning(move |_, _, _, _, _, _| { Ok(PathBuf::from(format!( - "/tmp/safe-{}-x86_64-unknown-linux-musl.tar.gz", + "/tmp/autonomi-{}-x86_64-unknown-linux-musl.tar.gz", latest_version_clone2 ))) }) .in_sequence(&mut seq); let mut install_dir_path_clone = install_dir.to_path_buf().clone(); - install_dir_path_clone.push("safe"); + install_dir_path_clone.push("autonomi"); mock_release_repo .expect_extract_release_archive() .with( eq(PathBuf::from(format!( - "/tmp/safe-{}-x86_64-unknown-linux-musl.tar.gz", + "/tmp/autonomi-{}-x86_64-unknown-linux-musl.tar.gz", latest_version.clone() ))), always(), // We will extract to a temporary directory @@ -559,13 +557,13 @@ mod test { .await?; assert_eq!(version, Version::new(0, 86, 55)); - assert_eq!(bin_path, installed_safe.to_path_buf()); + assert_eq!(bin_path, installed_autonomi.to_path_buf()); #[cfg(unix)] { - let extracted_safe_metadata = std::fs::metadata(installed_safe.path())?; + let extracted_autonomi_metadata = std::fs::metadata(installed_autonomi.path())?; assert_eq!( - (extracted_safe_metadata.permissions().mode() & 0o777), + (extracted_autonomi_metadata.permissions().mode() & 0o777), 0o755 ); } @@ -582,10 +580,10 @@ mod test { let temp_dir = assert_fs::TempDir::new()?; let install_dir = temp_dir.child("install/using/many/paths"); - let installed_safe = install_dir.child("safe"); + let installed_autonomi = install_dir.child("autonomi"); // By creating this file we are 'pretending' that it was extracted to the specified // location. It's done so we can assert that the file is made executable. - installed_safe.write_binary(b"fake safe bin")?; + installed_autonomi.write_binary(b"fake autonomi bin")?; let mut mock_release_repo = MockSafeReleaseRepository::new(); let mut seq = Sequence::new(); @@ -598,7 +596,7 @@ mod test { mock_release_repo .expect_download_release_from_s3() .with( - eq(&ReleaseType::Safe), + eq(&ReleaseType::Autonomi), eq(latest_version.clone()), always(), // Varies per platform eq(&ArchiveType::TarGz), @@ -608,19 +606,19 @@ mod test { .times(1) .returning(move |_, _, _, _, _, _| { Ok(PathBuf::from(format!( - "/tmp/safe-{}-x86_64-unknown-linux-musl.tar.gz", + "/tmp/autonomi-{}-x86_64-unknown-linux-musl.tar.gz", latest_version_clone2 ))) }) .in_sequence(&mut seq); let mut install_dir_path_clone = install_dir.to_path_buf().clone(); - install_dir_path_clone.push("safe"); + install_dir_path_clone.push("autonomi"); mock_release_repo .expect_extract_release_archive() .with( eq(PathBuf::from(format!( - "/tmp/safe-{}-x86_64-unknown-linux-musl.tar.gz", + "/tmp/autonomi-{}-x86_64-unknown-linux-musl.tar.gz", latest_version ))), always(), // We will extract to a temporary directory @@ -639,7 +637,7 @@ mod test { .await?; assert_eq!(version, Version::new(0, 86, 55)); - assert_eq!(bin_path, installed_safe.to_path_buf()); + assert_eq!(bin_path, installed_autonomi.to_path_buf()); Ok(()) } @@ -651,17 +649,17 @@ mod test { let temp_dir = assert_fs::TempDir::new()?; let install_dir = temp_dir.child("install"); - let installed_safe = install_dir.child("safe"); + let installed_autonomi = install_dir.child("autonomi"); // By creating this file we are 'pretending' that it was extracted to the specified // location. It's done so we can assert that the file is made executable. - installed_safe.write_binary(b"fake safe bin")?; + installed_autonomi.write_binary(b"fake autonomi bin")?; let mut mock_release_repo = MockSafeReleaseRepository::new(); let mut seq = Sequence::new(); mock_release_repo .expect_download_release_from_s3() .with( - eq(&ReleaseType::Safe), + eq(&ReleaseType::Autonomi), eq(specific_version.clone()), always(), // Varies per platform eq(&ArchiveType::TarGz), @@ -671,19 +669,19 @@ mod test { .times(1) .returning(move |_, _, _, _, _, _| { Ok(PathBuf::from(format!( - "/tmp/safe-{}-x86_64-unknown-linux-musl.tar.gz", + "/tmp/autonomi-{}-x86_64-unknown-linux-musl.tar.gz", specific_version_clone ))) }) .in_sequence(&mut seq); let mut install_dir_path_clone = install_dir.to_path_buf().clone(); - install_dir_path_clone.push("safe"); + install_dir_path_clone.push("autonomi"); mock_release_repo .expect_extract_release_archive() .with( eq(PathBuf::from(format!( - "/tmp/safe-{}-x86_64-unknown-linux-musl.tar.gz", + "/tmp/autonomi-{}-x86_64-unknown-linux-musl.tar.gz", specific_version.clone() ))), always(), // We will extract to a temporary directory @@ -702,7 +700,7 @@ mod test { .await?; assert_eq!(version, specific_version); - assert_eq!(bin_path, installed_safe.to_path_buf()); + assert_eq!(bin_path, installed_autonomi.to_path_buf()); Ok(()) } @@ -783,7 +781,7 @@ mod test { async fn save_should_write_new_settings_when_settings_file_does_not_exist() -> Result<()> { let tmp_data_path = assert_fs::TempDir::new()?; let settings_file = tmp_data_path.child("safeup.json"); - let safe_bin_file = tmp_data_path.child(SAFE_BIN_NAME); + let safe_bin_file = tmp_data_path.child(AUTONOMI_BIN_NAME); safe_bin_file.write_binary(b"fake safe code")?; let safenode_bin_file = tmp_data_path.child("safenode"); safenode_bin_file.write_binary(b"fake safenode code")?; @@ -793,8 +791,8 @@ mod test { testnet_bin_file.write_binary(b"fake testnet code")?; let settings = Settings { - safe_path: Some(safe_bin_file.to_path_buf()), - safe_version: Some(Version::new(0, 75, 1)), + autonomi_path: Some(safe_bin_file.to_path_buf()), + autonomi_version: Some(Version::new(0, 75, 1)), safenode_path: Some(safenode_bin_file.to_path_buf()), safenode_version: Some(Version::new(0, 75, 2)), safenode_manager_path: Some(safenode_manager_bin_file.to_path_buf()), @@ -805,8 +803,8 @@ mod test { settings_file.assert(predicates::path::is_file()); let settings = Settings::read(&settings_file.to_path_buf())?; - assert_eq!(settings.safe_path, Some(safe_bin_file.to_path_buf())); - assert_eq!(settings.safe_version, Some(Version::new(0, 75, 1))); + assert_eq!(settings.autonomi_path, Some(safe_bin_file.to_path_buf())); + assert_eq!(settings.autonomi_version, Some(Version::new(0, 75, 1))); assert_eq!( settings.safenode_path, Some(safenode_bin_file.to_path_buf()) @@ -832,7 +830,7 @@ mod test { .join("dirs") .join("safeup.json"), ); - let safe_bin_file = tmp_data_path.child(SAFE_BIN_NAME); + let safe_bin_file = tmp_data_path.child(AUTONOMI_BIN_NAME); safe_bin_file.write_binary(b"fake safe code")?; let safenode_bin_file = tmp_data_path.child("safenode"); safenode_bin_file.write_binary(b"fake safenode code")?; @@ -842,8 +840,8 @@ mod test { testnet_bin_file.write_binary(b"fake testnet code")?; let settings = Settings { - safe_path: Some(safe_bin_file.to_path_buf()), - safe_version: Some(Version::new(0, 75, 1)), + autonomi_path: Some(safe_bin_file.to_path_buf()), + autonomi_version: Some(Version::new(0, 75, 1)), safenode_path: Some(safenode_bin_file.to_path_buf()), safenode_version: Some(Version::new(0, 75, 2)), safenode_manager_path: Some(safenode_manager_bin_file.to_path_buf()), @@ -854,8 +852,8 @@ mod test { settings_file.assert(predicates::path::is_file()); let settings = Settings::read(&settings_file.to_path_buf())?; - assert_eq!(settings.safe_path, Some(safe_bin_file.to_path_buf())); - assert_eq!(settings.safe_version, Some(Version::new(0, 75, 1))); + assert_eq!(settings.autonomi_path, Some(safe_bin_file.to_path_buf())); + assert_eq!(settings.autonomi_version, Some(Version::new(0, 75, 1))); assert_eq!( settings.safenode_path, Some(safenode_bin_file.to_path_buf()) diff --git a/src/main.rs b/src/main.rs index a7ad6f0..9e2579a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,14 +29,14 @@ struct Cli { #[derive(Subcommand)] enum Commands { - /// Install the safe client binary. + /// Install the autonomi client binary. /// /// The location is platform specific: /// - Linux/macOS: $HOME/.local/bin - /// - Windows: C:\Users\\safe + /// - Windows: C:\Users\\autonomi /// /// On Linux/macOS, the Bash shell profile will be modified to add $HOME/.local/bin to the PATH - /// variable. On Windows, the user Path variable will be modified to add C:\Users\\safe. + /// variable. On Windows, the user Path variable will be modified to add C:\Users\\autonomi. #[clap(verbatim_doc_comment)] Client { /// Override the default installation path. @@ -57,10 +57,10 @@ enum Commands { /// /// The location is platform specific: /// - Linux/macOS: $HOME/.local/bin - /// - Windows: C:\Users\\safe + /// - Windows: C:\Users\\autonomi /// /// On Linux/macOS, the Bash shell profile will be modified to add $HOME/.local/bin to the PATH - /// variable. On Windows, the user Path variable will be modified to add C:\Users\\safe. + /// variable. On Windows, the user Path variable will be modified to add C:\Users\\autonomi. #[clap(verbatim_doc_comment)] Node { /// Override the default installation path. @@ -81,10 +81,10 @@ enum Commands { /// /// The location is platform specific: /// - Linux/macOS: $HOME/.local/bin - /// - Windows: C:\Users\\safe + /// - Windows: C:\Users\\autonomi /// /// On Linux/macOS, the Bash shell profile will be modified to add $HOME/.local/bin to the PATH - /// variable. On Windows, the user Path variable will be modified to add C:\Users\\safe. + /// variable. On Windows, the user Path variable will be modified to add C:\Users\\autonomi. #[clap(verbatim_doc_comment)] NodeManager { /// Override the default installation path. @@ -120,7 +120,7 @@ async fn main() -> Result<()> { }) => { println!("**************************************"); println!("* *"); - println!("* Installing safe *"); + println!("* Installing autonomi *"); println!("* *"); println!("**************************************"); install::check_prerequisites()?; diff --git a/src/update.rs b/src/update.rs index 2e133f8..1e705c0 100644 --- a/src/update.rs +++ b/src/update.rs @@ -51,8 +51,8 @@ mod test { #[test] fn perform_upgrade_assessment_should_indicate_no_previous_installation() -> Result<()> { let settings = Settings { - safe_path: None, - safe_version: None, + autonomi_path: None, + autonomi_version: None, safenode_path: Some(PathBuf::from("/home/chris/.local/bin/safenode")), safenode_version: Some(Version::new(0, 83, 13)), safenode_manager_path: Some(PathBuf::from("/home/chris/.local/bin/safenode-manager")), @@ -63,8 +63,8 @@ mod test { assert_matches!(decision, UpdateAssessmentResult::NoPreviousInstallation); let settings = Settings { - safe_path: Some(PathBuf::from("/home/chris/.local/safe")), - safe_version: Some(Version::new(0, 78, 26)), + autonomi_path: Some(PathBuf::from("/home/user/.local/autonomi")), + autonomi_version: Some(Version::new(0, 78, 26)), safenode_path: None, safenode_version: None, safenode_manager_path: Some(PathBuf::from("/home/chris/.local/bin/safenode-manager")), @@ -75,8 +75,8 @@ mod test { assert_matches!(decision, UpdateAssessmentResult::NoPreviousInstallation); let settings = Settings { - safe_path: Some(PathBuf::from("/home/chris/.local/safe")), - safe_version: Some(Version::new(0, 78, 26)), + autonomi_path: Some(PathBuf::from("/home/user/.local/autonomi")), + autonomi_version: Some(Version::new(0, 78, 26)), safenode_path: Some(PathBuf::from("/home/chris/.local/bin/safenode")), safenode_version: Some(Version::new(0, 83, 13)), safenode_manager_path: None, @@ -92,8 +92,8 @@ mod test { #[test] fn perform_upgrade_assessment_should_indicate_we_are_at_latest_version() -> Result<()> { let settings = Settings { - safe_path: Some(PathBuf::from("/home/chris/.local/safe")), - safe_version: Some(Version::new(0, 78, 26)), + autonomi_path: Some(PathBuf::from("/home/user/.local/autonomi")), + autonomi_version: Some(Version::new(0, 78, 26)), safenode_path: Some(PathBuf::from("/home/chris/.local/bin/safenode")), safenode_version: Some(Version::new(0, 83, 13)), safenode_manager_path: Some(PathBuf::from("/home/chris/.local/bin/safenode-manager")), @@ -119,8 +119,8 @@ mod test { fn perform_upgrade_assessment_latest_version_is_less_than_current_should_return_error( ) -> Result<()> { let settings = Settings { - safe_path: Some(PathBuf::from("/home/chris/.local/safe")), - safe_version: Some(Version::new(0, 78, 26)), + autonomi_path: Some(PathBuf::from("/home/user/.local/autonomi")), + autonomi_version: Some(Version::new(0, 78, 26)), safenode_path: Some(PathBuf::from("/home/chris/.local/bin/safenode")), safenode_version: Some(Version::new(0, 83, 13)), safenode_manager_path: Some(PathBuf::from("/home/chris/.local/bin/safenode-manager")), @@ -164,8 +164,8 @@ mod test { fn perform_upgrade_assessment_should_perform_update_when_latest_patch_version_is_greater( ) -> Result<()> { let settings = Settings { - safe_path: Some(PathBuf::from("/home/chris/.local/safe")), - safe_version: Some(Version::new(0, 78, 26)), + autonomi_path: Some(PathBuf::from("/home/user/.local/autonomi")), + autonomi_version: Some(Version::new(0, 78, 26)), safenode_path: Some(PathBuf::from("/home/chris/.local/bin/safenode")), safenode_version: Some(Version::new(0, 83, 13)), safenode_manager_path: Some(PathBuf::from("/home/chris/.local/bin/safenode-manager")), @@ -191,8 +191,8 @@ mod test { fn perform_upgrade_assessment_should_perform_update_when_latest_minor_version_is_greater( ) -> Result<()> { let settings = Settings { - safe_path: Some(PathBuf::from("/home/chris/.local/safe")), - safe_version: Some(Version::new(0, 78, 26)), + autonomi_path: Some(PathBuf::from("/home/user/.local/autonomi")), + autonomi_version: Some(Version::new(0, 78, 26)), safenode_path: Some(PathBuf::from("/home/chris/.local/bin/safenode")), safenode_version: Some(Version::new(0, 83, 13)), safenode_manager_path: Some(PathBuf::from("/home/chris/.local/bin/safenode-manager")), @@ -218,8 +218,8 @@ mod test { fn perform_upgrade_assessment_should_perform_update_when_latest_major_version_is_greater( ) -> Result<()> { let settings = Settings { - safe_path: Some(PathBuf::from("/home/chris/.local/safe")), - safe_version: Some(Version::new(0, 78, 26)), + autonomi_path: Some(PathBuf::from("/home/user/.local/autonomi")), + autonomi_version: Some(Version::new(0, 78, 26)), safenode_path: Some(PathBuf::from("/home/chris/.local/bin/safenode")), safenode_version: Some(Version::new(0, 83, 13)), safenode_manager_path: Some(PathBuf::from("/home/chris/.local/bin/safenode-manager")),