Skip to content

Commit cb5a231

Browse files
authored
Update GenerateMigrationExcel.ps1 to generate the excel based on checkined attribute (Azure#24735)
1 parent 78f546b commit cb5a231

File tree

3 files changed

+647
-625
lines changed

3 files changed

+647
-625
lines changed

tools/BreakingChanges/GenerateMigrationExcel.ps1

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,55 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
# The generated excel will contains one sheet. The title is:
16+
# ModuleName, CmdletName, Description, Before, After, TeamMember, PR
17+
18+
# .\tools\BreakingChanges\GenerateMigrationExcel.ps1 -ExcelPath (Join-Path $env:USERPROFILE "Documents" "2024-05-21-Az-12.0-Breaking-Change-Migration-Guide.xlsx")
19+
1520
#Requires -Modules PSExcel
1621
[CmdletBinding()]
1722
Param(
1823
[Parameter()]
1924
[string]$ExcelPath
2025
)
21-
$ExcelPath = Resolve-Path -Path $ExcelPath
2226
If (Test-Path $ExcelPath) {
2327
Remove-Item $ExcelPath
2428
}
2529
$Path = [System.IO.Path]::Combine($PSScriptRoot, '..', '..')
2630
Set-Location -Path $Path
27-
Get-ChildItem -Path .\tools\StaticAnalysis\Exceptions\ -Filter BreakingChangeIssues.csv -Recurse
28-
dotnet msbuild /t:Clean
29-
dotnet msbuild /t:Build
30-
dotnet msbuild /t:StaticAnalysis
31-
$BreakingChangeItems = Import-Csv .\artifacts\StaticAnalysisResults\BreakingChangeIssues.csv
32-
$TotalTable = @{}
33-
foreach ($BreakingChangeItem in $BreakingChangeItems) {
34-
$ModuleName = 'Az' + $BreakingChangeItem.AssemblyFileName.Replace("Microsoft.Azure.PowerShell.Cmdlets", "").Replace('.dll', '')
35-
$CmdletName = $BreakingChangeItem.Target
36-
$Description = $BreakingChangeItem.Description
37-
if (-not $TotalTable.ContainsKey($ModuleName)) {
38-
$TotalTable.Add($ModuleName, @{})
39-
}
40-
if (-not $TotalTable[$ModuleName].ContainsKey($CmdletName)) {
41-
$TotalTable[$ModuleName].Add($CmdletName, "")
42-
}
43-
$TotalTable[$ModuleName][$CmdletName] = $TotalTable[$ModuleName][$CmdletName] + "$Description`n"
44-
}
31+
# dotnet msbuild /t:Clean
32+
# dotnet msbuild /t:Build
33+
# dotnet msbuild /t:StaticAnalysis
4534

35+
Import-Module (Join-Path $PSScriptRoot "Get-BreakingChangeMetadata.ps1") -Force
36+
$ArtifactsPath = [System.IO.Path]::Combine($Path, "artifacts", "Debug")
37+
38+
$AllModuleList = Get-ChildItem -Path $ArtifactsPath -Filter Az.* | ForEach-Object { $_.Name }
4639
$Data = New-Object System.Collections.ArrayList
47-
foreach ($ModuleName in $TotalTable.Keys) {
48-
foreach ($CmdletName in $TotalTable[$ModuleName].Keys) {
49-
$Tmp = New-Object -TypeName PSObject -Property @{
40+
ForEach ($ModuleName In $AllModuleList)
41+
{
42+
Write-Host "Processing Module: $ModuleName"
43+
$ModuleBreakingChangeInfo = Get-BreakingChangeMetadata -ArtifactsPath $ArtifactsPath -ModuleName $ModuleName
44+
If ($ModuleBreakingChangeInfo.Count -eq 0)
45+
{
46+
Continue
47+
}
48+
49+
ForEach ($CmdletName In ($ModuleBreakingChangeInfo.Keys | Sort-Object))
50+
{
51+
Write-Host "Processing Cmdlet: $ModuleName - $CmdletName"
52+
$NewRow = New-Object -TypeName PSObject -Property @{
5053
ModuleName = $ModuleName
5154
CmdletName = $CmdletName
52-
Description = $TotalTable[$ModuleName][$CmdletName]
55+
Description = Export-BreakingChangeMessageOfCmdlet $ModuleBreakingChangeInfo[$CmdletName]
5356
Before = $Null
5457
After = $Null
5558
TeamMember = $Null
5659
PR = $Null
57-
} | Select ModuleName, CmdletName, Description, Before, After, TeamMember, PR
58-
$Null = $Data.Add($Tmp)
60+
} | Select-Object ModuleName, CmdletName, Description, Before, After, TeamMember, PR
61+
$Null = $Data.Add($NewRow)
5962
}
6063
}
64+
6165
$Data | Export-XLSX -Path $ExcelPath
6266
Write-Host "Excel is generated at $ExcelPath. Please goto edit it."

0 commit comments

Comments
 (0)