@@ -9,10 +9,7 @@ use miette::{Diagnostic, NamedSource, Report, SourceSpan};
9
9
use oxc_resolver:: { ResolveError , Resolver } ;
10
10
use regex:: Regex ;
11
11
use swc_common:: {
12
- comments:: SingleThreadedComments ,
13
- errors:: { ColorConfig , Handler } ,
14
- input:: StringInput ,
15
- FileName , SourceMap ,
12
+ comments:: SingleThreadedComments , errors:: Handler , input:: StringInput , FileName , SourceMap ,
16
13
} ;
17
14
use swc_ecma_ast:: EsVersion ;
18
15
use swc_ecma_parser:: { lexer:: Lexer , Capturing , EsSyntax , Parser , Syntax , TsSyntax } ;
@@ -24,6 +21,7 @@ use turborepo_repository::{
24
21
package_graph:: { PackageName , PackageNode } ,
25
22
package_json:: PackageJson ,
26
23
} ;
24
+ use turborepo_ui:: { color, ColorConfig , BOLD_GREEN , BOLD_RED } ;
27
25
28
26
use crate :: run:: Run ;
29
27
@@ -80,6 +78,8 @@ static PACKAGE_NAME_REGEX: LazyLock<Regex> = LazyLock::new(|| {
80
78
} ) ;
81
79
82
80
pub struct BoundariesResult {
81
+ files_checked : usize ,
82
+ packages_checked : usize ,
83
83
pub source_map : Arc < SourceMap > ,
84
84
pub diagnostics : Vec < BoundariesDiagnostic > ,
85
85
}
@@ -89,13 +89,15 @@ impl BoundariesResult {
89
89
self . diagnostics . is_empty ( )
90
90
}
91
91
92
- pub fn emit ( & self ) {
93
- let handler = Handler :: with_tty_emitter (
94
- ColorConfig :: Auto ,
95
- true ,
96
- false ,
97
- Some ( self . source_map . clone ( ) ) ,
98
- ) ;
92
+ pub fn emit ( & self , color_config : ColorConfig ) {
93
+ let swc_color_config = if color_config. should_strip_ansi {
94
+ swc_common:: errors:: ColorConfig :: Never
95
+ } else {
96
+ swc_common:: errors:: ColorConfig :: Always
97
+ } ;
98
+
99
+ let handler =
100
+ Handler :: with_tty_emitter ( swc_color_config, true , false , Some ( self . source_map . clone ( ) ) ) ;
99
101
100
102
for diagnostic in self . diagnostics . clone ( ) {
101
103
match diagnostic {
@@ -107,6 +109,21 @@ impl BoundariesResult {
107
109
}
108
110
}
109
111
}
112
+ let result_message = if self . diagnostics . is_empty ( ) {
113
+ color ! ( color_config, BOLD_GREEN , "no issues found" )
114
+ } else {
115
+ color ! (
116
+ color_config,
117
+ BOLD_RED ,
118
+ "{} issues found" ,
119
+ self . diagnostics. len( )
120
+ )
121
+ } ;
122
+
123
+ println ! (
124
+ "Checked {} files in {} packages, {}" ,
125
+ self . files_checked, self . packages_checked, result_message
126
+ ) ;
110
127
}
111
128
}
112
129
@@ -116,6 +133,7 @@ impl Run {
116
133
let repo = Repository :: discover ( self . repo_root ( ) ) . ok ( ) . map ( Mutex :: new) ;
117
134
let mut diagnostics = vec ! [ ] ;
118
135
let source_map = SourceMap :: default ( ) ;
136
+ let mut total_files_checked = 0 ;
119
137
for ( package_name, package_info) in packages {
120
138
if !self . filtered_pkgs ( ) . contains ( package_name)
121
139
|| matches ! ( package_name, PackageName :: Root )
@@ -132,7 +150,7 @@ impl Run {
132
150
let unresolved_external_dependencies =
133
151
package_info. unresolved_external_dependencies . as_ref ( ) ;
134
152
135
- let package_diagnostics = self
153
+ let ( files_checked , package_diagnostics) = self
136
154
. check_package (
137
155
& repo,
138
156
& package_root,
@@ -143,10 +161,14 @@ impl Run {
143
161
)
144
162
. await ?;
145
163
164
+ total_files_checked += files_checked;
146
165
diagnostics. extend ( package_diagnostics) ;
147
166
}
148
167
149
168
Ok ( BoundariesResult {
169
+ files_checked : total_files_checked,
170
+ // Subtract 1 for the root package
171
+ packages_checked : self . pkg_dep_graph ( ) . len ( ) - 1 ,
150
172
source_map : Arc :: new ( source_map) ,
151
173
diagnostics,
152
174
} )
@@ -156,7 +178,8 @@ impl Run {
156
178
PACKAGE_NAME_REGEX . is_match ( import)
157
179
}
158
180
159
- /// Either returns a list of errors or a single, fatal error
181
+ /// Either returns a list of errors and number of files checked or a single,
182
+ /// fatal error
160
183
async fn check_package (
161
184
& self ,
162
185
repo : & Option < Mutex < Repository > > ,
@@ -165,7 +188,7 @@ impl Run {
165
188
internal_dependencies : HashSet < & PackageNode > ,
166
189
unresolved_external_dependencies : Option < & BTreeMap < String , String > > ,
167
190
source_map : & SourceMap ,
168
- ) -> Result < Vec < BoundariesDiagnostic > , Error > {
191
+ ) -> Result < ( usize , Vec < BoundariesDiagnostic > ) , Error > {
169
192
let files = globwalk:: globwalk (
170
193
package_root,
171
194
& [
@@ -180,6 +203,8 @@ impl Run {
180
203
globwalk:: WalkType :: Files ,
181
204
) ?;
182
205
206
+ let files_checked = files. len ( ) ;
207
+
183
208
let mut diagnostics: Vec < BoundariesDiagnostic > = Vec :: new ( ) ;
184
209
// We assume the tsconfig.json is at the root of the package
185
210
let tsconfig_path = package_root. join_component ( "tsconfig.json" ) ;
@@ -271,7 +296,7 @@ impl Run {
271
296
}
272
297
}
273
298
274
- Ok ( diagnostics)
299
+ Ok ( ( files_checked , diagnostics) )
275
300
}
276
301
277
302
fn check_file_import (
0 commit comments