Skip to content

Commit d79cc4f

Browse files
chore(turborepo): remove unused code (#8428)
### Description We don't need these serde derives anymore since we're not serializing the args to pass to Go. ### Testing Instructions <!-- Give a quick description of steps to test your changes. -->
1 parent 943d6b5 commit d79cc4f

File tree

4 files changed

+20
-77
lines changed

4 files changed

+20
-77
lines changed

crates/turborepo-lib/src/cli/mod.rs

+16-73
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use clap::{
88
};
99
use clap_complete::{generate, Shell};
1010
pub use error::Error;
11-
use serde::{Deserialize, Serialize};
11+
use serde::Serialize;
1212
use tracing::{debug, error};
1313
use turbopath::AbsoluteSystemPathBuf;
1414
use turborepo_api_client::AnonAPIClient;
@@ -45,10 +45,8 @@ const DEFAULT_NUM_WORKERS: u32 = 10;
4545
const SUPPORTED_GRAPH_FILE_EXTENSIONS: [&str; 8] =
4646
["svg", "png", "jpg", "pdf", "json", "html", "mermaid", "dot"];
4747

48-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, ValueEnum, Deserializable)]
48+
#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum, Deserializable, Serialize)]
4949
pub enum OutputLogsMode {
50-
// biome also obeys serde rename directives,
51-
// so the `Deserializable` derive will work properly here
5250
#[serde(rename = "full")]
5351
Full,
5452
#[serde(rename = "none")]
@@ -113,7 +111,7 @@ impl LogOrder {
113111
}
114112
}
115113

116-
#[derive(Copy, Clone, Debug, PartialEq, Serialize, ValueEnum)]
114+
#[derive(Copy, Clone, Debug, PartialEq, ValueEnum)]
117115
pub enum DryRunMode {
118116
Text,
119117
Json,
@@ -145,24 +143,21 @@ impl fmt::Display for EnvMode {
145143
}
146144
}
147145

148-
#[derive(Parser, Clone, Default, Debug, PartialEq, Serialize)]
146+
#[derive(Parser, Clone, Default, Debug, PartialEq)]
149147
#[clap(author, about = "The build system that makes ship happen", long_about = None)]
150148
#[clap(disable_help_subcommand = true)]
151149
#[clap(disable_version_flag = true)]
152150
#[clap(arg_required_else_help = true)]
153151
#[command(name = "turbo")]
154152
pub struct Args {
155153
#[clap(long, global = true)]
156-
#[serde(skip)]
157154
pub version: bool,
158155
#[clap(long, global = true)]
159156
/// Skip any attempts to infer which version of Turbo the project is
160157
/// configured to use
161-
#[serde(skip)]
162158
pub skip_infer: bool,
163159
/// Disable the turbo update notification
164160
#[clap(long, global = true)]
165-
#[serde(skip)]
166161
pub no_update_notifier: bool,
167162
/// Override the endpoint for API calls
168163
#[clap(long, global = true, value_parser)]
@@ -203,12 +198,10 @@ pub struct Args {
203198
pub verbosity: Verbosity,
204199
/// Force a check for a new version of turbo
205200
#[clap(long, global = true, hide = true)]
206-
#[serde(skip)]
207201
pub check_for_update: bool,
208202
#[clap(long = "__test-run", global = true, hide = true)]
209203
pub test_run: bool,
210204
#[clap(flatten, next_help_heading = "Run Arguments")]
211-
#[serde(skip)]
212205
pub run_args: Option<RunArgs>,
213206
// This should be inside `RunArgs` but clap currently has a bug
214207
// around nested flattened optional args: https://github.com/clap-rs/clap/issues/4697
@@ -218,8 +211,7 @@ pub struct Args {
218211
pub command: Option<Command>,
219212
}
220213

221-
#[derive(Debug, Parser, Serialize, Clone, Copy, PartialEq, Eq, Default)]
222-
#[serde(into = "u8")]
214+
#[derive(Debug, Parser, Clone, Copy, PartialEq, Eq, Default)]
223215
pub struct Verbosity {
224216
#[clap(
225217
long = "verbosity",
@@ -246,8 +238,7 @@ impl From<Verbosity> for u8 {
246238
}
247239
}
248240

249-
#[derive(Subcommand, Copy, Clone, Debug, Serialize, PartialEq)]
250-
#[serde(tag = "command")]
241+
#[derive(Subcommand, Copy, Clone, Debug, PartialEq)]
251242
pub enum DaemonCommand {
252243
/// Restarts the turbo daemon
253244
Restart,
@@ -272,8 +263,7 @@ pub enum DaemonCommand {
272263
Logs,
273264
}
274265

275-
#[derive(Subcommand, Copy, Clone, Debug, Serialize, PartialEq)]
276-
#[serde(tag = "command")]
266+
#[derive(Subcommand, Copy, Clone, Debug, PartialEq)]
277267
pub enum TelemetryCommand {
278268
/// Enables anonymous telemetry
279269
Enable,
@@ -283,7 +273,7 @@ pub enum TelemetryCommand {
283273
Status,
284274
}
285275

286-
#[derive(Copy, Clone, Debug, PartialEq, Serialize, ValueEnum)]
276+
#[derive(Copy, Clone, Debug, PartialEq, ValueEnum)]
287277
pub enum LinkTarget {
288278
RemoteCache,
289279
Spaces,
@@ -434,14 +424,11 @@ impl Args {
434424
/// Defines the subcommands for CLI. NOTE: If we change the commands in Go,
435425
/// we must change these as well to avoid accidentally passing the
436426
/// --single-package flag into non-build commands.
437-
#[derive(Subcommand, Clone, Debug, Serialize, PartialEq)]
427+
#[derive(Subcommand, Clone, Debug, PartialEq)]
438428
pub enum Command {
439-
// NOTE: Empty variants still have an empty struct attached so that serde serializes
440-
// them as `{ "Bin": {} }` instead of as `"Bin"`.
441429
/// Get the path to the Turbo binary
442-
Bin {},
430+
Bin,
443431
/// Generate the autocompletion script for the specified shell
444-
#[serde(skip)]
445432
Completion {
446433
shell: Shell,
447434
},
@@ -451,13 +438,11 @@ pub enum Command {
451438
#[clap(long, default_value_t = String::from("4h0m0s"))]
452439
idle_time: String,
453440
#[clap(subcommand)]
454-
#[serde(flatten)]
455441
command: Option<DaemonCommand>,
456442
},
457443
/// Generate a new app / package
458444
#[clap(aliases = ["g", "gen"])]
459445
Generate {
460-
#[serde(skip)]
461446
#[clap(long, default_value_t = String::from("latest"), hide = true)]
462447
tag: String,
463448
/// The name of the generator to run
@@ -474,13 +459,11 @@ pub enum Command {
474459
args: Vec<String>,
475460

476461
#[clap(subcommand)]
477-
#[serde(skip)]
478462
command: Option<Box<GenerateCommand>>,
479463
},
480464
/// Enable or disable anonymous telemetry
481465
Telemetry {
482466
#[clap(subcommand)]
483-
#[serde(flatten)]
484467
command: Option<TelemetryCommand>,
485468
},
486469
/// Turbo your monorepo by running a number of 'repo lints' to
@@ -594,7 +577,7 @@ pub struct GenerateWorkspaceArgs {
594577
pub show_all_dependencies: bool,
595578
}
596579

597-
#[derive(Parser, Clone, Debug, Default, Serialize, PartialEq)]
580+
#[derive(Parser, Clone, Debug, Default, PartialEq, Serialize)]
598581
pub struct GeneratorCustomArgs {
599582
/// The name of the generator to run
600583
generator_name: Option<String>,
@@ -610,7 +593,7 @@ pub struct GeneratorCustomArgs {
610593
args: Vec<String>,
611594
}
612595

613-
#[derive(Subcommand, Clone, Debug, Serialize, PartialEq)]
596+
#[derive(Subcommand, Clone, Debug, PartialEq)]
614597
pub enum GenerateCommand {
615598
/// Add a new package or app to your project
616599
#[clap(name = "workspace", alias = "w")]
@@ -645,7 +628,7 @@ fn path_non_empty(s: &str) -> Result<Utf8PathBuf, String> {
645628
}
646629

647630
/// Arguments used in run and watch
648-
#[derive(Parser, Clone, Debug, Default, Serialize, PartialEq)]
631+
#[derive(Parser, Clone, Debug, Default, PartialEq)]
649632
#[command(groups = [
650633
ArgGroup::new("scope-filter-group").multiple(true).required(false),
651634
])]
@@ -773,7 +756,7 @@ impl ExecutionArgs {
773756
}
774757
}
775758

776-
#[derive(Parser, Clone, Debug, Serialize, PartialEq)]
759+
#[derive(Parser, Clone, Debug, PartialEq)]
777760
#[command(groups = [
778761
ArgGroup::new("daemon-group").multiple(false).required(false),
779762
])]
@@ -815,12 +798,10 @@ pub struct RunArgs {
815798
pub profile: Option<String>,
816799
/// File to write turbo's performance profile output into.
817800
/// All identifying data omitted from the profile.
818-
#[serde(skip)]
819801
#[clap(long, value_parser=NonEmptyStringValueParser::new(), conflicts_with = "profile")]
820802
pub anon_profile: Option<String>,
821803
/// Treat remote cache as read only
822804
#[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)]
823-
#[serde(skip)]
824805
pub remote_cache_read_only: bool,
825806
/// Generate a summary of the turbo run
826807
#[clap(long, env = "TURBO_RUN_SUMMARY", default_missing_value = "true")]
@@ -1070,7 +1051,7 @@ pub async fn run(
10701051
cli_args.track(&root_telemetry);
10711052

10721053
let cli_result = match cli_args.command.as_ref().unwrap() {
1073-
Command::Bin { .. } => {
1054+
Command::Bin => {
10741055
CommandEventBuilder::new("bin")
10751056
.with_parent(&root_telemetry)
10761057
.track_call();
@@ -1357,11 +1338,7 @@ mod test {
13571338
}
13581339
}
13591340

1360-
use anyhow::Result;
1361-
1362-
use crate::cli::{
1363-
Args, Command, DryRunMode, EnvMode, LogOrder, LogPrefix, OutputLogsMode, Verbosity,
1364-
};
1341+
use crate::cli::{Args, Command, DryRunMode, EnvMode, LogOrder, LogPrefix, OutputLogsMode};
13651342

13661343
#[test_case::test_case(
13671344
&["turbo", "run", "build"],
@@ -2092,15 +2069,6 @@ mod test {
20922069
assert_eq!(Args::try_parse_from(args).unwrap(), expected);
20932070
}
20942071

2095-
fn test_serde() {
2096-
// Test that ouput-logs is not serialized by default
2097-
assert_eq!(
2098-
serde_json::to_string(&Args::try_parse_from(["turbo", "run", "build"]).unwrap())
2099-
.unwrap()
2100-
.contains("\"output_logs\":null"),
2101-
true
2102-
);
2103-
}
21042072
#[test_case::test_case(
21052073
&["turbo", "run", "build", "--daemon", "--no-daemon"],
21062074
"cannot be used with '--no-daemon'" ;
@@ -2437,31 +2405,6 @@ mod test {
24372405
assert!(Args::try_parse_from(["turbo", "prune", "foo", "--scope", "bar"]).is_err(),);
24382406
}
24392407

2440-
#[test]
2441-
fn test_verbosity_serialization() -> Result<(), serde_json::Error> {
2442-
assert_eq!(
2443-
serde_json::to_string(&Verbosity {
2444-
verbosity: None,
2445-
v: 0
2446-
})?,
2447-
"0"
2448-
);
2449-
assert_eq!(
2450-
serde_json::to_string(&Verbosity {
2451-
verbosity: Some(3),
2452-
v: 0
2453-
})?,
2454-
"3"
2455-
);
2456-
assert_eq!(
2457-
serde_json::to_string(&Verbosity {
2458-
verbosity: None,
2459-
v: 3
2460-
})?,
2461-
"3"
2462-
);
2463-
Ok(())
2464-
}
24652408
#[test]
24662409
fn test_parse_gen() {
24672410
let default_gen = Command::Generate {

crates/turborepo-lib/src/process/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ impl ProcessManager {
144144

145145
#[cfg(test)]
146146
mod test {
147+
use std::time::Instant;
148+
147149
use futures::{stream::FuturesUnordered, StreamExt};
148150
use test_case::test_case;
149-
use time::Instant;
150151
use tokio::{join, time::sleep};
151152
use tracing_test::traced_test;
152153

crates/turborepo-lib/src/task_graph/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl TaskOutputs {
3939
}
4040

4141
// Constructed from a RawTaskDefinition
42-
#[derive(Debug, Deserialize, PartialEq, Clone, Eq)]
42+
#[derive(Debug, PartialEq, Clone, Eq)]
4343
pub struct TaskDefinition {
4444
pub outputs: TaskOutputs,
4545
pub(crate) cache: bool,

crates/turborepo-repository/src/package_manager/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,9 @@ impl PackageManager {
595595

596596
#[cfg(test)]
597597
mod tests {
598-
use std::{collections::HashSet, fs::File};
598+
use std::collections::HashSet;
599599

600600
use pretty_assertions::assert_eq;
601-
use tempfile::tempdir;
602601

603602
use super::*;
604603

0 commit comments

Comments
 (0)