diff --git a/crates/turborepo-lib/src/cli/mod.rs b/crates/turborepo-lib/src/cli/mod.rs index f9a2473ab352a..b1c45eb5720b9 100644 --- a/crates/turborepo-lib/src/cli/mod.rs +++ b/crates/turborepo-lib/src/cli/mod.rs @@ -8,7 +8,7 @@ use clap::{ }; use clap_complete::{generate, Shell}; pub use error::Error; -use serde::{Deserialize, Serialize}; +use serde::Serialize; use tracing::{debug, error}; use turbopath::AbsoluteSystemPathBuf; use turborepo_api_client::AnonAPIClient; @@ -45,10 +45,8 @@ const DEFAULT_NUM_WORKERS: u32 = 10; const SUPPORTED_GRAPH_FILE_EXTENSIONS: [&str; 8] = ["svg", "png", "jpg", "pdf", "json", "html", "mermaid", "dot"]; -#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, ValueEnum, Deserializable)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum, Deserializable, Serialize)] pub enum OutputLogsMode { - // biome also obeys serde rename directives, - // so the `Deserializable` derive will work properly here #[serde(rename = "full")] Full, #[serde(rename = "none")] @@ -113,7 +111,7 @@ impl LogOrder { } } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, ValueEnum)] +#[derive(Copy, Clone, Debug, PartialEq, ValueEnum)] pub enum DryRunMode { Text, Json, @@ -145,7 +143,7 @@ impl fmt::Display for EnvMode { } } -#[derive(Parser, Clone, Default, Debug, PartialEq, Serialize)] +#[derive(Parser, Clone, Default, Debug, PartialEq)] #[clap(author, about = "The build system that makes ship happen", long_about = None)] #[clap(disable_help_subcommand = true)] #[clap(disable_version_flag = true)] @@ -153,16 +151,13 @@ impl fmt::Display for EnvMode { #[command(name = "turbo")] pub struct Args { #[clap(long, global = true)] - #[serde(skip)] pub version: bool, #[clap(long, global = true)] /// Skip any attempts to infer which version of Turbo the project is /// configured to use - #[serde(skip)] pub skip_infer: bool, /// Disable the turbo update notification #[clap(long, global = true)] - #[serde(skip)] pub no_update_notifier: bool, /// Override the endpoint for API calls #[clap(long, global = true, value_parser)] @@ -203,12 +198,10 @@ pub struct Args { pub verbosity: Verbosity, /// Force a check for a new version of turbo #[clap(long, global = true, hide = true)] - #[serde(skip)] pub check_for_update: bool, #[clap(long = "__test-run", global = true, hide = true)] pub test_run: bool, #[clap(flatten, next_help_heading = "Run Arguments")] - #[serde(skip)] pub run_args: Option, // This should be inside `RunArgs` but clap currently has a bug // around nested flattened optional args: https://github.com/clap-rs/clap/issues/4697 @@ -218,8 +211,7 @@ pub struct Args { pub command: Option, } -#[derive(Debug, Parser, Serialize, Clone, Copy, PartialEq, Eq, Default)] -#[serde(into = "u8")] +#[derive(Debug, Parser, Clone, Copy, PartialEq, Eq, Default)] pub struct Verbosity { #[clap( long = "verbosity", @@ -246,8 +238,7 @@ impl From for u8 { } } -#[derive(Subcommand, Copy, Clone, Debug, Serialize, PartialEq)] -#[serde(tag = "command")] +#[derive(Subcommand, Copy, Clone, Debug, PartialEq)] pub enum DaemonCommand { /// Restarts the turbo daemon Restart, @@ -272,8 +263,7 @@ pub enum DaemonCommand { Logs, } -#[derive(Subcommand, Copy, Clone, Debug, Serialize, PartialEq)] -#[serde(tag = "command")] +#[derive(Subcommand, Copy, Clone, Debug, PartialEq)] pub enum TelemetryCommand { /// Enables anonymous telemetry Enable, @@ -283,7 +273,7 @@ pub enum TelemetryCommand { Status, } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, ValueEnum)] +#[derive(Copy, Clone, Debug, PartialEq, ValueEnum)] pub enum LinkTarget { RemoteCache, Spaces, @@ -434,14 +424,11 @@ impl Args { /// Defines the subcommands for CLI. NOTE: If we change the commands in Go, /// we must change these as well to avoid accidentally passing the /// --single-package flag into non-build commands. -#[derive(Subcommand, Clone, Debug, Serialize, PartialEq)] +#[derive(Subcommand, Clone, Debug, PartialEq)] pub enum Command { - // NOTE: Empty variants still have an empty struct attached so that serde serializes - // them as `{ "Bin": {} }` instead of as `"Bin"`. /// Get the path to the Turbo binary - Bin {}, + Bin, /// Generate the autocompletion script for the specified shell - #[serde(skip)] Completion { shell: Shell, }, @@ -451,13 +438,11 @@ pub enum Command { #[clap(long, default_value_t = String::from("4h0m0s"))] idle_time: String, #[clap(subcommand)] - #[serde(flatten)] command: Option, }, /// Generate a new app / package #[clap(aliases = ["g", "gen"])] Generate { - #[serde(skip)] #[clap(long, default_value_t = String::from("latest"), hide = true)] tag: String, /// The name of the generator to run @@ -474,13 +459,11 @@ pub enum Command { args: Vec, #[clap(subcommand)] - #[serde(skip)] command: Option>, }, /// Enable or disable anonymous telemetry Telemetry { #[clap(subcommand)] - #[serde(flatten)] command: Option, }, /// Turbo your monorepo by running a number of 'repo lints' to @@ -594,7 +577,7 @@ pub struct GenerateWorkspaceArgs { pub show_all_dependencies: bool, } -#[derive(Parser, Clone, Debug, Default, Serialize, PartialEq)] +#[derive(Parser, Clone, Debug, Default, PartialEq, Serialize)] pub struct GeneratorCustomArgs { /// The name of the generator to run generator_name: Option, @@ -610,7 +593,7 @@ pub struct GeneratorCustomArgs { args: Vec, } -#[derive(Subcommand, Clone, Debug, Serialize, PartialEq)] +#[derive(Subcommand, Clone, Debug, PartialEq)] pub enum GenerateCommand { /// Add a new package or app to your project #[clap(name = "workspace", alias = "w")] @@ -645,7 +628,7 @@ fn path_non_empty(s: &str) -> Result { } /// Arguments used in run and watch -#[derive(Parser, Clone, Debug, Default, Serialize, PartialEq)] +#[derive(Parser, Clone, Debug, Default, PartialEq)] #[command(groups = [ ArgGroup::new("scope-filter-group").multiple(true).required(false), ])] @@ -773,7 +756,7 @@ impl ExecutionArgs { } } -#[derive(Parser, Clone, Debug, Serialize, PartialEq)] +#[derive(Parser, Clone, Debug, PartialEq)] #[command(groups = [ ArgGroup::new("daemon-group").multiple(false).required(false), ])] @@ -815,12 +798,10 @@ pub struct RunArgs { pub profile: Option, /// File to write turbo's performance profile output into. /// All identifying data omitted from the profile. - #[serde(skip)] #[clap(long, value_parser=NonEmptyStringValueParser::new(), conflicts_with = "profile")] pub anon_profile: Option, /// Treat remote cache as read only #[clap(long, env = "TURBO_REMOTE_CACHE_READ_ONLY", value_name = "BOOL", action = ArgAction::Set, default_value = "false", default_missing_value = "true", num_args = 0..=1)] - #[serde(skip)] pub remote_cache_read_only: bool, /// Generate a summary of the turbo run #[clap(long, env = "TURBO_RUN_SUMMARY", default_missing_value = "true")] @@ -1070,7 +1051,7 @@ pub async fn run( cli_args.track(&root_telemetry); let cli_result = match cli_args.command.as_ref().unwrap() { - Command::Bin { .. } => { + Command::Bin => { CommandEventBuilder::new("bin") .with_parent(&root_telemetry) .track_call(); @@ -1357,11 +1338,7 @@ mod test { } } - use anyhow::Result; - - use crate::cli::{ - Args, Command, DryRunMode, EnvMode, LogOrder, LogPrefix, OutputLogsMode, Verbosity, - }; + use crate::cli::{Args, Command, DryRunMode, EnvMode, LogOrder, LogPrefix, OutputLogsMode}; #[test_case::test_case( &["turbo", "run", "build"], @@ -2092,15 +2069,6 @@ mod test { assert_eq!(Args::try_parse_from(args).unwrap(), expected); } - fn test_serde() { - // Test that ouput-logs is not serialized by default - assert_eq!( - serde_json::to_string(&Args::try_parse_from(["turbo", "run", "build"]).unwrap()) - .unwrap() - .contains("\"output_logs\":null"), - true - ); - } #[test_case::test_case( &["turbo", "run", "build", "--daemon", "--no-daemon"], "cannot be used with '--no-daemon'" ; @@ -2437,31 +2405,6 @@ mod test { assert!(Args::try_parse_from(["turbo", "prune", "foo", "--scope", "bar"]).is_err(),); } - #[test] - fn test_verbosity_serialization() -> Result<(), serde_json::Error> { - assert_eq!( - serde_json::to_string(&Verbosity { - verbosity: None, - v: 0 - })?, - "0" - ); - assert_eq!( - serde_json::to_string(&Verbosity { - verbosity: Some(3), - v: 0 - })?, - "3" - ); - assert_eq!( - serde_json::to_string(&Verbosity { - verbosity: None, - v: 3 - })?, - "3" - ); - Ok(()) - } #[test] fn test_parse_gen() { let default_gen = Command::Generate { diff --git a/crates/turborepo-lib/src/process/mod.rs b/crates/turborepo-lib/src/process/mod.rs index 9708519596be6..0fdbc3efff594 100644 --- a/crates/turborepo-lib/src/process/mod.rs +++ b/crates/turborepo-lib/src/process/mod.rs @@ -144,9 +144,10 @@ impl ProcessManager { #[cfg(test)] mod test { + use std::time::Instant; + use futures::{stream::FuturesUnordered, StreamExt}; use test_case::test_case; - use time::Instant; use tokio::{join, time::sleep}; use tracing_test::traced_test; diff --git a/crates/turborepo-lib/src/task_graph/mod.rs b/crates/turborepo-lib/src/task_graph/mod.rs index 650adcfaf4519..e1042db9d87f9 100644 --- a/crates/turborepo-lib/src/task_graph/mod.rs +++ b/crates/turborepo-lib/src/task_graph/mod.rs @@ -39,7 +39,7 @@ impl TaskOutputs { } // Constructed from a RawTaskDefinition -#[derive(Debug, Deserialize, PartialEq, Clone, Eq)] +#[derive(Debug, PartialEq, Clone, Eq)] pub struct TaskDefinition { pub outputs: TaskOutputs, pub(crate) cache: bool, diff --git a/crates/turborepo-repository/src/package_manager/mod.rs b/crates/turborepo-repository/src/package_manager/mod.rs index b6b127bf81c7b..f22490083e667 100644 --- a/crates/turborepo-repository/src/package_manager/mod.rs +++ b/crates/turborepo-repository/src/package_manager/mod.rs @@ -595,10 +595,9 @@ impl PackageManager { #[cfg(test)] mod tests { - use std::{collections::HashSet, fs::File}; + use std::collections::HashSet; use pretty_assertions::assert_eq; - use tempfile::tempdir; use super::*;