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

Commit9635919

Browse files
authored
Merge pull requestmicrosoft#3315 from iclanton/rush-check-summary
[rush] By default, truncate long lists of package names when running rush check.
2 parents3d660bc +d9c3084 commit9635919

File tree

4 files changed

+74
-19
lines changed

4 files changed

+74
-19
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: 51 additions & 17 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,18 +90,21 @@ 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

93-
constprojects:VersionMismatchFinderEntity[]=rushConfiguration.projects.map((project)=>{
94-
returnnewVersionMismatchFinderProject(project);
95-
});
97+
constprojects:VersionMismatchFinderEntity[]=[];
9698

9799
// Create an object for the purposes of reporting conflicts with preferredVersions
98100
// or xstitchPreferredVersions from common-versions.json
101+
// Make sure this one is first so it doesn't get truncated when a long list is printed
99102
projects.push(newVersionMismatchFinderCommonVersions(commonVersions));
100103

104+
for(constprojectofrushConfiguration.projects){
105+
projects.push(newVersionMismatchFinderProject(project));
106+
}
107+
101108
returnnewVersionMismatchFinder(projects,commonVersions.allowedAlternativeVersions);
102109
}
103110

@@ -107,6 +114,7 @@ export class VersionMismatchFinder {
107114
isRushCheckCommand:boolean;
108115
variant?:string|undefined;
109116
printAsJson?:boolean|undefined;
117+
truncateLongPackageNameLists?:boolean|undefined;
110118
}
111119
):void{
112120
if(rushConfiguration.ensureConsistentVersions||options.isRushCheckCommand){
@@ -118,10 +126,17 @@ export class VersionMismatchFinder {
118126
if(options.printAsJson){
119127
mismatchFinder.printAsJson();
120128
}else{
121-
mismatchFinder.print();
129+
mismatchFinder.print(options.truncateLongPackageNameLists);
122130

123131
if(mismatchFinder.numberOfMismatches>0){
124132
console.log(colors.red(`Found${mismatchFinder.numberOfMismatches} mis-matching dependencies!`));
133+
if(!options.isRushCheckCommand&&options.truncateLongPackageNameLists){
134+
// There isn't a --verbose flag in `rush install`/`rush update`, so a long list will always be truncated.
135+
console.log(
136+
'For more detailed reporting about these version mismatches, use the "rush check --verbose" command.'
137+
);
138+
}
139+
125140
thrownewAlreadyReportedError();
126141
}else{
127142
if(options.isRushCheckCommand){
@@ -188,15 +203,34 @@ export class VersionMismatchFinder {
188203
console.log(JSON.stringify(output,undefined,2));
189204
}
190205

191-
publicprint():void{
206+
publicprint(truncateLongPackageNameLists:boolean=false):void{
192207
// Iterate over the list. For any dependency with mismatching versions, print the projects
193208
this.getMismatches().forEach((dependency:string)=>{
194209
console.log(colors.yellow(dependency));
195210
this.getVersionsOfMismatch(dependency)!.forEach((version:string)=>{
196211
console.log(`${version}`);
197-
this.getConsumersOfMismatch(dependency,version)!.forEach((project:VersionMismatchFinderEntity)=>{
198-
console.log(` -${project.friendlyName}`);
199-
});
212+
constconsumersOfMismatch:VersionMismatchFinderEntity[]=this.getConsumersOfMismatch(
213+
dependency,
214+
version
215+
)!;
216+
217+
letnumberToPrint:number=truncateLongPackageNameLists
218+
?TRUNCATE_AFTER_PACKAGE_NAME_COUNT
219+
:consumersOfMismatch.length;
220+
letnumberRemaining:number=consumersOfMismatch.length;
221+
for(const{ friendlyName}ofconsumersOfMismatch){
222+
if(numberToPrint--===0){
223+
break;
224+
}
225+
226+
numberRemaining--;
227+
228+
console.log(` -${friendlyName}`);
229+
}
230+
231+
if(numberRemaining>0){
232+
console.log(` (and${numberRemaining} others)`);
233+
}
200234
});
201235
console.log();
202236
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName":"@microsoft/rush",
5+
"comment":"Change the way\"rush change\" prints long lists of package names to include an\"(and <count> more)\" line after the first five listed by name.",
6+
"type":"none"
7+
}
8+
],
9+
"packageName":"@microsoft/rush"
10+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp