diff --git a/crates/infra/cli/src/commands/check/mod.rs b/crates/infra/cli/src/commands/check/mod.rs index 28bdc27550..00b103d166 100644 --- a/crates/infra/cli/src/commands/check/mod.rs +++ b/crates/infra/cli/src/commands/check/mod.rs @@ -6,7 +6,6 @@ use infra_utils::terminal::Terminal; use rayon::iter::{ParallelBridge, ParallelIterator}; use strum::IntoEnumIterator; -use crate::toolchains::mkdocs::Mkdocs; use crate::toolchains::wasm::WasmPackage; use crate::utils::{ClapExtensions, OrderedCommand}; @@ -26,12 +25,8 @@ impl CheckController { enum CheckCommand { /// Run 'cargo check' for all crates, features, and targets. Cargo, - /// Run `cargo doc` to generate Rustdoc documentation and check for any broken links. - Rustdoc, /// Check NPM packages for any outdated codegen steps. Npm, - /// Check mkdocs documentation for any build issues or broken links. - Mkdocs, } impl OrderedCommand for CheckCommand { @@ -40,9 +35,7 @@ impl OrderedCommand for CheckCommand { match self { CheckCommand::Cargo => check_cargo(), - CheckCommand::Rustdoc => check_rustdoc(), CheckCommand::Npm => check_npm(), - CheckCommand::Mkdocs => check_mkdocs(), }; Ok(()) @@ -50,24 +43,11 @@ impl OrderedCommand for CheckCommand { } fn check_cargo() { - // 'cargo clippy' will run both 'cargo check', and 'clippy' lints: Command::new("cargo") - .arg("clippy") + .arg("check") .flag("--workspace") .flag("--all-features") .flag("--all-targets") - .flag("--no-deps") - .add_build_rustflags() - .run(); -} - -fn check_rustdoc() { - Command::new("cargo") - .arg("doc") - .flag("--workspace") - .flag("--all-features") - .flag("--no-deps") - .flag("--document-private-items") .add_build_rustflags() .run(); } @@ -77,7 +57,3 @@ fn check_npm() { .par_bridge() .for_each(|package| package.build().unwrap()); } - -fn check_mkdocs() { - Mkdocs::check(); -} diff --git a/crates/infra/cli/src/commands/lint/mod.rs b/crates/infra/cli/src/commands/lint/mod.rs index c78b08b7cd..26b9569e33 100644 --- a/crates/infra/cli/src/commands/lint/mod.rs +++ b/crates/infra/cli/src/commands/lint/mod.rs @@ -2,11 +2,13 @@ use std::path::Path; use anyhow::Result; use clap::{Parser, ValueEnum}; +use infra_utils::cargo::CargoWorkspaceCommands; use infra_utils::commands::Command; use infra_utils::github::GitHub; use infra_utils::paths::{FileWalker, PathExtensions}; use infra_utils::terminal::Terminal; +use crate::toolchains::mkdocs::Mkdocs; use crate::toolchains::pipenv::PipEnv; use crate::utils::{ClapExtensions, OrderedCommand}; @@ -24,6 +26,12 @@ impl LintController { #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] enum LintCommand { + /// Run `cargo clippy` to check for any Rust lints. + Clippy, + /// Run `cargo doc` to generate Rustdoc documentation and check for any broken links. + Rustdoc, + /// Check mkdocs documentation for any build issues or broken links. + Mkdocs, /// Check for spelling issues in Markdown files. Cspell, /// Format all non-Rust source files. @@ -49,6 +57,9 @@ impl OrderedCommand for LintCommand { Terminal::step(format!("lint {name}", name = self.clap_name())); match self { + LintCommand::Clippy => run_clippy(), + LintCommand::Rustdoc => run_rustdoc(), + LintCommand::Mkdocs => run_mkdocs(), LintCommand::Cspell => run_cspell(), LintCommand::Prettier => run_prettier(), LintCommand::MarkdownLinkCheck => run_markdown_link_check()?, @@ -64,6 +75,32 @@ impl OrderedCommand for LintCommand { } } +fn run_clippy() { + Command::new("cargo") + .arg("clippy") + .flag("--workspace") + .flag("--all-features") + .flag("--all-targets") + .flag("--no-deps") + .add_build_rustflags() + .run(); +} + +fn run_rustdoc() { + Command::new("cargo") + .arg("doc") + .flag("--workspace") + .flag("--all-features") + .flag("--no-deps") + .flag("--document-private-items") + .add_build_rustflags() + .run(); +} + +fn run_mkdocs() { + Mkdocs::check(); +} + fn run_cspell() { Command::new("cspell") .arg("lint")