@@ -11,19 +11,22 @@ import { VersionMismatchFinderEntity } from './VersionMismatchFinderEntity';
1111import { VersionMismatchFinderProject } from './VersionMismatchFinderProject' ;
1212import { VersionMismatchFinderCommonVersions } from './VersionMismatchFinderCommonVersions' ;
1313
14- export interface IVersionMismatchFinderRushCheckOptions {
15- variant ?:string | undefined ;
16- printAsJson ?:boolean | undefined ;
17- }
14+ const TRUNCATE_AFTER_PACKAGE_NAME_COUNT :number = 5 ;
1815
19- export interface IVersionMismatchFinderEnsureConsistentVersionsOptions {
16+ export interface IVersionMismatchFinderOptions {
2017variant ?:string | undefined ;
2118}
2219
23- export interface IVersionMismatchFinderGetMismatchesOptions {
24- variant ?:string | undefined ;
20+ export interface IVersionMismatchFinderRushCheckOptions extends IVersionMismatchFinderOptions {
21+ printAsJson ?:boolean | undefined ;
22+ truncateLongPackageNameLists ?:boolean | undefined ;
2523}
2624
25+ export interface IVersionMismatchFinderEnsureConsistentVersionsOptions
26+ extends IVersionMismatchFinderOptions { }
27+
28+ export interface IVersionMismatchFinderGetMismatchesOptions extends IVersionMismatchFinderOptions { }
29+
2730export interface IMismatchDependency {
2831dependencyName :string ;
2932versions :IMismatchDependencyVersion [ ] ;
@@ -76,7 +79,8 @@ export class VersionMismatchFinder {
7679) :void {
7780VersionMismatchFinder . _checkForInconsistentVersions ( rushConfiguration , {
7881 ...options ,
79- isRushCheckCommand :false
82+ isRushCheckCommand :false ,
83+ truncateLongPackageNameLists :true
8084} ) ;
8185}
8286
@@ -86,7 +90,7 @@ export class VersionMismatchFinder {
8690 */
8791public static getMismatches (
8892rushConfiguration :RushConfiguration ,
89- options :IVersionMismatchFinderRushCheckOptions = { }
93+ options :IVersionMismatchFinderOptions = { }
9094) :VersionMismatchFinder {
9195const commonVersions :CommonVersionsConfiguration = rushConfiguration . getCommonVersions ( options . variant ) ;
9296
@@ -107,6 +111,7 @@ export class VersionMismatchFinder {
107111isRushCheckCommand :boolean ;
108112variant ?:string | undefined ;
109113printAsJson ?:boolean | undefined ;
114+ truncateLongPackageNameLists ?:boolean | undefined ;
110115}
111116) :void {
112117if ( rushConfiguration . ensureConsistentVersions || options . isRushCheckCommand ) {
@@ -118,7 +123,7 @@ export class VersionMismatchFinder {
118123if ( options . printAsJson ) {
119124mismatchFinder . printAsJson ( ) ;
120125} else {
121- mismatchFinder . print ( ) ;
126+ mismatchFinder . print ( options . truncateLongPackageNameLists ) ;
122127
123128if ( mismatchFinder . numberOfMismatches > 0 ) {
124129console . log ( colors . red ( `Found${ mismatchFinder . numberOfMismatches } mis-matching dependencies!` ) ) ;
@@ -188,15 +193,34 @@ export class VersionMismatchFinder {
188193console . log ( JSON . stringify ( output , undefined , 2 ) ) ;
189194}
190195
191- public print ( ) :void {
196+ public print ( truncateLongPackageNameLists : boolean = false ) :void {
192197// Iterate over the list. For any dependency with mismatching versions, print the projects
193198this . getMismatches ( ) . forEach ( ( dependency :string ) => {
194199console . log ( colors . yellow ( dependency ) ) ;
195200this . getVersionsOfMismatch ( dependency ) ! . forEach ( ( version :string ) => {
196201console . log ( `${ version } ` ) ;
197- this . getConsumersOfMismatch ( dependency , version ) ! . forEach ( ( project :VersionMismatchFinderEntity ) => {
198- console . log ( ` -${ project . friendlyName } ` ) ;
199- } ) ;
202+ const consumersOfMismatch :VersionMismatchFinderEntity [ ] = this . getConsumersOfMismatch (
203+ dependency ,
204+ version
205+ ) ! ;
206+
207+ let numberToPrint :number = truncateLongPackageNameLists
208+ ?TRUNCATE_AFTER_PACKAGE_NAME_COUNT
209+ :consumersOfMismatch . length ;
210+ let numberRemaining :number = consumersOfMismatch . length ;
211+ for ( const { friendlyName} of consumersOfMismatch ) {
212+ if ( numberToPrint -- === 0 ) {
213+ break ;
214+ }
215+
216+ numberRemaining -- ;
217+
218+ console . log ( ` -${ friendlyName } ` ) ;
219+ }
220+
221+ if ( numberRemaining > 0 ) {
222+ console . log ( ` (and${ numberRemaining } others)` ) ;
223+ }
200224} ) ;
201225console . log ( ) ;
202226} ) ;