Created
March 17, 2022 17:36
-
-
Save natesubra/8cd38bf52b4146db0e7fb762db6eb727 to your computer and use it in GitHub Desktop.
Generate HTML Index of all Installed Scoop buckets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
Import-Module PSWriteHTML -ErrorAction Break | |
} | |
catch { | |
Install-Module -Name PSWriteHTML -Scope CurrentUser | |
} | |
$SCOOP_BUCKETS_DIR = (Get-ChildItem $ENV:SCOOP\Buckets) | |
$SCOOP_MANIFESTS = [System.Collections.Generic.List[object]]::new() | |
$SCOOP_BUCKETS_DIR.ForEach( { | |
$_Bucket = if ($_.BaseName) { $_.BaseName } else { "Unknown" } | |
(Get-ChildItem $_\bucket -Filter *.json -ErrorAction SilentlyContinue).ForEach( { | |
$_Package = if ($_.Basename) { $_.Basename } else { "Unknown" } | |
$_LastWriteTime = $_.LastWriteTime | Get-Date -Format 'MM-dd-yy HH:mm:ss' | |
try { | |
$localManifest = Get-Content -Path $_.Fullname -ErrorAction Continue | ConvertFrom-Json -ErrorAction Continue | |
$localManifest | Add-Member -MemberType NoteProperty -Name Name -Value "$_Package" -ErrorAction Continue | |
$localManifest | Add-Member -MemberType NoteProperty -Name Bucket -Value "$_Bucket" -ErrorAction Continue | |
$localManifest | Add-Member -MemberType NoteProperty -Name LastWriteTime -Value "$_LastWriteTime" -ErrorAction Continue | |
$SCOOP_MANIFESTS.Add($localManifest) | |
# $localManifest.ForEach( { | |
# $_.Homepage = "<a href=`"$($_.Homepage)`" target='_blank'>$($_.Homepage)</a>" | |
# if ($_.changelog.length -gt 0) { | |
# $_.changelog = "<a href=`"$($_.changelog)`" target='_blank'>$($_.changelog)</a>" | |
# } | |
# $_ | |
# }) | |
} catch { | |
Write-Host "Failed: $_Bucket - $_Package" | |
} | |
}) | |
}) | |
$CHOSEN_MANIFESTS = $SCOOP_MANIFESTS | Select-Object Name, @{ | |
name = 'Homepage' | |
expression = { "<a href=`"$($_.Homepage)`" target='_blank'>$($_.Homepage)</a>" } | |
}, Bucket, Version, LastWriteTime, @{ | |
name = 'License' | |
expression = { $_.license.identifier } | |
}, Description | Sort-Object Name, Version, Bucket, LastWriteTime | |
# @{ | |
# name = 'Binaries' | |
# expression = { $_.bin } | |
# }, | |
# , @{ | |
# name = 'Changelog' | |
# expression = { "<a href=`"$($_.changelog)`" target='_blank'>$($_.changelog)</a>" } | |
# } | |
Remove-Item -Force -Path .\scoop-table.html -ErrorAction SilentlyContinue | |
New-HTML { | |
New-HTMLTable ` | |
-DataTable $CHOSEN_MANIFESTS ` | |
-Title 'Scoop Manifests' ` | |
-SearchHighlight ` | |
-PagingLength 50 ` | |
-InvokeHTMLTags ` | |
-EnableColumnReorder ` | |
-ScreenSizePercent 85 | |
} -Minify -FilePath "$PSScriptRoot\scoop-table.html" -Online -ShowHTML |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment