@@ -22,7 +22,7 @@ use chrono::{DateTime, Local};
22
22
use itertools:: Itertools ;
23
23
use rayon:: iter:: ParallelBridge ;
24
24
use tracing:: debug;
25
- use turbopath:: AnchoredSystemPath ;
25
+ use turbopath:: { AbsoluteSystemPathBuf , AnchoredSystemPath } ;
26
26
use turborepo_analytics:: { start_analytics, AnalyticsHandle , AnalyticsSender } ;
27
27
use turborepo_api_client:: { APIAuth , APIClient } ;
28
28
use turborepo_cache:: { AsyncCache , RemoteCacheOpts } ;
@@ -39,7 +39,7 @@ use turborepo_telemetry::events::{
39
39
repo:: { RepoEventBuilder , RepoType } ,
40
40
EventBuilder ,
41
41
} ;
42
- use turborepo_ui:: { cprint, cprintln, ColorSelector , BOLD_GREY , GREY } ;
42
+ use turborepo_ui:: { cprint, cprintln, ColorSelector , BOLD_GREY , GREY , UI } ;
43
43
#[ cfg( feature = "daemon-package-discovery" ) ]
44
44
use {
45
45
crate :: run:: package_discovery:: DaemonPackageDiscovery ,
@@ -67,10 +67,12 @@ use crate::{
67
67
} ;
68
68
69
69
pub struct Run {
70
- base : CommandBase ,
71
70
processes : ProcessManager ,
72
71
opts : Opts ,
73
72
api_auth : Option < APIAuth > ,
73
+ repo_root : AbsoluteSystemPathBuf ,
74
+ ui : UI ,
75
+ version : & ' static str ,
74
76
}
75
77
76
78
impl Run {
@@ -98,11 +100,15 @@ impl Run {
98
100
if opts. run_opts . experimental_space_id . is_none ( ) {
99
101
opts. run_opts . experimental_space_id = config. spaces_id ( ) . map ( |s| s. to_owned ( ) ) ;
100
102
}
103
+ let version = base. version ( ) ;
104
+ let CommandBase { repo_root, ui, .. } = base;
101
105
Ok ( Self {
102
- base,
103
106
processes,
104
107
opts,
105
108
api_auth,
109
+ repo_root,
110
+ ui,
111
+ version,
106
112
} )
107
113
}
108
114
@@ -114,10 +120,6 @@ impl Run {
114
120
} ) ;
115
121
}
116
122
117
- fn targets ( & self ) -> & [ String ] {
118
- self . base . args ( ) . get_tasks ( )
119
- }
120
-
121
123
fn initialize_analytics (
122
124
api_auth : Option < APIAuth > ,
123
125
api_client : APIClient ,
@@ -132,30 +134,30 @@ impl Run {
132
134
fn print_run_prelude ( & self , filtered_pkgs : & HashSet < WorkspaceName > ) {
133
135
let targets_list = self . opts . run_opts . tasks . join ( ", " ) ;
134
136
if self . opts . run_opts . single_package {
135
- cprint ! ( self . base . ui, GREY , "{}" , "• Running" ) ;
136
- cprint ! ( self . base . ui, BOLD_GREY , " {}\n " , targets_list) ;
137
+ cprint ! ( self . ui, GREY , "{}" , "• Running" ) ;
138
+ cprint ! ( self . ui, BOLD_GREY , " {}\n " , targets_list) ;
137
139
} else {
138
140
let mut packages = filtered_pkgs
139
141
. iter ( )
140
142
. map ( |workspace_name| workspace_name. to_string ( ) )
141
143
. collect :: < Vec < String > > ( ) ;
142
144
packages. sort ( ) ;
143
145
cprintln ! (
144
- self . base . ui,
146
+ self . ui,
145
147
GREY ,
146
148
"• Packages in scope: {}" ,
147
149
packages. join( ", " )
148
150
) ;
149
- cprint ! ( self . base . ui, GREY , "{} " , "• Running" ) ;
150
- cprint ! ( self . base . ui, BOLD_GREY , "{}" , targets_list) ;
151
- cprint ! ( self . base . ui, GREY , " in {} packages\n " , filtered_pkgs. len( ) ) ;
151
+ cprint ! ( self . ui, GREY , "{} " , "• Running" ) ;
152
+ cprint ! ( self . ui, BOLD_GREY , "{}" , targets_list) ;
153
+ cprint ! ( self . ui, GREY , " in {} packages\n " , filtered_pkgs. len( ) ) ;
152
154
}
153
155
154
156
let use_http_cache = !self . opts . cache_opts . skip_remote ;
155
157
if use_http_cache {
156
- cprintln ! ( self . base . ui, GREY , "• Remote caching enabled" ) ;
158
+ cprintln ! ( self . ui, GREY , "• Remote caching enabled" ) ;
157
159
} else {
158
- cprintln ! ( self . base . ui, GREY , "• Remote caching disabled" ) ;
160
+ cprintln ! ( self . ui, GREY , "• Remote caching disabled" ) ;
159
161
}
160
162
}
161
163
@@ -210,14 +212,14 @@ impl Run {
210
212
telemetry : CommandEventBuilder ,
211
213
) -> Result < i32 , Error > {
212
214
let scm = {
213
- let repo_root = self . base . repo_root . clone ( ) ;
215
+ let repo_root = self . repo_root . clone ( ) ;
214
216
tokio:: task:: spawn_blocking ( move || SCM :: new ( & repo_root) )
215
217
} ;
216
- let package_json_path = self . base . repo_root . join_component ( "package.json" ) ;
218
+ let package_json_path = self . repo_root . join_component ( "package.json" ) ;
217
219
let root_package_json = PackageJson :: load ( & package_json_path) ?;
218
220
let run_telemetry = GenericEventBuilder :: new ( ) . with_parent ( & telemetry) ;
219
221
let repo_telemetry =
220
- RepoEventBuilder :: new ( & self . base . repo_root . to_string ( ) ) . with_parent ( & telemetry) ;
222
+ RepoEventBuilder :: new ( & self . repo_root . to_string ( ) ) . with_parent ( & telemetry) ;
221
223
222
224
// Pulled from initAnalyticsClient in run.go
223
225
let is_linked = turborepo_api_client:: is_linked ( & self . api_auth ) ;
@@ -252,7 +254,7 @@ impl Run {
252
254
let can_start_server = true ;
253
255
let can_kill_server = true ;
254
256
let connector =
255
- DaemonConnector :: new ( can_start_server, can_kill_server, & self . base . repo_root ) ;
257
+ DaemonConnector :: new ( can_start_server, can_kill_server, & self . repo_root ) ;
256
258
match ( connector. connect ( ) . await , self . opts . run_opts . daemon ) {
257
259
( Ok ( client) , _) => {
258
260
run_telemetry. track_daemon_init ( DaemonInitStatus :: Started ) ;
@@ -280,7 +282,7 @@ impl Run {
280
282
} ;
281
283
282
284
let mut pkg_dep_graph = {
283
- let builder = PackageGraph :: builder ( & self . base . repo_root , root_package_json. clone ( ) )
285
+ let builder = PackageGraph :: builder ( & self . repo_root , root_package_json. clone ( ) )
284
286
. with_single_package_mode ( self . opts . run_opts . single_package ) ;
285
287
286
288
#[ cfg( feature = "daemon-package-discovery" ) ]
@@ -292,7 +294,7 @@ impl Run {
292
294
(
293
295
Some (
294
296
LocalPackageDiscoveryBuilder :: new (
295
- self . base . repo_root . clone ( ) ,
297
+ self . repo_root . clone ( ) ,
296
298
None ,
297
299
Some ( root_package_json. clone ( ) ) ,
298
300
)
@@ -319,18 +321,18 @@ impl Run {
319
321
let scm = scm. await . expect ( "detecting scm panicked" ) ;
320
322
let async_cache = AsyncCache :: new (
321
323
& self . opts . cache_opts ,
322
- & self . base . repo_root ,
324
+ & self . repo_root ,
323
325
api_client. clone ( ) ,
324
326
self . api_auth . clone ( ) ,
325
327
analytics_sender,
326
328
) ?;
327
329
328
330
// restore config from task access trace if it's enabled
329
- let task_access = TaskAccess :: new ( self . base . repo_root . clone ( ) , async_cache. clone ( ) , & scm) ;
331
+ let task_access = TaskAccess :: new ( self . repo_root . clone ( ) , async_cache. clone ( ) , & scm) ;
330
332
task_access. restore_config ( ) . await ;
331
333
332
334
let root_turbo_json = TurboJson :: load (
333
- & self . base . repo_root ,
335
+ & self . repo_root ,
334
336
AnchoredSystemPath :: empty ( ) ,
335
337
& root_package_json,
336
338
is_single_package,
@@ -341,13 +343,13 @@ impl Run {
341
343
let filtered_pkgs = {
342
344
let ( mut filtered_pkgs, is_all_packages) = scope:: resolve_packages (
343
345
& self . opts . scope_opts ,
344
- & self . base . repo_root ,
346
+ & self . repo_root ,
345
347
& pkg_dep_graph,
346
348
& scm,
347
349
) ?;
348
350
349
351
if is_all_packages {
350
- for target in self . targets ( ) {
352
+ for target in self . opts . run_opts . tasks . iter ( ) {
351
353
let mut task_name = TaskName :: from ( target. as_str ( ) ) ;
352
354
// If it's not a package task, we convert to a root task
353
355
if !task_name. is_package_task ( ) {
@@ -382,7 +384,7 @@ impl Run {
382
384
383
385
let mut global_hash_inputs = get_global_hash_inputs (
384
386
root_external_dependencies_hash. as_deref ( ) ,
385
- & self . base . repo_root ,
387
+ & self . repo_root ,
386
388
pkg_dep_graph. package_manager ( ) ,
387
389
pkg_dep_graph. lockfile ( ) ,
388
390
& root_turbo_json. global_deps ,
@@ -403,11 +405,11 @@ impl Run {
403
405
404
406
let runcache = Arc :: new ( RunCache :: new (
405
407
async_cache,
406
- & self . base . repo_root ,
408
+ & self . repo_root ,
407
409
& self . opts . runcache_opts ,
408
410
color_selector,
409
411
daemon,
410
- self . base . ui ,
412
+ self . ui ,
411
413
self . opts . run_opts . dry_run . is_some ( ) ,
412
414
) ) ;
413
415
if let Some ( subscriber) = signal_handler. subscribe ( ) {
@@ -433,7 +435,7 @@ impl Run {
433
435
engine. tasks ( ) . par_bridge ( ) ,
434
436
workspaces,
435
437
engine. task_definitions ( ) ,
436
- & self . base . repo_root ,
438
+ & self . repo_root ,
437
439
& run_telemetry,
438
440
) ?;
439
441
@@ -444,11 +446,13 @@ impl Run {
444
446
445
447
if let Some ( graph_opts) = & self . opts . run_opts . graph {
446
448
graph_visualizer:: write_graph (
447
- self . base . ui ,
449
+ self . ui ,
448
450
graph_opts,
449
451
& engine,
450
452
self . opts . run_opts . single_package ,
451
- self . base . cwd ( ) ,
453
+ // Note that cwd used to be pulled from CommandBase, which had it set
454
+ // as the repo root.
455
+ & self . repo_root ,
452
456
) ?;
453
457
return Ok ( 0 ) ;
454
458
}
@@ -471,8 +475,8 @@ impl Run {
471
475
self . opts . synthesize_command ( ) ,
472
476
self . opts . scope_opts . pkg_inference_root . as_deref ( ) ,
473
477
& env_at_execution_start,
474
- & self . base . repo_root ,
475
- self . base . version ( ) ,
478
+ & self . repo_root ,
479
+ self . version ,
476
480
self . opts . run_opts . experimental_space_id . clone ( ) ,
477
481
api_client,
478
482
self . api_auth . clone ( ) ,
@@ -490,10 +494,10 @@ impl Run {
490
494
& env_at_execution_start,
491
495
& global_hash,
492
496
global_env_mode,
493
- self . base . ui ,
497
+ self . ui ,
494
498
false ,
495
499
self . processes . clone ( ) ,
496
- & self . base . repo_root ,
500
+ & self . repo_root ,
497
501
global_env,
498
502
) ;
499
503
@@ -544,7 +548,7 @@ impl Run {
544
548
filtered_pkgs : & HashSet < WorkspaceName > ,
545
549
) -> Result < Engine , Error > {
546
550
let engine = EngineBuilder :: new (
547
- & self . base . repo_root ,
551
+ & self . repo_root ,
548
552
pkg_dep_graph,
549
553
self . opts . run_opts . single_package ,
550
554
)
0 commit comments