@@ -8,7 +8,7 @@ use clap::{
8
8
} ;
9
9
use clap_complete:: { generate, Shell } ;
10
10
pub use error:: Error ;
11
- use serde:: { Deserialize , Serialize } ;
11
+ use serde:: Serialize ;
12
12
use tracing:: { debug, error} ;
13
13
use turbopath:: AbsoluteSystemPathBuf ;
14
14
use turborepo_api_client:: AnonAPIClient ;
@@ -45,10 +45,8 @@ const DEFAULT_NUM_WORKERS: u32 = 10;
45
45
const SUPPORTED_GRAPH_FILE_EXTENSIONS : [ & str ; 8 ] =
46
46
[ "svg" , "png" , "jpg" , "pdf" , "json" , "html" , "mermaid" , "dot" ] ;
47
47
48
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Deserialize , Serialize , ValueEnum , Deserializable ) ]
48
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , ValueEnum , Deserializable , Serialize ) ]
49
49
pub enum OutputLogsMode {
50
- // biome also obeys serde rename directives,
51
- // so the `Deserializable` derive will work properly here
52
50
#[ serde( rename = "full" ) ]
53
51
Full ,
54
52
#[ serde( rename = "none" ) ]
@@ -113,7 +111,7 @@ impl LogOrder {
113
111
}
114
112
}
115
113
116
- #[ derive( Copy , Clone , Debug , PartialEq , Serialize , ValueEnum ) ]
114
+ #[ derive( Copy , Clone , Debug , PartialEq , ValueEnum ) ]
117
115
pub enum DryRunMode {
118
116
Text ,
119
117
Json ,
@@ -145,24 +143,21 @@ impl fmt::Display for EnvMode {
145
143
}
146
144
}
147
145
148
- #[ derive( Parser , Clone , Default , Debug , PartialEq , Serialize ) ]
146
+ #[ derive( Parser , Clone , Default , Debug , PartialEq ) ]
149
147
#[ clap( author, about = "The build system that makes ship happen" , long_about = None ) ]
150
148
#[ clap( disable_help_subcommand = true ) ]
151
149
#[ clap( disable_version_flag = true ) ]
152
150
#[ clap( arg_required_else_help = true ) ]
153
151
#[ command( name = "turbo" ) ]
154
152
pub struct Args {
155
153
#[ clap( long, global = true ) ]
156
- #[ serde( skip) ]
157
154
pub version : bool ,
158
155
#[ clap( long, global = true ) ]
159
156
/// Skip any attempts to infer which version of Turbo the project is
160
157
/// configured to use
161
- #[ serde( skip) ]
162
158
pub skip_infer : bool ,
163
159
/// Disable the turbo update notification
164
160
#[ clap( long, global = true ) ]
165
- #[ serde( skip) ]
166
161
pub no_update_notifier : bool ,
167
162
/// Override the endpoint for API calls
168
163
#[ clap( long, global = true , value_parser) ]
@@ -203,12 +198,10 @@ pub struct Args {
203
198
pub verbosity : Verbosity ,
204
199
/// Force a check for a new version of turbo
205
200
#[ clap( long, global = true , hide = true ) ]
206
- #[ serde( skip) ]
207
201
pub check_for_update : bool ,
208
202
#[ clap( long = "__test-run" , global = true , hide = true ) ]
209
203
pub test_run : bool ,
210
204
#[ clap( flatten, next_help_heading = "Run Arguments" ) ]
211
- #[ serde( skip) ]
212
205
pub run_args : Option < RunArgs > ,
213
206
// This should be inside `RunArgs` but clap currently has a bug
214
207
// around nested flattened optional args: https://github.com/clap-rs/clap/issues/4697
@@ -218,8 +211,7 @@ pub struct Args {
218
211
pub command : Option < Command > ,
219
212
}
220
213
221
- #[ derive( Debug , Parser , Serialize , Clone , Copy , PartialEq , Eq , Default ) ]
222
- #[ serde( into = "u8" ) ]
214
+ #[ derive( Debug , Parser , Clone , Copy , PartialEq , Eq , Default ) ]
223
215
pub struct Verbosity {
224
216
#[ clap(
225
217
long = "verbosity" ,
@@ -246,8 +238,7 @@ impl From<Verbosity> for u8 {
246
238
}
247
239
}
248
240
249
- #[ derive( Subcommand , Copy , Clone , Debug , Serialize , PartialEq ) ]
250
- #[ serde( tag = "command" ) ]
241
+ #[ derive( Subcommand , Copy , Clone , Debug , PartialEq ) ]
251
242
pub enum DaemonCommand {
252
243
/// Restarts the turbo daemon
253
244
Restart ,
@@ -272,8 +263,7 @@ pub enum DaemonCommand {
272
263
Logs ,
273
264
}
274
265
275
- #[ derive( Subcommand , Copy , Clone , Debug , Serialize , PartialEq ) ]
276
- #[ serde( tag = "command" ) ]
266
+ #[ derive( Subcommand , Copy , Clone , Debug , PartialEq ) ]
277
267
pub enum TelemetryCommand {
278
268
/// Enables anonymous telemetry
279
269
Enable ,
@@ -283,7 +273,7 @@ pub enum TelemetryCommand {
283
273
Status ,
284
274
}
285
275
286
- #[ derive( Copy , Clone , Debug , PartialEq , Serialize , ValueEnum ) ]
276
+ #[ derive( Copy , Clone , Debug , PartialEq , ValueEnum ) ]
287
277
pub enum LinkTarget {
288
278
RemoteCache ,
289
279
Spaces ,
@@ -434,14 +424,11 @@ impl Args {
434
424
/// Defines the subcommands for CLI. NOTE: If we change the commands in Go,
435
425
/// we must change these as well to avoid accidentally passing the
436
426
/// --single-package flag into non-build commands.
437
- #[ derive( Subcommand , Clone , Debug , Serialize , PartialEq ) ]
427
+ #[ derive( Subcommand , Clone , Debug , PartialEq ) ]
438
428
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"`.
441
429
/// Get the path to the Turbo binary
442
- Bin { } ,
430
+ Bin ,
443
431
/// Generate the autocompletion script for the specified shell
444
- #[ serde( skip) ]
445
432
Completion {
446
433
shell : Shell ,
447
434
} ,
@@ -451,13 +438,11 @@ pub enum Command {
451
438
#[ clap( long, default_value_t = String :: from( "4h0m0s" ) ) ]
452
439
idle_time : String ,
453
440
#[ clap( subcommand) ]
454
- #[ serde( flatten) ]
455
441
command : Option < DaemonCommand > ,
456
442
} ,
457
443
/// Generate a new app / package
458
444
#[ clap( aliases = [ "g" , "gen" ] ) ]
459
445
Generate {
460
- #[ serde( skip) ]
461
446
#[ clap( long, default_value_t = String :: from( "latest" ) , hide = true ) ]
462
447
tag : String ,
463
448
/// The name of the generator to run
@@ -474,13 +459,11 @@ pub enum Command {
474
459
args : Vec < String > ,
475
460
476
461
#[ clap( subcommand) ]
477
- #[ serde( skip) ]
478
462
command : Option < Box < GenerateCommand > > ,
479
463
} ,
480
464
/// Enable or disable anonymous telemetry
481
465
Telemetry {
482
466
#[ clap( subcommand) ]
483
- #[ serde( flatten) ]
484
467
command : Option < TelemetryCommand > ,
485
468
} ,
486
469
/// Turbo your monorepo by running a number of 'repo lints' to
@@ -594,7 +577,7 @@ pub struct GenerateWorkspaceArgs {
594
577
pub show_all_dependencies : bool ,
595
578
}
596
579
597
- #[ derive( Parser , Clone , Debug , Default , Serialize , PartialEq ) ]
580
+ #[ derive( Parser , Clone , Debug , Default , PartialEq , Serialize ) ]
598
581
pub struct GeneratorCustomArgs {
599
582
/// The name of the generator to run
600
583
generator_name : Option < String > ,
@@ -610,7 +593,7 @@ pub struct GeneratorCustomArgs {
610
593
args : Vec < String > ,
611
594
}
612
595
613
- #[ derive( Subcommand , Clone , Debug , Serialize , PartialEq ) ]
596
+ #[ derive( Subcommand , Clone , Debug , PartialEq ) ]
614
597
pub enum GenerateCommand {
615
598
/// Add a new package or app to your project
616
599
#[ clap( name = "workspace" , alias = "w" ) ]
@@ -645,7 +628,7 @@ fn path_non_empty(s: &str) -> Result<Utf8PathBuf, String> {
645
628
}
646
629
647
630
/// Arguments used in run and watch
648
- #[ derive( Parser , Clone , Debug , Default , Serialize , PartialEq ) ]
631
+ #[ derive( Parser , Clone , Debug , Default , PartialEq ) ]
649
632
#[ command( groups = [
650
633
ArgGroup :: new( "scope-filter-group" ) . multiple( true ) . required( false ) ,
651
634
] ) ]
@@ -773,7 +756,7 @@ impl ExecutionArgs {
773
756
}
774
757
}
775
758
776
- #[ derive( Parser , Clone , Debug , Serialize , PartialEq ) ]
759
+ #[ derive( Parser , Clone , Debug , PartialEq ) ]
777
760
#[ command( groups = [
778
761
ArgGroup :: new( "daemon-group" ) . multiple( false ) . required( false ) ,
779
762
] ) ]
@@ -815,12 +798,10 @@ pub struct RunArgs {
815
798
pub profile : Option < String > ,
816
799
/// File to write turbo's performance profile output into.
817
800
/// All identifying data omitted from the profile.
818
- #[ serde( skip) ]
819
801
#[ clap( long, value_parser=NonEmptyStringValueParser :: new( ) , conflicts_with = "profile" ) ]
820
802
pub anon_profile : Option < String > ,
821
803
/// Treat remote cache as read only
822
804
#[ 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) ]
824
805
pub remote_cache_read_only : bool ,
825
806
/// Generate a summary of the turbo run
826
807
#[ clap( long, env = "TURBO_RUN_SUMMARY" , default_missing_value = "true" ) ]
@@ -1070,7 +1051,7 @@ pub async fn run(
1070
1051
cli_args. track ( & root_telemetry) ;
1071
1052
1072
1053
let cli_result = match cli_args. command . as_ref ( ) . unwrap ( ) {
1073
- Command :: Bin { .. } => {
1054
+ Command :: Bin => {
1074
1055
CommandEventBuilder :: new ( "bin" )
1075
1056
. with_parent ( & root_telemetry)
1076
1057
. track_call ( ) ;
@@ -1357,11 +1338,7 @@ mod test {
1357
1338
}
1358
1339
}
1359
1340
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 } ;
1365
1342
1366
1343
#[ test_case:: test_case(
1367
1344
& [ "turbo" , "run" , "build" ] ,
@@ -2092,15 +2069,6 @@ mod test {
2092
2069
assert_eq ! ( Args :: try_parse_from( args) . unwrap( ) , expected) ;
2093
2070
}
2094
2071
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
- }
2104
2072
#[ test_case:: test_case(
2105
2073
& [ "turbo" , "run" , "build" , "--daemon" , "--no-daemon" ] ,
2106
2074
"cannot be used with '--no-daemon'" ;
@@ -2437,31 +2405,6 @@ mod test {
2437
2405
assert ! ( Args :: try_parse_from( [ "turbo" , "prune" , "foo" , "--scope" , "bar" ] ) . is_err( ) , ) ;
2438
2406
}
2439
2407
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
- }
2465
2408
#[ test]
2466
2409
fn test_parse_gen ( ) {
2467
2410
let default_gen = Command :: Generate {
0 commit comments