-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export json to be machine readable #57
base: master
Are you sure you want to change the base?
Conversation
766a3d0
to
1669754
Compare
1669754
to
369c5e4
Compare
@olsh I am going to use this in some projects where I am applying Kentico hotfixes to websites and want to automate the fixing of nuget packages. function Update-Package {
param(
[Parameter(Mandatory = $true)]
[string]
$package,
[Parameter(Mandatory = $true)]
[string[]]
$version
)
foreach ($sln in $slns) {
Write-Host "Processing $sln"
$cmdArgs = "update", "-Id", $($package), "-version", $($version), "-configfile", "$PSScriptRoot\..\src\nuget.config", "$sln"
& "$PSScriptRoot\..\tools\nuget.exe" $cmdArgs
}
$projs = Get-ChildItem -Filter *.csproj -Recurse | % { $_.FullName }
$projs | ? { $(Select-String -Path $_ -Pattern "PackageReference.*$($package.Replace('\.', '\\.'))" ).Matches.Length -gt 0 } | % {
dotnet add "$_" package $($package) --version $($version)
}
}
function Consolidate-Packages {
$slns | % {
# $json = dotnet consolidate -s ".\src\CMS.sln" -j
$json = dotnet consolidate -s "$_" -j
$converted = $json | ConvertFrom-Json
$notConsolidated = $converted | % {
$pck = [PSCustomObject]@{
Package = $_.NuGetPackageId
Versions = (($_.PackageVersions | sort -Property NuGetPackageVersion -Descending ).NuGetPackageVersion.OriginalValue) | % { [Version]::Parse($_) }
}
$pck
} | % {
$pck = $_
$pck | Add-Member -MemberType NoteProperty -Name LatestVersion -Value ($pck.Versions | sort -Descending)[0]
$pck
}
if ($notConsolidated.Count -gt 0) {
$notConsolidated | % {
Update-Package -package $_.Package -version $_.LatestVersion
}
}
}
}
@("Kentico.Xperience.Libraries", "Kentico.Xperience.AspNetCore.WebApp") | % {
Update-Package -package $_ -version $hotfixVersion
}
Consolidate-Packages |
369c5e4
to
6b71129
Compare
@olsh I have just about completed my Hotfix work for my website projects. I really need this to be reviewed and either issues with it mentioned or merged and a release made. This is now becoming a blocker on my work. Thanks for a great tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it would be nice to update the readme file.
Thank you for the contribution. 👍🏻 |
Will Do |
0b915e5
to
1c07323
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the file structure as is for now.
I don't see any benefits for a separate folder for each interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
Temporary testing commit just showing my debugging setup. Will drop once I rebase. |
I realized If you passed in multiple solutions the json was going to be weird. Close to fixing that part. Just making sure it acts right. |
Good point, I didn't think about that. |
Quick question... I am planning on building an object that represents across all solutions here are your non consolidated packages deduped and versions deduped. At the same time I will expose the solution detail and each solution/Package set. Something like {
AllNonConsolidatedPackages:[...], BySolution:
[
{
Solution:{...},
NonConsolidatedPackages:[...]
}
]
} That way the user of the json can decide if they want cross solutions distinct values or per solution data. So my question is do you want the output to be controlled so it always generates this kind of format or do you want an option like IncludePerSolutionDetails to control what is generated? |
I think the |
Ok. I'll take your review stuff and get this finished later on today. I'll ping for a review once done and then after you say good. I'll rebase to squash down. |
358ed9c
to
93762d5
Compare
Ok @olsh think I got it ready. Let me know what you think about this. |
623e70d
to
22876d1
Compare
Fixed
|
22876d1
to
5131e7d
Compare
Also count to be distinct by package id. |
5131e7d
to
e14690c
Compare
e14690c
to
97cb75d
Compare
Fixed BOM issue with text output and updated readme. @olsh This should be it. I validated text output was good with both formats. |
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 4 New issues |
Pushed fixes for some of sonar cloud issues but for example the count. https://stackoverflow.com/questions/305092/which-method-performs-better-any-vs-count-0 Get's fun determining. I guess since the source object is a List which is an ICollection I can switch to Count >0 way if you want. Let me know if you want to fix or ignore the rest. See https://github.com/dotnet/runtime/blob/d14587922635ecf583733051106cc147f6173e06/src/libraries/System.Linq/src/System/Linq/Count.cs#L95 which is called in Any. |
🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 |
Yes, I remember about the PR. But sadly, I don't have time for OS projects. |
Will export json report instead of tables to make output parsable. This will allow scripting to be done against output.
Fixes #58
Example
Formatted Output below