From 9359c5dead03518d36d1d907eed648bc03973d38 Mon Sep 17 00:00:00 2001 From: Danil Date: Fri, 16 Aug 2024 18:35:19 +0200 Subject: [PATCH] Add comments Signed-off-by: Danil --- zk_toolbox/Cargo.toml | 2 +- zk_toolbox/crates/zk_supervisor/Cargo.toml | 2 +- zk_toolbox/crates/zk_supervisor/src/commands/fmt.rs | 9 ++++++--- zk_toolbox/crates/zk_supervisor/src/commands/lint.rs | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/zk_toolbox/Cargo.toml b/zk_toolbox/Cargo.toml index 6743a2f7484..ab850d82770 100644 --- a/zk_toolbox/Cargo.toml +++ b/zk_toolbox/Cargo.toml @@ -58,4 +58,4 @@ tokio = { version = "1.37", features = ["full"] } toml = "0.8.12" url = { version = "2.5.0", features = ["serde"] } xshell = "0.2.6" -clap-markdown = "0.1.4" \ No newline at end of file +clap-markdown = "0.1.4" diff --git a/zk_toolbox/crates/zk_supervisor/Cargo.toml b/zk_toolbox/crates/zk_supervisor/Cargo.toml index 94c649afcc2..e1225de96d3 100644 --- a/zk_toolbox/crates/zk_supervisor/Cargo.toml +++ b/zk_toolbox/crates/zk_supervisor/Cargo.toml @@ -22,4 +22,4 @@ url.workspace = true xshell.workspace = true serde.workspace = true clap-markdown.workspace = true -futures.workspace = true \ No newline at end of file +futures.workspace = true diff --git a/zk_toolbox/crates/zk_supervisor/src/commands/fmt.rs b/zk_toolbox/crates/zk_supervisor/src/commands/fmt.rs index bc08153e48d..cc59d334da5 100644 --- a/zk_toolbox/crates/zk_supervisor/src/commands/fmt.rs +++ b/zk_toolbox/crates/zk_supervisor/src/commands/fmt.rs @@ -1,4 +1,4 @@ -use std::{env::args, ffi::OsStr, future, path::PathBuf, process::Command}; +use std::path::PathBuf; use clap::Parser; use common::{cmd::Cmd, logger, spinner::Spinner}; @@ -9,7 +9,6 @@ use crate::commands::lint::Extension; const CONFIG_PATH: &str = "etc/prettier-config"; async fn prettier(shell: Shell, extension: Extension, check: bool) -> anyhow::Result<()> { - let spinner = Spinner::new(&format!("Running prettier for: {extension}")); let mode = if check { "--check" } else { "--write" }; let glob = format!("**/*.{extension}"); let config = format!("etc/prettier-config/{extension}.js"); @@ -29,7 +28,6 @@ async fn prettier_contracts(shell: Shell, check: bool) -> anyhow::Result<()> { async fn rustfmt(shell: Shell, check: bool, link_to_code: PathBuf) -> anyhow::Result<()> { for dir in vec![".", "prover", "zk_toolbox"] { - logger::info(format!("Running rustfmt for: {dir}")); let _dir = shell.push_dir(link_to_code.join(dir)); let mut cmd = cmd!(shell, "cargo fmt -- --config imports_granularity=Crate --config group_imports=StdExternalCrate"); if check { @@ -74,6 +72,8 @@ pub async fn run(shell: Shell, args: FmtArgs) -> anyhow::Result<()> { let mut tasks = vec![]; let extensions: Vec<_> = vec![Extension::Js, Extension::Ts, Extension::Md, Extension::Sol]; + let spinner = + Spinner::new(&format!("Running prettier for: {extensions:?} and rustfmt")); for ext in extensions { tasks.push(tokio::spawn(prettier(shell.clone(), ext, args.check))); } @@ -89,14 +89,17 @@ pub async fn run(shell: Shell, args: FmtArgs) -> anyhow::Result<()> { logger::error(err) } }); + spinner.finish() } Some(Formatter::Prettier { mut extensions }) => { if extensions.is_empty() { extensions = vec![Extension::Js, Extension::Ts, Extension::Md, Extension::Sol]; } + let spinner = Spinner::new(&format!("Running prettier for: {extensions:?}")); for ext in extensions { prettier(shell.clone(), ext, args.check).await? } + spinner.finish() } Some(Formatter::Rustfmt) => { run_all_rust_formatters(shell.clone(), args.check, ".".into()).await? diff --git a/zk_toolbox/crates/zk_supervisor/src/commands/lint.rs b/zk_toolbox/crates/zk_supervisor/src/commands/lint.rs index f8fb15bf34e..27c197821e5 100644 --- a/zk_toolbox/crates/zk_supervisor/src/commands/lint.rs +++ b/zk_toolbox/crates/zk_supervisor/src/commands/lint.rs @@ -9,7 +9,7 @@ use crate::messages::{ MSG_LINT_CONFIG_PATH_ERR, MSG_RUNNING_CONTRACTS_LINTER_SPINNER, }; -pub const IGNORED_DIRS: [&str; 18] = [ +const IGNORED_DIRS: [&str; 18] = [ "target", "node_modules", "volumes", @@ -31,7 +31,7 @@ pub const IGNORED_DIRS: [&str; 18] = [ "contracts/l1-contracts/lib", ]; -pub const IGNORED_FILES: [&str; 4] = [ +const IGNORED_FILES: [&str; 4] = [ "KeysWithPlonkVerifier.sol", "TokenInit.sol", ".tslintrc.js",