Skip to content

Commit 2a62732

Browse files
authored
Tools to generate migration guide. (#13334)
Co-authored-by: wyunchi-ms <[email protected]>
1 parent 742917b commit 2a62732

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#Requires -Modules PSExcel
2+
[CmdletBinding()]
3+
Param(
4+
[Parameter()]
5+
[string]$ExcelPath
6+
)
7+
$ExcelPath = Resolve-Path -Path $ExcelPath
8+
If (Test-Path $ExcelPath) {
9+
Remove-Item $ExcelPath
10+
}
11+
$Path = [System.IO.Path]::Combine($PSScriptRoot, '..', '..')
12+
Set-Location -Path $Path
13+
Get-ChildItem -Path .\tools\StaticAnalysis\Exceptions\ -Filter BreakingChangeIssues.csv -Recurse
14+
dotnet msbuild /t:Clean
15+
dotnet msbuild /t:Build
16+
dotnet msbuild /t:StaticAnalysis
17+
$BreakingChangeItems = Import-Csv .\artifacts\StaticAnalysisResults\BreakingChangeIssues.csv
18+
$TotalTable = @{}
19+
foreach ($BreakingChangeItem in $BreakingChangeItems) {
20+
$ModuleName = 'Az' + $BreakingChangeItem.AssemblyFileName.Replace("Microsoft.Azure.PowerShell.Cmdlets", "").Replace('.dll', '')
21+
$CmdletName = $BreakingChangeItem.Target
22+
$Description = $BreakingChangeItem.Description
23+
if (-not $TotalTable.ContainsKey($ModuleName)) {
24+
$TotalTable.Add($ModuleName, @{})
25+
}
26+
if (-not $TotalTable[$ModuleName].ContainsKey($CmdletName)) {
27+
$TotalTable[$ModuleName].Add($CmdletName, "")
28+
}
29+
$TotalTable[$ModuleName][$CmdletName] = $TotalTable[$ModuleName][$CmdletName] + "$Description`n"
30+
}
31+
32+
$Data = New-Object System.Collections.ArrayList
33+
foreach ($ModuleName in $TotalTable.Keys) {
34+
foreach ($CmdletName in $TotalTable[$ModuleName].Keys) {
35+
$Tmp = New-Object -TypeName PSObject -Property @{
36+
ModuleName = $ModuleName
37+
CmdletName = $CmdletName
38+
Description = $TotalTable[$ModuleName][$CmdletName]
39+
Before = $Null
40+
After = $Null
41+
TeamMember = $Null
42+
PR = $Null
43+
} | Select ModuleName, CmdletName, Description, Before, After, TeamMember, PR
44+
$Null = $Data.Add($Tmp)
45+
}
46+
}
47+
$Data | Export-XLSX -Path $ExcelPath
48+
Write-Host "Excel is generated at $ExcelPath. Please goto edit it."
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#Requires -Modules PSExcel
2+
[CmdletBinding()]
3+
Param(
4+
[Parameter()]
5+
[string]$ExcelPath,
6+
[Parameter()]
7+
[string]$TargetAzVersion
8+
)
9+
10+
$BreakingChangeItems = Import-XLSX -Path $ExcelPath -RowStart 1
11+
$TotalTable = @{}
12+
foreach ($BreakingChangeItem in $BreakingChangeItems) {
13+
$ModuleName = $BreakingChangeItem.ModuleName
14+
if (-not $TotalTable.ContainsKey($ModuleName)) {
15+
$Tmp = New-Object System.Collections.ArrayList
16+
$TotalTable.Add($ModuleName, $Tmp)
17+
}
18+
$Null = $TotalTable[$ModuleName].Add($BreakingChangeItem)
19+
}
20+
21+
$MigrationGuidePath = [System.IO.Path]::Combine($PSScriptRoot, '..', '..', 'documentation', 'migration-guides', "Az.$TargetAzVersion.0-migration-guide.md")
22+
$MigrationGuidePath = Resolve-Path -Path $MigrationGuidePath
23+
Set-Content -Path $MigrationGuidePath -Value "# Migration Guide for Az $TargetAzVersion.0`n"
24+
25+
foreach ($Module in $TotalTable.Keys) {
26+
Add-Content -Path $MigrationGuidePath -Value "## $Module`n"
27+
foreach ($BreakingChangeItem in $TotalTable[$Module]) {
28+
$CmdletName = $BreakingChangeItem.CmdletName
29+
$Description = $BreakingChangeItem.Description
30+
$Before = $BreakingChangeItem.Before
31+
$After = $BreakingChangeItem.After
32+
Add-Content -Path $MigrationGuidePath -Value "### ``${CmdletName}```n${Description}`n"
33+
if ($Null -ne $Before) {
34+
Add-Content -Path $MigrationGuidePath -Value "#### Before`n${Before}`n#### After`n${After}`n`n"
35+
}
36+
}
37+
}
38+
Write-Host "Migration guide is generated at: $MigrationGuidePath"

0 commit comments

Comments
 (0)