Skip to content

Commit

Permalink
Additional package details not included by default (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbergstrom authored May 14, 2022
1 parent 655bbb7 commit 8cd2d22
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

## 0.0.8 - 2022-05-14 - Performance Improvement
### Changed
* No longer include package summary and download URL in package data by default, now accessible with the `-Detailed` switch

## 0.0.7 - 2022-03-12 - Additional Package Details
### Added
* Include package summary and download URL in package data
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ Note: Please do **not** use `Import-Module` with Package Management providers, a
```PowerShell
Find-Package OpenJS.NodeJS -Provider WinGet
Find-Package Mozilla.Firefox -Provider WinGet
Find-Package Mozilla.Firefox -Provider WinGet -Detailed
```

### Find all available versions of a package
```PowerShell
Find-Package Mozilla.Firefox -Provider WinGet -AllVersions
Expand Down
2 changes: 1 addition & 1 deletion Test/WinGet.Unit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Describe 'basic package search operations' {
Find-Package -Provider $WinGet -Name $package -AllVersions | Where-Object {$_.Version -eq $version} | Should -Not -BeNullOrEmpty
}
It 'returns additional package metadata' {
Find-Package -Provider $WinGet -Name $package | Select-Object -ExpandProperty FullPath | Should -Not -BeNullOrEmpty
Find-Package -Provider $WinGet -Name $package -Detailed | Select-Object -ExpandProperty FullPath | Should -Not -BeNullOrEmpty
}
It 'searches for all versions of a package' {
Find-Package -Provider $WinGet -Name $package -AllVersions | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
Expand Down
2 changes: 1 addition & 1 deletion src/WinGet.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
RootModule = 'WinGet.psm1'
ModuleVersion = '0.0.7'
ModuleVersion = '0.0.8'
GUID = '468ef37a-2557-4c10-92ec-783ec1e41639'
Author = 'Ethan Bergstrom'
Copyright = ''
Expand Down
1 change: 1 addition & 0 deletions src/WinGet.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ $script:AcceptLicense = "AcceptLicense"
$script:Force = "Force"
$script:PackageSource = "WinGet"
$script:AllVersions = "AllVersions"
$script:Detailed = "Detailed"

# Utility variables
# Fast Package References are passed between cmdlets in the format of '<name>#<version>#<source>'
Expand Down
10 changes: 7 additions & 3 deletions src/private/ConvertTo-SoftwareIdentity.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@ function ConvertTo-SoftwareIdentity {
)
if ($packageSource) {
Write-Debug "Package identified: $($package.ID), $($package.version), $($packageSource)"
$metadata = Cobalt\Get-WinGetPackageInfo -ID $package.ID -Version $package.Version -Source $packageSource
$swid = @{
FastPackageReference = $package.ID+"#"+ $package.version+"#"+$packageSource
Name = $package.ID
Version = $package.version
versionScheme = "MultiPartNumeric"
FromTrustedSource = $true
Source = $packageSource
Summary = $metadata.Description
FullPath = $metadata.'Download URL'
}

if ($request.Options.ContainsKey($script:Detailed)) {
$metadata = Cobalt\Get-WinGetPackageInfo -ID $package.ID -Version $package.Version -Source $packageSource
$swid.Summary = $metadata.Description
$swid.FullPath = $metadata.'Download URL'
}

New-SoftwareIdentity @swid
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/public/BaseFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ function Get-DynamicOptions {
switch ($category) {
Package {
Write-Output -InputObject (New-DynamicOption -Category $category -Name $script:AcceptLicense -ExpectedType Switch -IsRequired $false)
Write-Output -InputObject (New-DynamicOption -Category $category -Name $script:Detailed -ExpectedType Switch -IsRequired $false)
}
Install {
Write-Output -InputObject (New-DynamicOption -Category $category -Name $script:AcceptLicense -ExpectedType Switch -IsRequired $false)
Write-Output -InputObject (New-DynamicOption -Category $category -Name $script:Detailed -ExpectedType Switch -IsRequired $false)
}
}
}

0 comments on commit 8cd2d22

Please sign in to comment.