From b69bdbd6d2b2cc38875d263c0e04fd479a8a7cdd Mon Sep 17 00:00:00 2001 From: Rashil Gandhi <46838874+rashil2000@users.noreply.github.com> Date: Wed, 9 Feb 2022 08:38:24 +0530 Subject: [PATCH] feat(scoop-list): Show last-updated time (#4723) --- libexec/scoop-list.ps1 | 11 ++++-- .../formats/ScoopAppsList.Format.ps1xml | 34 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 supporting/formats/ScoopAppsList.Format.ps1xml diff --git a/libexec/scoop-list.ps1 b/libexec/scoop-list.ps1 index 4c8f20603a..2c4415df2c 100644 --- a/libexec/scoop-list.ps1 +++ b/libexec/scoop-list.ps1 @@ -10,6 +10,9 @@ param($query) reset_aliases $def_arch = default_architecture +if (-not (Get-FormatData ScoopAppsList)) { + Update-FormatData "$PSScriptRoot\..\supporting\formats\ScoopAppsList.Format.ps1xml" +} $local = installed_apps $false | ForEach-Object { @{ name = $_ } } $global = installed_apps $true | ForEach-Object { @{ name = $_; global = $true } } @@ -25,22 +28,26 @@ Write-Host "Installed apps$(if($query) { `" matching '$query'`"}):" $apps | Where-Object { !$query -or ($_.name -match $query) } | ForEach-Object { $app = $_.name $global = $_.global - $item = [ordered]@{} + $item = @{ PSTypeName = 'ScoopAppsList' } $ver = Select-CurrentVersion -AppName $app -Global:$global $item.Name = $app $item.Version = $ver $install_info_path = "$(versiondir $app $ver $global)\install.json" + $updated = (Get-Item (appdir $app $global)).LastWriteTime | Get-Date -Format 'yyyy-MM-dd HH:mm:ss' $install_info = $null if(Test-Path $install_info_path) { $install_info = parse_json $install_info_path + $updated = (Get-Item $install_info_path).LastWriteTime | Get-Date -Format 'yyyy-MM-dd HH:mm:ss' } $item.Source = if ($install_info.bucket) { $install_info.bucket } elseif ($install_info.url) { - $install_info.url + if ($install_info.url -eq (usermanifest $app)) { "" } + else { $install_info.url } } + $item.Updated = $updated $info = @() if($global) { $info += "Global install" } diff --git a/supporting/formats/ScoopAppsList.Format.ps1xml b/supporting/formats/ScoopAppsList.Format.ps1xml new file mode 100644 index 0000000000..4ca6d92233 --- /dev/null +++ b/supporting/formats/ScoopAppsList.Format.ps1xml @@ -0,0 +1,34 @@ + + + + ScoopAppsListTable + + ScoopAppsList + + + + + + + Name + + + Version + + + Source + + + Updated + + + Info + + + + + + + + +