Skip to content

Commit

Permalink
Change AnyPackage to v0.5.1 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasNieto authored Apr 6, 2023
1 parent bd991d8 commit cd849bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/AnyPackage.Scoop.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Description = 'Scoop provider for AnyPackage.'
PowerShellVersion = '5.1'
RequiredModules = @(
@{ ModuleName = 'AnyPackage'; ModuleVersion = '0.4.0' },
@{ ModuleName = 'AnyPackage'; ModuleVersion = '0.5.1' },
@{ ModuleName = 'Scoop'; ModuleVersion = '0.1.1' })
FunctionsToExport = @()
CmdletsToExport = @()
Expand Down
22 changes: 12 additions & 10 deletions src/AnyPackage.Scoop.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ using namespace System.Management.Automation
[PackageProvider('Scoop')]
class ScoopProvider : PackageProvider, IFindPackage, IGetPackage,
IInstallPackage, IUpdatePackage, IUninstallPackage, IGetSource, ISetSource {
ScoopProvider() : base('28111522-ea7a-4e8a-b598-85389c17f8be') { }

[PackageProviderInfo] Initialize([PackageProviderInfo] $providerInfo) {
return [ScoopProviderInfo]::new($providerInfo)
}
Expand Down Expand Up @@ -287,10 +285,11 @@ $ScriptBlock = {

Register-ArgumentCompleter -CommandName Register-PackageSource -ParameterName Official -ScriptBlock $ScriptBlock

[PackageProviderManager]::RegisterProvider([ScoopProvider], $MyInvocation.MyCommand.ScriptBlock.Module)
[guid] $id = '28111522-ea7a-4e8a-b598-85389c17f8be'
[PackageProviderManager]::RegisterProvider($id, [ScoopProvider], $MyInvocation.MyCommand.ScriptBlock.Module)

$MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = {
[PackageProviderManager]::UnregisterProvider([ScoopProvider])
[PackageProviderManager]::UnregisterProvider($id)
}

function Write-Source {
Expand Down Expand Up @@ -325,7 +324,8 @@ function Write-Source {
process {
if ($Name -like $Request.Name) {
$trusted = if ($Location -in $OfficialSources.Values) { $true } else { $false }
$Request.WriteSource($Name, $Location, $trusted, @{ Updated = $Updated; Manifests = $Manifests })
$source = [PackageSourceInfo]::new($Name, $Location, $trusted, @{ Updated = $Updated; Manifests = $Manifests }, $Request.ProviderInfo)
$Request.WriteSource($source)
}
}
}
Expand Down Expand Up @@ -382,14 +382,16 @@ function Write-Package {
else {
$bucket = $buckets | Where-Object Name -eq $Source
$trusted = if ($bucket.Source -in $OfficialSources.Values) { $true } else { $false }
$sourceInfo = $Request.NewSourceInfo($bucket.Name,
$bucket.Source,
$trusted,
@{ Updated = $bucket.Updated; Manifests = $bucket.Manifests })
$sourceInfo = [PackageSourceInfo]::new($bucket.Name,
$bucket.Source,
$trusted,
@{ Updated = $bucket.Updated; Manifests = $bucket.Manifests },
$Request.ProviderInfo)
}

if ($Request.IsMatch($Name, $Version)) {
$Request.WritePackage($Name, $Version, $Description, $sourceInfo, $metadata)
$package = [PackageInfo]::new($Name, $Version, $sourceInfo, $Description, $null, $metadata, $Request.ProviderInfo)
$Request.WritePackage($package)
}
}
}

0 comments on commit cd849bf

Please sign in to comment.