@@ -11,40 +11,8 @@ pub use visitor::{Error as VisitorError, Visitor};
1111use crate :: {
1212 cli:: { EnvMode , OutputLogsMode } ,
1313 run:: task_id:: { TaskId , TaskName } ,
14- turbo_json:: RawTaskDefinition ,
1514} ;
1615
17- // TaskOutputs represents the patterns for including and excluding files from
18- // outputs
19- #[ derive( Clone , Debug , Default , Serialize , Deserialize , PartialEq , Eq ) ]
20- pub struct TaskOutputs {
21- pub inclusions : Vec < String > ,
22- pub exclusions : Vec < String > ,
23- }
24-
25- impl TaskOutputs {
26- // We consider an empty outputs to be a log output and nothing else
27- pub fn is_empty ( & self ) -> bool {
28- self . inclusions . len ( ) == 1
29- && self . inclusions [ 0 ] . ends_with ( ".log" )
30- && self . exclusions . is_empty ( )
31- }
32-
33- pub fn validated_inclusions ( & self ) -> Result < Vec < ValidatedGlob > , GlobError > {
34- self . inclusions
35- . iter ( )
36- . map ( |i| ValidatedGlob :: from_str ( i) )
37- . collect ( )
38- }
39-
40- pub fn validated_exclusions ( & self ) -> Result < Vec < ValidatedGlob > , GlobError > {
41- self . exclusions
42- . iter ( )
43- . map ( |e| ValidatedGlob :: from_str ( e) )
44- . collect ( )
45- }
46- }
47-
4816// Constructed from a RawTaskDefinition
4917#[ derive( Debug , PartialEq , Clone , Eq ) ]
5018pub struct TaskDefinition {
@@ -70,10 +38,10 @@ pub struct TaskDefinition {
7038
7139 // Inputs indicate the list of files this Task depends on. If any of those files change
7240 // we can conclude that any cached outputs or logs for this Task should be invalidated.
73- pub ( crate ) inputs : Vec < String > ,
41+ pub inputs : TaskInputs ,
7442
7543 // OutputMode determines how we should log the output.
76- pub ( crate ) output_logs : OutputLogsMode ,
44+ pub output_logs : OutputLogsMode ,
7745
7846 // Persistent indicates whether the Task is expected to exit or not
7947 // Tasks marked Persistent do not exit (e.g. watch mode or dev servers)
@@ -98,6 +66,22 @@ pub struct TaskDefinition {
9866 pub with : Option < Vec < Spanned < TaskName < ' static > > > > ,
9967}
10068
69+ // TaskOutputs represents the patterns for including and excluding files from
70+ // outputs
71+ #[ derive( Clone , Debug , Default , Serialize , Deserialize , PartialEq , Eq ) ]
72+ pub struct TaskOutputs {
73+ pub inclusions : Vec < String > ,
74+ pub exclusions : Vec < String > ,
75+ }
76+
77+ // Structure for holding the inputs for a task
78+ #[ derive( Debug , PartialEq , Clone , Eq , Default ) ]
79+ pub struct TaskInputs {
80+ pub globs : Vec < String > ,
81+ // Set when $TURBO_DEFAULT$ is in inputs
82+ pub default : bool ,
83+ }
84+
10185impl Default for TaskDefinition {
10286 fn default ( ) -> Self {
10387 Self {
@@ -118,16 +102,6 @@ impl Default for TaskDefinition {
118102 }
119103}
120104
121- impl FromIterator < RawTaskDefinition > for RawTaskDefinition {
122- fn from_iter < T : IntoIterator < Item = RawTaskDefinition > > ( iter : T ) -> Self {
123- iter. into_iter ( )
124- . fold ( RawTaskDefinition :: default ( ) , |mut def, other| {
125- def. merge ( other) ;
126- def
127- } )
128- }
129- }
130-
131105const LOG_DIR : & str = ".turbo" ;
132106
133107impl TaskDefinition {
@@ -190,6 +164,43 @@ impl TaskDefinition {
190164 }
191165}
192166
167+ impl TaskInputs {
168+ pub fn new ( globs : Vec < String > ) -> Self {
169+ Self {
170+ globs,
171+ default : false ,
172+ }
173+ }
174+
175+ pub fn with_default ( mut self , default : bool ) -> Self {
176+ self . default = default;
177+ self
178+ }
179+ }
180+
181+ impl TaskOutputs {
182+ // We consider an empty outputs to be a log output and nothing else
183+ pub fn is_empty ( & self ) -> bool {
184+ self . inclusions . len ( ) == 1
185+ && self . inclusions [ 0 ] . ends_with ( ".log" )
186+ && self . exclusions . is_empty ( )
187+ }
188+
189+ pub fn validated_inclusions ( & self ) -> Result < Vec < ValidatedGlob > , GlobError > {
190+ self . inclusions
191+ . iter ( )
192+ . map ( |i| ValidatedGlob :: from_str ( i) )
193+ . collect ( )
194+ }
195+
196+ pub fn validated_exclusions ( & self ) -> Result < Vec < ValidatedGlob > , GlobError > {
197+ self . exclusions
198+ . iter ( )
199+ . map ( |e| ValidatedGlob :: from_str ( e) )
200+ . collect ( )
201+ }
202+ }
203+
193204fn task_log_filename ( task_name : & str ) -> String {
194205 format ! ( "turbo-{}.log" , task_name. replace( ':' , "$colon$" ) )
195206}
0 commit comments