From ec18ec71e735d2f5be19c1ffebcae02eb6a45ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=BCtt?= Date: Thu, 22 Dec 2022 11:29:39 +0100 Subject: [PATCH] PartialWapmConfig -> WasmerConfig --- lib/cli/src/commands/add.rs | 4 ++-- lib/cli/src/commands/init.rs | 4 ++-- lib/cli/src/commands/list.rs | 4 ++-- lib/cli/src/commands/login.rs | 4 ++-- lib/cli/src/commands/publish.rs | 10 +++++----- lib/cli/src/commands/whoami.rs | 4 ++-- lib/cli/src/package_source.rs | 10 +++++----- lib/registry/src/lib.rs | 4 ++-- lib/registry/src/login.rs | 6 +++--- lib/registry/src/package.rs | 6 +++--- lib/registry/src/publish.rs | 10 +++++----- 11 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/cli/src/commands/add.rs b/lib/cli/src/commands/add.rs index b95c472c8..885dc1f9b 100644 --- a/lib/cli/src/commands/add.rs +++ b/lib/cli/src/commands/add.rs @@ -77,8 +77,8 @@ impl Add { Some(r) => Ok(r.clone()), None => { let wasmer_dir = - PartialWapmConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("{e}"))?; - let cfg = PartialWapmConfig::from_file(&wasmer_dir) + WasmerConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("{e}"))?; + let cfg = WasmerConfig::from_file(&wasmer_dir) .map_err(Error::msg) .context("Unable to load WAPM's config file")?; Ok(cfg.registry.get_current_registry()) diff --git a/lib/cli/src/commands/init.rs b/lib/cli/src/commands/init.rs index d3e4e5203..ba641ec0c 100644 --- a/lib/cli/src/commands/init.rs +++ b/lib/cli/src/commands/init.rs @@ -4,7 +4,7 @@ use clap::Parser; use std::collections::HashMap; use std::path::Path; use std::path::PathBuf; -use wasmer_registry::PartialWapmConfig; +use wasmer_registry::WasmerConfig; static NOTE: &str = "# See more keys and definitions at https://docs.wasmer.io/ecosystem/wapm/manifest"; @@ -365,7 +365,7 @@ fn construct_manifest( .map(|p| &p.name) .unwrap_or(fallback_package_name) }); - let wasmer_dir = PartialWapmConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("{e}"))?; + let wasmer_dir = WasmerConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("{e}"))?; let namespace = namespace.or_else(|| { wasmer_registry::whoami(&wasmer_dir, None, None) .ok() diff --git a/lib/cli/src/commands/list.rs b/lib/cli/src/commands/list.rs index 34c494e88..770b4c4dd 100644 --- a/lib/cli/src/commands/list.rs +++ b/lib/cli/src/commands/list.rs @@ -1,5 +1,5 @@ use clap::Parser; -use wasmer_registry::PartialWapmConfig; +use wasmer_registry::WasmerConfig; /// Subcommand for listing packages #[derive(Debug, Copy, Clone, Parser)] @@ -9,7 +9,7 @@ impl List { /// execute [List] pub fn execute(&self) -> Result<(), anyhow::Error> { use prettytable::{format, row, Table}; - let wasmer_dir = PartialWapmConfig::get_wasmer_dir() + let wasmer_dir = WasmerConfig::get_wasmer_dir() .map_err(|e| anyhow::anyhow!("no wasmer dir: {e}"))?; let rows = wasmer_registry::get_all_local_packages(&wasmer_dir) .into_iter() diff --git a/lib/cli/src/commands/login.rs b/lib/cli/src/commands/login.rs index f23694dc3..25a42fe27 100644 --- a/lib/cli/src/commands/login.rs +++ b/lib/cli/src/commands/login.rs @@ -1,7 +1,7 @@ use clap::Parser; #[cfg(not(test))] use dialoguer::Input; -use wasmer_registry::PartialWapmConfig; +use wasmer_registry::WasmerConfig; /// Subcommand for listing packages #[derive(Debug, Clone, Parser)] @@ -52,7 +52,7 @@ impl Login { /// execute [List] pub fn execute(&self) -> Result<(), anyhow::Error> { let token = self.get_token_or_ask_user()?; - let wasmer_dir = PartialWapmConfig::get_wasmer_dir() + let wasmer_dir = WasmerConfig::get_wasmer_dir() .map_err(|e| anyhow::anyhow!("no wasmer dir: {e}"))?; match wasmer_registry::login::login_and_save_token(&wasmer_dir, &self.registry, &token)? { Some(s) => println!("Login for WAPM user {:?} saved", s), diff --git a/lib/cli/src/commands/publish.rs b/lib/cli/src/commands/publish.rs index e3a825be7..f4b038d3e 100644 --- a/lib/cli/src/commands/publish.rs +++ b/lib/cli/src/commands/publish.rs @@ -9,7 +9,7 @@ use tar::Builder; use thiserror::Error; use time::{self, OffsetDateTime}; use wasmer_registry::publish::SignArchiveResult; -use wasmer_registry::{PartialWapmConfig, PACKAGE_TOML_FALLBACK_NAME}; +use wasmer_registry::{WasmerConfig, PACKAGE_TOML_FALLBACK_NAME}; const MIGRATIONS: &[(i32, &str)] = &[ (0, include_str!("../../sql/migrations/0000.sql")), @@ -94,9 +94,9 @@ impl Publish { let registry = match self.registry.as_deref() { Some(s) => wasmer_registry::format_graphql(s), None => { - let wasmer_dir = PartialWapmConfig::get_wasmer_dir() + let wasmer_dir = WasmerConfig::get_wasmer_dir() .map_err(|e| anyhow::anyhow!("no wasmer dir: {e}"))?; - let config = PartialWapmConfig::from_file(&wasmer_dir) + let config = WasmerConfig::from_file(&wasmer_dir) .map_err(|e| anyhow::anyhow!("could not load config {e}"))?; config.registry.get_current_registry() } @@ -325,8 +325,8 @@ pub fn sign_compressed_archive( /// Opens an exclusive read/write connection to the database, creating it if it does not exist pub fn open_db() -> anyhow::Result { let wasmer_dir = - PartialWapmConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("no wasmer dir: {e}"))?; - let db_path = PartialWapmConfig::get_database_file_path(&wasmer_dir); + WasmerConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("no wasmer dir: {e}"))?; + let db_path = WasmerConfig::get_database_file_path(&wasmer_dir); let mut conn = Connection::open_with_flags( db_path, OpenFlags::SQLITE_OPEN_CREATE diff --git a/lib/cli/src/commands/whoami.rs b/lib/cli/src/commands/whoami.rs index a0fbedd3a..c72f9ac76 100644 --- a/lib/cli/src/commands/whoami.rs +++ b/lib/cli/src/commands/whoami.rs @@ -1,5 +1,5 @@ use clap::Parser; -use wasmer_registry::PartialWapmConfig; +use wasmer_registry::WasmerConfig; #[derive(Debug, Parser)] /// The options for the `wasmer whoami` subcommand @@ -12,7 +12,7 @@ pub struct Whoami { impl Whoami { /// Execute `wasmer whoami` pub fn execute(&self) -> Result<(), anyhow::Error> { - let wasmer_dir = PartialWapmConfig::get_wasmer_dir() + let wasmer_dir = WasmerConfig::get_wasmer_dir() .map_err(|e| anyhow::anyhow!("no wasmer dir: {e}"))?; let (registry, username) = wasmer_registry::whoami(&wasmer_dir, self.registry.as_deref(), None)?; diff --git a/lib/cli/src/package_source.rs b/lib/cli/src/package_source.rs index d3ffc1166..3e1c854fb 100644 --- a/lib/cli/src/package_source.rs +++ b/lib/cli/src/package_source.rs @@ -4,7 +4,7 @@ use anyhow::Context; use std::path::{Path, PathBuf}; use std::str::FromStr; use url::Url; -use wasmer_registry::PartialWapmConfig; +use wasmer_registry::WasmerConfig; /// Source of a package #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] @@ -62,7 +62,7 @@ impl PackageSource { }; } Self::Url(u) => { - let wasmer_dir = PartialWapmConfig::get_wasmer_dir() + let wasmer_dir = WasmerConfig::get_wasmer_dir() .map_err(|e| anyhow::anyhow!("no wasmer dir: {e}"))?; if let Some(path) = wasmer_registry::Package::is_url_already_installed(u, &wasmer_dir) @@ -73,7 +73,7 @@ impl PackageSource { } } Self::Package(p) => { - let wasmer_dir = PartialWapmConfig::get_wasmer_dir() + let wasmer_dir = WasmerConfig::get_wasmer_dir() .map_err(|e| anyhow::anyhow!("no wasmer dir: {e}"))?; let package_path = Path::new(&p.file()).to_path_buf(); if package_path.exists() { @@ -81,7 +81,7 @@ impl PackageSource { } else if let Some(path) = p.already_installed(&wasmer_dir) { return Ok(path); } else { - let config = PartialWapmConfig::from_file(&wasmer_dir) + let config = WasmerConfig::from_file(&wasmer_dir) .map_err(|e| anyhow::anyhow!("error loading wasmer config file: {e}"))?; p.url(&config.registry.get_current_registry())? } @@ -94,7 +94,7 @@ impl PackageSource { String::new() }; - let wasmer_dir = PartialWapmConfig::get_wasmer_dir() + let wasmer_dir = WasmerConfig::get_wasmer_dir() .map_err(|e| anyhow::anyhow!("no wasmer dir: {e}"))?; let mut sp = start_spinner(format!("Installing package {url} ...")); let opt_path = wasmer_registry::install_package(&wasmer_dir, &url); diff --git a/lib/registry/src/lib.rs b/lib/registry/src/lib.rs index 6c8ae17d1..c4dc32ab3 100644 --- a/lib/registry/src/lib.rs +++ b/lib/registry/src/lib.rs @@ -576,7 +576,7 @@ pub fn whoami( use crate::queries::{who_am_i_query, WhoAmIQuery}; use graphql_client::GraphQLQuery; - let config = PartialWapmConfig::from_file(wasmer_dir); + let config = WasmerConfig::from_file(wasmer_dir); let config = config .map_err(|e| anyhow::anyhow!("{e}")) @@ -626,7 +626,7 @@ pub fn test_if_registry_present(registry: &str) -> Result { pub fn get_all_available_registries(wasmer_dir: &Path) -> Result, String> { - let config = PartialWapmConfig::from_file(wasmer_dir)?; + let config = WasmerConfig::from_file(wasmer_dir)?; let mut registries = Vec::new(); for login in config.registry.tokens { registries.push(format_graphql(&login.registry)); diff --git a/lib/registry/src/login.rs b/lib/registry/src/login.rs index 2aba0f05a..e112be4ba 100644 --- a/lib/registry/src/login.rs +++ b/lib/registry/src/login.rs @@ -1,5 +1,5 @@ use crate::config::{format_graphql, UpdateRegistry}; -use crate::PartialWapmConfig; +use crate::WasmerConfig; use std::path::Path; @@ -12,7 +12,7 @@ pub fn login_and_save_token( token: &str, ) -> Result, anyhow::Error> { let registry = format_graphql(registry); - let mut config = PartialWapmConfig::from_file(wasmer_dir) + let mut config = WasmerConfig::from_file(wasmer_dir) .map_err(|e| anyhow::anyhow!("config from file: {e}"))?; config.registry.set_current_registry(®istry); config.registry.set_login_token_for_registry( @@ -20,7 +20,7 @@ pub fn login_and_save_token( token, UpdateRegistry::Update, ); - let path = PartialWapmConfig::get_file_location(wasmer_dir); + let path = WasmerConfig::get_file_location(wasmer_dir); config.save(&path)?; crate::utils::get_username_registry_token(®istry, token) } diff --git a/lib/registry/src/package.rs b/lib/registry/src/package.rs index 9662e2a85..062800f7f 100644 --- a/lib/registry/src/package.rs +++ b/lib/registry/src/package.rs @@ -1,4 +1,4 @@ -use crate::PartialWapmConfig; +use crate::WasmerConfig; use regex::Regex; use std::path::{Path, PathBuf}; use std::{fmt, str::FromStr}; @@ -28,7 +28,7 @@ impl Package { /// Checks whether the package is already installed, if yes, returns the path to the root dir pub fn already_installed(&self, wasmer_dir: &Path) -> Option { let checkouts_dir = crate::get_checkouts_dir(wasmer_dir); - let config = PartialWapmConfig::from_file(wasmer_dir).ok()?; + let config = WasmerConfig::from_file(wasmer_dir).ok()?; let current_registry = config.registry.get_current_registry(); let hash = self.get_hash(¤t_registry); @@ -134,7 +134,7 @@ impl Package { /// Does not check whether the installation directory already exists. pub fn get_path(&self, wasmer_dir: &Path) -> Result { let checkouts_dir = crate::get_checkouts_dir(wasmer_dir); - let config = PartialWapmConfig::from_file(wasmer_dir) + let config = WasmerConfig::from_file(wasmer_dir) .map_err(|e| anyhow::anyhow!("could not load config {e}"))?; let hash = self.get_hash(&config.registry.get_current_registry()); diff --git a/lib/registry/src/publish.rs b/lib/registry/src/publish.rs index 612cd2ca7..ec5f5c5df 100644 --- a/lib/registry/src/publish.rs +++ b/lib/registry/src/publish.rs @@ -1,6 +1,6 @@ use crate::graphql::{execute_query_modifier_inner, get_signed_url, GetSignedUrl}; use crate::graphql::{publish_package_mutation_chunked, PublishPackageMutationChunked}; -use crate::{format_graphql, PartialWapmConfig}; +use crate::{format_graphql, WasmerConfig}; use console::{style, Emoji}; use graphql_client::GraphQLQuery; use indicatif::{ProgressBar, ProgressState, ProgressStyle}; @@ -40,9 +40,9 @@ pub fn try_chunked_uploading( Some(s) => format_graphql(s), None => { let wasmer_dir = - PartialWapmConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("{e}"))?; + WasmerConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("{e}"))?; - let config = PartialWapmConfig::from_file(&wasmer_dir); + let config = WasmerConfig::from_file(&wasmer_dir); config .map_err(|e| anyhow::anyhow!("{e}"))? @@ -55,9 +55,9 @@ pub fn try_chunked_uploading( Some(s) => s.to_string(), None => { let wasmer_dir = - PartialWapmConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("{e}"))?; + WasmerConfig::get_wasmer_dir().map_err(|e| anyhow::anyhow!("{e}"))?; - let config = PartialWapmConfig::from_file(&wasmer_dir); + let config = WasmerConfig::from_file(&wasmer_dir); config .map_err(|e| anyhow::anyhow!("{e}"))?