@@ -9,10 +9,7 @@ use miette::{Diagnostic, NamedSource, Report, SourceSpan};
99use oxc_resolver:: { ResolveError , Resolver } ;
1010use regex:: Regex ;
1111use swc_common:: {
12- comments:: SingleThreadedComments ,
13- errors:: { ColorConfig , Handler } ,
14- input:: StringInput ,
15- FileName , SourceMap ,
12+ comments:: SingleThreadedComments , errors:: Handler , input:: StringInput , FileName , SourceMap ,
1613} ;
1714use swc_ecma_ast:: EsVersion ;
1815use swc_ecma_parser:: { lexer:: Lexer , Capturing , EsSyntax , Parser , Syntax , TsSyntax } ;
@@ -24,6 +21,7 @@ use turborepo_repository::{
2421 package_graph:: { PackageName , PackageNode } ,
2522 package_json:: PackageJson ,
2623} ;
24+ use turborepo_ui:: { color, ColorConfig , BOLD_GREEN , BOLD_RED } ;
2725
2826use crate :: run:: Run ;
2927
@@ -80,6 +78,8 @@ static PACKAGE_NAME_REGEX: LazyLock<Regex> = LazyLock::new(|| {
8078} ) ;
8179
8280pub struct BoundariesResult {
81+ files_checked : usize ,
82+ packages_checked : usize ,
8383 pub source_map : Arc < SourceMap > ,
8484 pub diagnostics : Vec < BoundariesDiagnostic > ,
8585}
@@ -89,13 +89,15 @@ impl BoundariesResult {
8989 self . diagnostics . is_empty ( )
9090 }
9191
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 ( ) ) ) ;
99101
100102 for diagnostic in self . diagnostics . clone ( ) {
101103 match diagnostic {
@@ -107,6 +109,21 @@ impl BoundariesResult {
107109 }
108110 }
109111 }
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+ ) ;
110127 }
111128}
112129
@@ -116,6 +133,7 @@ impl Run {
116133 let repo = Repository :: discover ( self . repo_root ( ) ) . ok ( ) . map ( Mutex :: new) ;
117134 let mut diagnostics = vec ! [ ] ;
118135 let source_map = SourceMap :: default ( ) ;
136+ let mut total_files_checked = 0 ;
119137 for ( package_name, package_info) in packages {
120138 if !self . filtered_pkgs ( ) . contains ( package_name)
121139 || matches ! ( package_name, PackageName :: Root )
@@ -132,7 +150,7 @@ impl Run {
132150 let unresolved_external_dependencies =
133151 package_info. unresolved_external_dependencies . as_ref ( ) ;
134152
135- let package_diagnostics = self
153+ let ( files_checked , package_diagnostics) = self
136154 . check_package (
137155 & repo,
138156 & package_root,
@@ -143,10 +161,14 @@ impl Run {
143161 )
144162 . await ?;
145163
164+ total_files_checked += files_checked;
146165 diagnostics. extend ( package_diagnostics) ;
147166 }
148167
149168 Ok ( BoundariesResult {
169+ files_checked : total_files_checked,
170+ // Subtract 1 for the root package
171+ packages_checked : self . pkg_dep_graph ( ) . len ( ) - 1 ,
150172 source_map : Arc :: new ( source_map) ,
151173 diagnostics,
152174 } )
@@ -156,7 +178,8 @@ impl Run {
156178 PACKAGE_NAME_REGEX . is_match ( import)
157179 }
158180
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
160183 async fn check_package (
161184 & self ,
162185 repo : & Option < Mutex < Repository > > ,
@@ -165,7 +188,7 @@ impl Run {
165188 internal_dependencies : HashSet < & PackageNode > ,
166189 unresolved_external_dependencies : Option < & BTreeMap < String , String > > ,
167190 source_map : & SourceMap ,
168- ) -> Result < Vec < BoundariesDiagnostic > , Error > {
191+ ) -> Result < ( usize , Vec < BoundariesDiagnostic > ) , Error > {
169192 let files = globwalk:: globwalk (
170193 package_root,
171194 & [
@@ -180,6 +203,8 @@ impl Run {
180203 globwalk:: WalkType :: Files ,
181204 ) ?;
182205
206+ let files_checked = files. len ( ) ;
207+
183208 let mut diagnostics: Vec < BoundariesDiagnostic > = Vec :: new ( ) ;
184209 // We assume the tsconfig.json is at the root of the package
185210 let tsconfig_path = package_root. join_component ( "tsconfig.json" ) ;
@@ -271,7 +296,7 @@ impl Run {
271296 }
272297 }
273298
274- Ok ( diagnostics)
299+ Ok ( ( files_checked , diagnostics) )
275300 }
276301
277302 fn check_file_import (
0 commit comments