From 1317bdf216cd37fdfe1a1ee23d5bd1534871aaf5 Mon Sep 17 00:00:00 2001 From: Danil Date: Thu, 23 May 2024 09:17:44 +0200 Subject: [PATCH] Remove slugify Signed-off-by: Danil --- zk_toolbox/Cargo.lock | 26 ------------------- zk_toolbox/Cargo.toml | 1 - zk_toolbox/crates/common/src/lib.rs | 2 ++ zk_toolbox/crates/common/src/slugify.rs | 3 +++ zk_toolbox/crates/zk_inception/Cargo.toml | 1 - .../src/commands/chain/args/create.rs | 5 ++-- .../src/commands/chain/args/genesis.rs | 7 +++-- .../src/commands/ecosystem/args/create.rs | 5 ++-- 8 files changed, 12 insertions(+), 38 deletions(-) create mode 100644 zk_toolbox/crates/common/src/slugify.rs diff --git a/zk_toolbox/Cargo.lock b/zk_toolbox/Cargo.lock index 7fe43a903330..2492caf89780 100644 --- a/zk_toolbox/Cargo.lock +++ b/zk_toolbox/Cargo.lock @@ -732,12 +732,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "deunicode" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" - [[package]] name = "diff" version = "0.1.13" @@ -2048,15 +2042,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "nanoid" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8" -dependencies = [ - "rand", -] - [[package]] name = "new_debug_unreachable" version = "1.0.4" @@ -3166,16 +3151,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "slugify-rs" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c88cdb6ea794da1dde6f267c3a363b2373ce24386b136828d66402a97ebdbff3" -dependencies = [ - "deunicode", - "nanoid", -] - [[package]] name = "smallvec" version = "1.13.1" @@ -4531,7 +4506,6 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "slugify-rs", "strum 0.26.2", "strum_macros 0.26.2", "thiserror", diff --git a/zk_toolbox/Cargo.toml b/zk_toolbox/Cargo.toml index b02dc81e47da..f2ade7a48294 100644 --- a/zk_toolbox/Cargo.toml +++ b/zk_toolbox/Cargo.toml @@ -40,5 +40,4 @@ toml = "0.8.12" url = { version = "2.5.0", features = ["serde"] } xshell = "0.2.6" futures = "0.3.30" -slugify-rs = "0.0.3" thiserror = "1.0.57" diff --git a/zk_toolbox/crates/common/src/lib.rs b/zk_toolbox/crates/common/src/lib.rs index a173d1acfbc8..349cd751c5f6 100644 --- a/zk_toolbox/crates/common/src/lib.rs +++ b/zk_toolbox/crates/common/src/lib.rs @@ -7,9 +7,11 @@ pub mod files; pub mod forge; mod prerequisites; mod prompt; +mod slugify; mod term; pub mod wallets; pub use prerequisites::check_prerequisites; pub use prompt::{init_prompt_theme, Prompt, PromptConfirm, PromptSelect}; +pub use slugify::slugify; pub use term::{logger, spinner}; diff --git a/zk_toolbox/crates/common/src/slugify.rs b/zk_toolbox/crates/common/src/slugify.rs new file mode 100644 index 000000000000..a934a56b5527 --- /dev/null +++ b/zk_toolbox/crates/common/src/slugify.rs @@ -0,0 +1,3 @@ +pub fn slugify(data: &str) -> String { + data.trim().replace(" ", "-") +} diff --git a/zk_toolbox/crates/zk_inception/Cargo.toml b/zk_toolbox/crates/zk_inception/Cargo.toml index e3a2f980e055..7c41e39fa8ea 100644 --- a/zk_toolbox/crates/zk_inception/Cargo.toml +++ b/zk_toolbox/crates/zk_inception/Cargo.toml @@ -27,5 +27,4 @@ strum_macros.workspace = true strum.workspace = true toml.workspace = true url.workspace = true -slugify-rs.workspace = true thiserror.workspace = true \ No newline at end of file diff --git a/zk_toolbox/crates/zk_inception/src/commands/chain/args/create.rs b/zk_toolbox/crates/zk_inception/src/commands/chain/args/create.rs index 4ea26cbaf696..6afb46cbfb60 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/chain/args/create.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/chain/args/create.rs @@ -1,10 +1,9 @@ use std::{path::PathBuf, str::FromStr}; use clap::Parser; -use common::{Prompt, PromptConfirm, PromptSelect}; +use common::{slugify, Prompt, PromptConfirm, PromptSelect}; use ethers::types::H160; use serde::{Deserialize, Serialize}; -use slugify_rs::slugify; use strum::IntoEnumIterator; use strum_macros::{Display, EnumIter}; @@ -43,7 +42,7 @@ impl ChainCreateArgs { let mut chain_name = self .chain_name .unwrap_or_else(|| Prompt::new("How do you want to name the chain?").ask()); - chain_name = slugify!(&chain_name); + chain_name = slugify(&chain_name); let chain_id = self.chain_id.unwrap_or_else(|| { Prompt::new("What's the chain id?") diff --git a/zk_toolbox/crates/zk_inception/src/commands/chain/args/genesis.rs b/zk_toolbox/crates/zk_inception/src/commands/chain/args/genesis.rs index e3c3a03af83a..b24956c70c12 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/chain/args/genesis.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/chain/args/genesis.rs @@ -1,7 +1,6 @@ use clap::Parser; -use common::Prompt; +use common::{slugify, Prompt}; use serde::{Deserialize, Serialize}; -use slugify_rs::slugify; use url::Url; use crate::{ @@ -48,7 +47,7 @@ impl GenesisArgs { .default(DATABASE_SERVER_URL) .ask() }); - let server_db_name = slugify!(&self.server_db_name.unwrap_or_else(|| { + let server_db_name = slugify(&self.server_db_name.unwrap_or_else(|| { Prompt::new(&format!( "Please provide server database name for chain {chain_name}" )) @@ -62,7 +61,7 @@ impl GenesisArgs { .default(DATABASE_PROVER_URL) .ask() }); - let prover_db_name = slugify!(&self.prover_db_name.unwrap_or_else(|| { + let prover_db_name = slugify(&self.prover_db_name.unwrap_or_else(|| { Prompt::new(&format!( "Please provide prover database name for chain {chain_name}" )) diff --git a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs index e31bdf8c9644..d5e20bc3881f 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs @@ -1,9 +1,8 @@ use std::path::PathBuf; use clap::Parser; -use common::{Prompt, PromptConfirm, PromptSelect}; +use common::{slugify, Prompt, PromptConfirm, PromptSelect}; use serde::{Deserialize, Serialize}; -use slugify_rs::slugify; use strum::IntoEnumIterator; use strum_macros::{Display, EnumIter}; use url::Url; @@ -37,7 +36,7 @@ impl EcosystemCreateArgs { let mut ecosystem_name = self .ecosystem_name .unwrap_or_else(|| Prompt::new("How do you want to name the ecosystem?").ask()); - ecosystem_name = slugify!(&ecosystem_name); + ecosystem_name = slugify(&ecosystem_name); let link_to_code = self.link_to_code.unwrap_or_else(|| { let link_to_code_selection = PromptSelect::new(