diff --git a/rust/src/chrome.rs b/rust/src/chrome.rs index 36cd958e951e9..4aaadd6f71bb0 100644 --- a/rust/src/chrome.rs +++ b/rust/src/chrome.rs @@ -16,15 +16,6 @@ // under the License. use crate::config::ManagerConfig; -use reqwest::Client; -use serde::{Deserialize, Serialize}; -use std::collections::HashMap; - -use anyhow::anyhow; -use anyhow::Error; -use std::option::Option; -use std::path::PathBuf; - use crate::config::ARCH::{ARM64, X32}; use crate::config::OS::{LINUX, MACOS, WINDOWS}; use crate::downloads::{parse_json_from_url, read_version_from_link}; @@ -38,6 +29,13 @@ use crate::{ OFFLINE_REQUEST_ERR_MSG, REG_VERSION_ARG, STABLE, UNAVAILABLE_DOWNLOAD_WITH_MIN_VERSION_ERR_MSG, }; +use anyhow::anyhow; +use anyhow::Error; +use reqwest::Client; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use std::option::Option; +use std::path::PathBuf; pub const CHROME_NAME: &str = "chrome"; pub const CHROMEDRIVER_NAME: &str = "chromedriver"; diff --git a/rust/src/config.rs b/rust/src/config.rs index ec4d65659e429..94febff1531b9 100644 --- a/rust/src/config.rs +++ b/rust/src/config.rs @@ -22,12 +22,11 @@ use crate::{ UNAME_COMMAND, }; use crate::{ARCH_AMD64, ARCH_ARM64, ARCH_X86, TTL_SEC, WMIC_COMMAND_OS}; +use anyhow::anyhow; +use anyhow::Error; use std::cell::RefCell; use std::env; use std::env::consts::OS; - -use anyhow::anyhow; -use anyhow::Error; use std::fs::read_to_string; use std::path::Path; use toml::Table; diff --git a/rust/src/downloads.rs b/rust/src/downloads.rs index d72f4be4b77c0..caa9252c4730b 100644 --- a/rust/src/downloads.rs +++ b/rust/src/downloads.rs @@ -15,21 +15,18 @@ // specific language governing permissions and limitations // under the License. +use crate::files::parse_version; +use crate::Logger; +use anyhow::anyhow; use anyhow::Error; use reqwest::{Client, StatusCode}; use serde::{Deserialize, Serialize}; use serde_json::Value; - -use anyhow::anyhow; use std::fs::File; use std::io::copy; use std::io::Cursor; - use tempfile::{Builder, TempDir}; -use crate::files::parse_version; -use crate::Logger; - #[tokio::main] pub async fn download_to_tmp_folder( http_client: &Client, diff --git a/rust/src/edge.rs b/rust/src/edge.rs index 388e664cd3ceb..0013e5e7c6836 100644 --- a/rust/src/edge.rs +++ b/rust/src/edge.rs @@ -16,13 +16,6 @@ // under the License. use crate::config::ManagerConfig; -use anyhow::Error; -use reqwest::Client; -use serde::{Deserialize, Serialize}; -use std::collections::HashMap; -use std::env; -use std::path::{Path, PathBuf}; - use crate::config::ARCH::{ARM64, X32}; use crate::config::OS::{LINUX, MACOS, WINDOWS}; use crate::downloads::{parse_json_from_url, read_version_from_link}; @@ -35,6 +28,12 @@ use crate::{ DASH_DASH_VERSION, DEV, ENV_PROGRAM_FILES_X86, NIGHTLY, OFFLINE_REQUEST_ERR_MSG, REG_VERSION_ARG, STABLE, }; +use anyhow::Error; +use reqwest::Client; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use std::env; +use std::path::{Path, PathBuf}; pub const EDGE_NAMES: &[&str] = &[ "edge", diff --git a/rust/src/files.rs b/rust/src/files.rs index 570e06f1004de..67b3e04c4ae37 100644 --- a/rust/src/files.rs +++ b/rust/src/files.rs @@ -15,31 +15,28 @@ // specific language governing permissions and limitations // under the License. +use crate::config::OS; +use crate::config::OS::WINDOWS; +use crate::{ + format_one_arg, format_three_args, format_two_args, run_shell_command_by_os, Command, Logger, + CP_VOLUME_COMMAND, HDIUTIL_ATTACH_COMMAND, HDIUTIL_DETACH_COMMAND, MACOS, + MSIEXEC_INSTALL_COMMAND, MV_PAYLOAD_COMMAND, MV_PAYLOAD_OLD_VERSIONS_COMMAND, PKGUTIL_COMMAND, +}; +use anyhow::anyhow; use anyhow::Error; +use bzip2::read::BzDecoder; +use directories::BaseDirs; +use flate2::read::GzDecoder; +use regex::Regex; use std::fs; use std::fs::File; use std::io; use std::io::{BufReader, Cursor, Read}; - -use anyhow::anyhow; -use bzip2::read::BzDecoder; use std::path::{Path, PathBuf}; - -use crate::config::OS; -use directories::BaseDirs; -use flate2::read::GzDecoder; -use regex::Regex; use tar::Archive; use tempfile::Builder; use zip::ZipArchive; -use crate::config::OS::WINDOWS; -use crate::{ - format_one_arg, format_three_args, format_two_args, run_shell_command_by_os, Command, Logger, - CP_VOLUME_COMMAND, HDIUTIL_ATTACH_COMMAND, HDIUTIL_DETACH_COMMAND, MACOS, - MSIEXEC_INSTALL_COMMAND, MV_PAYLOAD_COMMAND, MV_PAYLOAD_OLD_VERSIONS_COMMAND, PKGUTIL_COMMAND, -}; - pub const PARSE_ERROR: &str = "Wrong browser/driver version"; const CACHE_FOLDER: &str = ".cache/selenium"; const ZIP: &str = "zip"; diff --git a/rust/src/firefox.rs b/rust/src/firefox.rs index f66c4dbb0efcf..db2786568ab1a 100644 --- a/rust/src/firefox.rs +++ b/rust/src/firefox.rs @@ -17,13 +17,6 @@ // under the License. use crate::config::ManagerConfig; -use anyhow::Error; -use reqwest::Client; -use std::collections::HashMap; - -use anyhow::anyhow; -use std::path::PathBuf; - use crate::config::ARCH::{ARM64, X32}; use crate::config::OS::{LINUX, MACOS, WINDOWS}; use crate::downloads::{ @@ -37,6 +30,11 @@ use crate::{ create_http_client, format_three_args, format_two_args, Logger, SeleniumManager, BETA, DASH_VERSION, DEV, NIGHTLY, OFFLINE_REQUEST_ERR_MSG, REG_CURRENT_VERSION_ARG, STABLE, }; +use anyhow::anyhow; +use anyhow::Error; +use reqwest::Client; +use std::collections::HashMap; +use std::path::PathBuf; pub const FIREFOX_NAME: &str = "firefox"; pub const GECKODRIVER_NAME: &str = "geckodriver"; diff --git a/rust/src/grid.rs b/rust/src/grid.rs index a96f0e8e87754..42e664438fd53 100644 --- a/rust/src/grid.rs +++ b/rust/src/grid.rs @@ -16,24 +16,20 @@ // under the License. use crate::config::ManagerConfig; -use anyhow::Error; -use reqwest::Client; -use std::collections::HashMap; - -use anyhow::anyhow; -use std::path::PathBuf; - -use crate::files::BrowserPath; - use crate::downloads::parse_json_from_url; -use crate::{ - create_http_client, parse_version, Logger, SeleniumManager, OFFLINE_REQUEST_ERR_MSG, SNAPSHOT, -}; - +use crate::files::BrowserPath; use crate::metadata::{ create_driver_metadata, get_driver_version_from_metadata, get_metadata, write_metadata, }; use crate::mirror::{Assets, SeleniumRelease, MIRROR_URL}; +use crate::{ + create_http_client, parse_version, Logger, SeleniumManager, OFFLINE_REQUEST_ERR_MSG, SNAPSHOT, +}; +use anyhow::anyhow; +use anyhow::Error; +use reqwest::Client; +use std::collections::HashMap; +use std::path::PathBuf; pub const GRID_NAME: &str = "grid"; const GRID_RELEASE: &str = "selenium-server"; diff --git a/rust/src/iexplorer.rs b/rust/src/iexplorer.rs index e94c4a370169c..3e6364964f6ab 100644 --- a/rust/src/iexplorer.rs +++ b/rust/src/iexplorer.rs @@ -16,20 +16,17 @@ // under the License. use crate::config::ManagerConfig; -use anyhow::Error; -use reqwest::Client; -use std::collections::HashMap; - -use anyhow::anyhow; -use std::path::PathBuf; - -use crate::files::{compose_driver_path_in_cache, BrowserPath}; - use crate::downloads::parse_json_from_url; +use crate::files::{compose_driver_path_in_cache, BrowserPath}; use crate::{ create_http_client, parse_version, Logger, SeleniumManager, OFFLINE_REQUEST_ERR_MSG, REG_VERSION_ARG, STABLE, WINDOWS, }; +use anyhow::anyhow; +use anyhow::Error; +use reqwest::Client; +use std::collections::HashMap; +use std::path::PathBuf; use crate::metadata::{ create_driver_metadata, get_driver_version_from_metadata, get_metadata, write_metadata, diff --git a/rust/src/lib.rs b/rust/src/lib.rs index d059094e83d4c..10064de373e0f 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -16,39 +16,36 @@ // under the License. use crate::chrome::{ChromeManager, CHROMEDRIVER_NAME, CHROME_NAME}; +use crate::config::OS::{MACOS, WINDOWS}; +use crate::config::{str_to_os, ManagerConfig}; +use crate::downloads::download_to_tmp_folder; use crate::edge::{EdgeManager, EDGEDRIVER_NAME, EDGE_NAMES, WEBVIEW2_NAME}; use crate::files::{ create_parent_path_if_not_exists, create_path_if_not_exists, default_cache_folder, get_binary_extension, path_to_string, }; -use crate::firefox::{FirefoxManager, FIREFOX_NAME, GECKODRIVER_NAME}; -use crate::iexplorer::{IExplorerManager, IEDRIVER_NAME, IE_NAMES}; -use crate::safari::{SafariManager, SAFARIDRIVER_NAME, SAFARI_NAME}; -use std::{env, fs}; - -use crate::config::OS::{MACOS, WINDOWS}; -use crate::config::{str_to_os, ManagerConfig}; -use anyhow::Error; -use is_executable::IsExecutable; -use reqwest::{Client, Proxy}; -use std::collections::HashMap; - -use anyhow::anyhow; -use std::path::{Path, PathBuf}; -use std::time::Duration; -use walkdir::{DirEntry, WalkDir}; - -use crate::downloads::download_to_tmp_folder; use crate::files::{parse_version, uncompress, BrowserPath}; +use crate::firefox::{FirefoxManager, FIREFOX_NAME, GECKODRIVER_NAME}; use crate::grid::GRID_NAME; +use crate::iexplorer::{IExplorerManager, IEDRIVER_NAME, IE_NAMES}; use crate::logger::Logger; use crate::metadata::{ create_browser_metadata, get_browser_version_from_metadata, get_metadata, write_metadata, }; +use crate::safari::{SafariManager, SAFARIDRIVER_NAME, SAFARI_NAME}; use crate::safaritp::{SafariTPManager, SAFARITP_NAMES}; use crate::shell::{ run_shell_command, run_shell_command_by_os, run_shell_command_with_log, split_lines, Command, }; +use anyhow::anyhow; +use anyhow::Error; +use is_executable::IsExecutable; +use reqwest::{Client, Proxy}; +use std::collections::HashMap; +use std::path::{Path, PathBuf}; +use std::time::Duration; +use std::{env, fs}; +use walkdir::{DirEntry, WalkDir}; pub mod chrome; pub mod config; diff --git a/rust/src/main.rs b/rust/src/main.rs index d92de21a6c7da..f47cf50f7615d 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -15,26 +15,23 @@ // specific language governing permissions and limitations // under the License. -use std::backtrace::{Backtrace, BacktraceStatus}; -use std::path::Path; -use std::process::exit; - use anyhow::Error; use clap::Parser; - use exitcode::DATAERR; use exitcode::OK; use exitcode::UNAVAILABLE; use selenium_manager::config::{BooleanKey, StringKey, CACHE_PATH_KEY}; use selenium_manager::grid::GridManager; use selenium_manager::logger::{Logger, BROWSER_PATH, DRIVER_PATH}; +use selenium_manager::metadata::clear_metadata; use selenium_manager::REQUEST_TIMEOUT_SEC; use selenium_manager::TTL_SEC; use selenium_manager::{ clear_cache, get_manager_by_browser, get_manager_by_driver, SeleniumManager, }; - -use selenium_manager::metadata::clear_metadata; +use std::backtrace::{Backtrace, BacktraceStatus}; +use std::path::Path; +use std::process::exit; /// Automated driver management for Selenium #[derive(Parser, Debug)] diff --git a/rust/src/metadata.rs b/rust/src/metadata.rs index 90ebdeb8929fd..10b1d203f7f70 100644 --- a/rust/src/metadata.rs +++ b/rust/src/metadata.rs @@ -15,16 +15,13 @@ // specific language governing permissions and limitations // under the License. +use crate::Logger; +use serde::{Deserialize, Serialize}; use std::fs; use std::fs::File; - use std::path::{Path, PathBuf}; use std::time::{SystemTime, UNIX_EPOCH}; -use serde::{Deserialize, Serialize}; - -use crate::Logger; - const METADATA_FILE_OLD: &str = "selenium-manager.json"; const METADATA_FILE: &str = "se-metadata.json"; diff --git a/rust/src/safari.rs b/rust/src/safari.rs index fe65fdad5e122..f10420d8085c5 100644 --- a/rust/src/safari.rs +++ b/rust/src/safari.rs @@ -16,19 +16,16 @@ // under the License. use crate::config::ManagerConfig; +use crate::config::OS::MACOS; +use crate::files::BrowserPath; +use crate::{create_http_client, Logger, SeleniumManager, STABLE}; +use anyhow::anyhow; use anyhow::Error; use reqwest::Client; use std::collections::HashMap; - -use anyhow::anyhow; use std::path::PathBuf; use std::string::ToString; -use crate::files::BrowserPath; - -use crate::config::OS::MACOS; -use crate::{create_http_client, Logger, SeleniumManager, STABLE}; - pub const SAFARI_NAME: &str = "safari"; pub const SAFARIDRIVER_NAME: &str = "safaridriver"; const SAFARI_PATH: &str = r#"/Applications/Safari.app"#; diff --git a/rust/src/safaritp.rs b/rust/src/safaritp.rs index 4837a4a822309..34a6233eaca43 100644 --- a/rust/src/safaritp.rs +++ b/rust/src/safaritp.rs @@ -16,19 +16,16 @@ // under the License. use crate::config::ManagerConfig; +use crate::config::OS::MACOS; +use crate::files::BrowserPath; +use crate::{create_http_client, Logger, SeleniumManager, STABLE}; +use anyhow::anyhow; use anyhow::Error; use reqwest::Client; use std::collections::HashMap; - -use anyhow::anyhow; use std::path::PathBuf; use std::string::ToString; -use crate::files::BrowserPath; - -use crate::config::OS::MACOS; -use crate::{create_http_client, Logger, SeleniumManager, STABLE}; - pub const SAFARITP_NAMES: &[&str] = &[ "safaritp", "safari technology preview", diff --git a/rust/tests/browser_download_tests.rs b/rust/tests/browser_download_tests.rs index 404d6b29cb8ab..12875debb1fe1 100644 --- a/rust/tests/browser_download_tests.rs +++ b/rust/tests/browser_download_tests.rs @@ -15,11 +15,10 @@ // specific language governing permissions and limitations // under the License. -use assert_cmd::Command; -use std::env::consts::OS; - use crate::common::{assert_browser, assert_driver}; +use assert_cmd::Command; use rstest::rstest; +use std::env::consts::OS; mod common; diff --git a/rust/tests/browser_tests.rs b/rust/tests/browser_tests.rs index a1b01801c0fa6..80267998af10c 100644 --- a/rust/tests/browser_tests.rs +++ b/rust/tests/browser_tests.rs @@ -15,13 +15,12 @@ // specific language governing permissions and limitations // under the License. +use crate::common::{assert_driver, assert_output}; use assert_cmd::Command; use rstest::rstest; use selenium_manager::logger::JsonOutput; use std::env::consts::OS; -use crate::common::{assert_driver, assert_output}; - mod common; #[rstest] diff --git a/rust/tests/common.rs b/rust/tests/common.rs index 59eedc700ae0b..5e94aad6cd75a 100644 --- a/rust/tests/common.rs +++ b/rust/tests/common.rs @@ -17,15 +17,14 @@ use assert_cmd::assert::AssertResult; use assert_cmd::Command; -use std::borrow::BorrowMut; -use std::env::consts::OS; -use std::path::Path; - use is_executable::is_executable; use selenium_manager::files::path_to_string; use selenium_manager::logger::JsonOutput; use selenium_manager::shell; use selenium_manager::shell::run_shell_command_by_os; +use std::borrow::BorrowMut; +use std::env::consts::OS; +use std::path::Path; #[allow(dead_code)] pub fn assert_driver(cmd: &mut Command) { diff --git a/rust/tests/config_tests.rs b/rust/tests/config_tests.rs index 93180314e4e47..71c1b62af446e 100644 --- a/rust/tests/config_tests.rs +++ b/rust/tests/config_tests.rs @@ -15,13 +15,12 @@ // specific language governing permissions and limitations // under the License. +use crate::common::{assert_browser, assert_driver}; use assert_cmd::Command; +use rstest::rstest; use std::env; use std::fs::File; use std::io::{BufWriter, Write}; - -use crate::common::{assert_browser, assert_driver}; -use rstest::rstest; use tempfile::Builder; mod common; diff --git a/rust/tests/exec_driver_tests.rs b/rust/tests/exec_driver_tests.rs index c0d64f2360509..327bdcb2cb419 100644 --- a/rust/tests/exec_driver_tests.rs +++ b/rust/tests/exec_driver_tests.rs @@ -16,10 +16,9 @@ // under the License. use crate::common::{assert_browser, assert_driver, exec_driver}; -use std::env::consts::OS; - use assert_cmd::Command; use rstest::rstest; +use std::env::consts::OS; mod common; diff --git a/rust/tests/iexplorer_tests.rs b/rust/tests/iexplorer_tests.rs index 0af55872ea2df..b424845834d4d 100644 --- a/rust/tests/iexplorer_tests.rs +++ b/rust/tests/iexplorer_tests.rs @@ -16,7 +16,6 @@ // under the License. use assert_cmd::Command; - use rstest::rstest; #[rstest] diff --git a/rust/tests/output_tests.rs b/rust/tests/output_tests.rs index 762fccd3abd38..b8e7b90a428a9 100644 --- a/rust/tests/output_tests.rs +++ b/rust/tests/output_tests.rs @@ -16,9 +16,8 @@ // under the License. use assert_cmd::Command; -use std::path::Path; - use selenium_manager::logger::{JsonOutput, DRIVER_PATH}; +use std::path::Path; use std::str; #[test] diff --git a/rust/tests/stable_browser_tests.rs b/rust/tests/stable_browser_tests.rs index bf3708f89067f..37a8e21c8f0ee 100644 --- a/rust/tests/stable_browser_tests.rs +++ b/rust/tests/stable_browser_tests.rs @@ -15,9 +15,8 @@ // specific language governing permissions and limitations // under the License. -use assert_cmd::Command; - use crate::common::{assert_browser, assert_driver}; +use assert_cmd::Command; use rstest::rstest; mod common;