Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5300d0b

Browse files
committed
By default, truncate long lists of package names when running rush check.
1 parentc516014 commit5300d0b

File tree

3 files changed

+51
-16
lines changed

3 files changed

+51
-16
lines changed

‎apps/rush-lib/src/cli/actions/CheckAction.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Variants } from '../../api/Variants';
1212
exportclassCheckActionextendsBaseRushAction{
1313
private_variant!:CommandLineStringParameter;
1414
private_jsonFlag!:CommandLineFlagParameter;
15+
private_verboseFlag!:CommandLineFlagParameter;
1516

1617
publicconstructor(parser:RushCommandLineParser){
1718
super({
@@ -33,6 +34,12 @@ export class CheckAction extends BaseRushAction {
3334
parameterLongName:'--json',
3435
description:'If this flag is specified, output will be in JSON format.'
3536
});
37+
this._verboseFlag=this.defineFlagParameter({
38+
parameterLongName:'--verbose',
39+
description:
40+
'If this flag is specified, long lists of package names will not be truncated. '+
41+
`This has no effect if the${this._jsonFlag.longName} flag is also specified.`
42+
});
3643
}
3744

3845
protectedasyncrunAsync():Promise<void>{
@@ -49,7 +56,8 @@ export class CheckAction extends BaseRushAction {
4956

5057
VersionMismatchFinder.rushCheck(this.rushConfiguration,{
5158
variant:this._variant.value,
52-
printAsJson:this._jsonFlag.value
59+
printAsJson:this._jsonFlag.value,
60+
truncateLongPackageNameLists:!this._verboseFlag.value
5361
});
5462
}
5563
}

‎apps/rush-lib/src/cli/test/__snapshots__/CommandLineHelp.test.ts.snap‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Optional arguments:
303303
`;
304304
305305
exports[`CommandLineHelp prints the help for each action: check 1`] = `
306-
"usage: rush check [-h] [--variant VARIANT] [--json]
306+
"usage: rush check [-h] [--variant VARIANT] [--json] [--verbose]
307307
308308
Checks each project's package.json files and ensures that all dependencies
309309
are of the same version throughout the repository.
@@ -314,6 +314,9 @@ Optional arguments:
314314
This parameter may alternatively be specified via the
315315
RUSH_VARIANT environment variable.
316316
--json If this flag is specified, output will be in JSON format.
317+
--verbose If this flag is specified, long lists of package names
318+
will not be truncated. This has no effect if the --json
319+
flag is also specified.
317320
"
318321
`;
319322

‎apps/rush-lib/src/logic/versionMismatch/VersionMismatchFinder.ts‎

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ import { VersionMismatchFinderEntity } from './VersionMismatchFinderEntity';
1111
import{VersionMismatchFinderProject}from'./VersionMismatchFinderProject';
1212
import{VersionMismatchFinderCommonVersions}from'./VersionMismatchFinderCommonVersions';
1313

14-
exportinterfaceIVersionMismatchFinderRushCheckOptions{
15-
variant?:string|undefined;
16-
printAsJson?:boolean|undefined;
17-
}
14+
constTRUNCATE_AFTER_PACKAGE_NAME_COUNT:number=5;
1815

19-
exportinterfaceIVersionMismatchFinderEnsureConsistentVersionsOptions{
16+
exportinterfaceIVersionMismatchFinderOptions{
2017
variant?:string|undefined;
2118
}
2219

23-
exportinterfaceIVersionMismatchFinderGetMismatchesOptions{
24-
variant?:string|undefined;
20+
exportinterfaceIVersionMismatchFinderRushCheckOptionsextendsIVersionMismatchFinderOptions{
21+
printAsJson?:boolean|undefined;
22+
truncateLongPackageNameLists?:boolean|undefined;
2523
}
2624

25+
exportinterfaceIVersionMismatchFinderEnsureConsistentVersionsOptions
26+
extendsIVersionMismatchFinderOptions{}
27+
28+
exportinterfaceIVersionMismatchFinderGetMismatchesOptionsextendsIVersionMismatchFinderOptions{}
29+
2730
exportinterfaceIMismatchDependency{
2831
dependencyName:string;
2932
versions:IMismatchDependencyVersion[];
@@ -76,7 +79,8 @@ export class VersionMismatchFinder {
7679
):void{
7780
VersionMismatchFinder._checkForInconsistentVersions(rushConfiguration,{
7881
...options,
79-
isRushCheckCommand:false
82+
isRushCheckCommand:false,
83+
truncateLongPackageNameLists:true
8084
});
8185
}
8286

@@ -86,7 +90,7 @@ export class VersionMismatchFinder {
8690
*/
8791
publicstaticgetMismatches(
8892
rushConfiguration:RushConfiguration,
89-
options:IVersionMismatchFinderRushCheckOptions={}
93+
options:IVersionMismatchFinderOptions={}
9094
):VersionMismatchFinder{
9195
constcommonVersions:CommonVersionsConfiguration=rushConfiguration.getCommonVersions(options.variant);
9296

@@ -107,6 +111,7 @@ export class VersionMismatchFinder {
107111
isRushCheckCommand:boolean;
108112
variant?:string|undefined;
109113
printAsJson?:boolean|undefined;
114+
truncateLongPackageNameLists?:boolean|undefined;
110115
}
111116
):void{
112117
if(rushConfiguration.ensureConsistentVersions||options.isRushCheckCommand){
@@ -118,7 +123,7 @@ export class VersionMismatchFinder {
118123
if(options.printAsJson){
119124
mismatchFinder.printAsJson();
120125
}else{
121-
mismatchFinder.print();
126+
mismatchFinder.print(options.truncateLongPackageNameLists);
122127

123128
if(mismatchFinder.numberOfMismatches>0){
124129
console.log(colors.red(`Found${mismatchFinder.numberOfMismatches} mis-matching dependencies!`));
@@ -188,15 +193,34 @@ export class VersionMismatchFinder {
188193
console.log(JSON.stringify(output,undefined,2));
189194
}
190195

191-
publicprint():void{
196+
publicprint(truncateLongPackageNameLists:boolean=false):void{
192197
// Iterate over the list. For any dependency with mismatching versions, print the projects
193198
this.getMismatches().forEach((dependency:string)=>{
194199
console.log(colors.yellow(dependency));
195200
this.getVersionsOfMismatch(dependency)!.forEach((version:string)=>{
196201
console.log(`${version}`);
197-
this.getConsumersOfMismatch(dependency,version)!.forEach((project:VersionMismatchFinderEntity)=>{
198-
console.log(` -${project.friendlyName}`);
199-
});
202+
constconsumersOfMismatch:VersionMismatchFinderEntity[]=this.getConsumersOfMismatch(
203+
dependency,
204+
version
205+
)!;
206+
207+
letnumberToPrint:number=truncateLongPackageNameLists
208+
?TRUNCATE_AFTER_PACKAGE_NAME_COUNT
209+
:consumersOfMismatch.length;
210+
letnumberRemaining:number=consumersOfMismatch.length;
211+
for(const{ friendlyName}ofconsumersOfMismatch){
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
});
201225
console.log();
202226
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp