Skip to content

Commit

Permalink
Update script to merge duplicate masters
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Guo committed Sep 25, 2019
1 parent 161e781 commit d1e7c06
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
6 changes: 3 additions & 3 deletions build/Helix/CreateLinksToHelixFiles.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Param(

function Generate-File-Links
{
Param ([Array[]]$files,[string]$headerName)
Param ([Array[]]$files,[string]$sectionName)
if($files.Count -gt 0)
{
Out-File -FilePath $outputFilePath -Append -InputObject "<div class=$headerName>"
Out-File -FilePath $outputFilePath -Append -InputObject "<h4>$headerName</h4>"
Out-File -FilePath $outputFilePath -Append -InputObject "<div class=$sectionName>"
Out-File -FilePath $outputFilePath -Append -InputObject "<h4>$sectionName</h4>"
Out-File -FilePath $outputFilePath -Append -InputObject "<ul>"
foreach($file in $files)
{
Expand Down
40 changes: 39 additions & 1 deletion tools/UpdateVisualTreeMasters.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,52 @@ $html.write($content)

$webClient = New-Object System.Net.WebClient
$visualTreeDumpDivs = $html.body.getElementsByClassName("VisualTreeMasters")
$newFiles = @()
foreach($div in $visualTreeDumpDivs)
{
$links = $div.getElementsByTagName("a")
foreach ($link in $links)
{
$url = $link.href
$fileName = [System.IO.Path]::GetFileName($url)
$destination = "$PSScriptRoot\..\test\MUXControlsTestApp\master\$Filename"
$destination = "$PSScriptRoot\..\test\MUXControlsTestApp\master\$fileName"
Write-Host "Copying $fileName"
$webClient.DownloadFile($url, $destination)
$newFiles += Get-Item $destination
}
}

Write-Host "Merging duplicates..."

$prefixList = @()
foreach($file in $newFiles)
{
$prefix = $file.BaseName.Split('-')[0]
if($prefixList -NotContains $prefix)
{
$prefixList += $prefix
}
}

foreach($prefix in $prefixList)
{
$filesToDelete = @()
$versionedMasters = $newFiles | Where { $_.BaseName.StartsWith($prefix) } | Sort-Object -Property Name -Descending
for ($i=0; $i -lt $versionedMasters.Length-1; $i++)
{
$v1 = Get-Content $versionedMasters[$i].FullName
$v2 = Get-Content $versionedMasters[$i+1].FullName
$diff = Compare-Object $v1 $v2
if($diff.Length -eq 0)
{
$filesToDelete += $versionedMasters[$i]
}
}
$filesToDelete | ForEach-Object {
Write-Host "Deleting $($_.Name)"
Remove-Item $_.FullName
}

Write-Host "Renaming $($versionedMasters[-1].Name) to $prefix.xml"
Move-Item $versionedMasters[-1].FullName "$PSScriptRoot\..\test\MUXControlsTestApp\master\$prefix.xml" -Force
}

0 comments on commit d1e7c06

Please sign in to comment.