diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4dc9ed8..d980fdd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,14 +40,14 @@ jobs: - name: Install AnyPackage run: Install-Module AnyPackage -Force -AllowClobber - - name: Install PowerShellGet - run: Install-Module PowerShellGet -AllowPrerelease -Force -AllowClobber + - name: Install PSResourceGet + run: Install-Module Microsoft.PowerShell.PSResourceGet -AllowPrerelease -Force -AllowClobber - name: Download module uses: actions/download-artifact@v3 with: name: module - path: AnyPackage.PowerShellGet + path: AnyPackage.PSResourceGet - name: Move module run: | @@ -57,7 +57,7 @@ jobs: $path = "$HOME/.local/share/powershell/Modules" } - Move-Item AnyPackage.PowerShellGet $path + Move-Item AnyPackage.PSResourceGet $path - name: Test with Pester run: | @@ -100,7 +100,7 @@ jobs: - name: Create and sign catalog file run: | $config = Import-PowerShellDataFile SignSettings.psd1 - $config['FilePath'] = 'AnyPackage.PowerShellGet.cat' + $config['FilePath'] = 'AnyPackage.PSResourceGet.cat' $config['Certificate'] = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert Set-Location .\module New-FileCatalog $config['FilePath'] -CatalogVersion 2 @@ -122,7 +122,7 @@ jobs: uses: actions/download-artifact@v3 with: name: module-signed - path: '~/.local/share/powershell/Modules/AnyPackage.PowerShellGet' + path: '~/.local/share/powershell/Modules/AnyPackage.PSResourceGet' - name: Install AnyPackage run: Install-Module AnyPackage -Force -AllowClobber @@ -130,4 +130,4 @@ jobs: - name: Publish Module env: NUGET_KEY: ${{ secrets.NUGET_KEY }} - run: Publish-Module -Name AnyPackage.PowerShellGet -NuGetApiKey $env:NUGET_KEY + run: Publish-Module -Name AnyPackage.PSResourceGet -NuGetApiKey $env:NUGET_KEY diff --git a/.github/workflows/lint-powershell.yml b/.github/workflows/lint-powershell.yml index 7621bbc..a5fb934 100644 --- a/.github/workflows/lint-powershell.yml +++ b/.github/workflows/lint-powershell.yml @@ -32,12 +32,12 @@ jobs: - name: Install ConvertToSARIF run: Install-Module ConvertToSARIF -Force - - name: Install PowerShellGet - run: Install-Module PowerShellGet -Force -AllowClobber -AllowPrerelease + - name: Install Microsoft.PowerShell.PSResourceGet + run: Install-Module Microsoft.PowerShell.PSResourceGet -Force -AllowClobber -AllowPrerelease - name: Run PSScriptAnalyzer run: | - Import-Module AnyPackage, ConvertToSARIF, PowerShellGet -PassThru + Import-Module AnyPackage, ConvertToSARIF, Microsoft.PowerShell.PSResourceGet -PassThru Invoke-ScriptAnalyzer -Path . -Recurse | ConvertTo-SARIF -FilePath results.sarif - name: Upload SARIF results file diff --git a/CHANGELOG.md b/CHANGELOG.md index aab5a9f..3ae733b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,10 +50,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial release -[Unreleased]: https://github.com/AnyPackage/anypackage/powershellget/compare/v0.2.4...HEAD -[0.2.4]: https://github.com/anypackage/powershellget/releases/tag/v0.2.4 -[0.2.3]: https://github.com/anypackage/powershellget/releases/tag/v0.2.3 -[0.2.2]: https://github.com/anypackage/powershellget/releases/tag/v0.2.2 -[0.2.1]: https://github.com/anypackage/powershellget/releases/tag/v0.2.1 -[0.2.0]: https://github.com/anypackage/powershellget/releases/tag/v0.2.0 -[0.1.0]: https://github.com/anypackage/powershellget/releases/tag/v0.1.0 +[Unreleased]: https://github.com/AnyPackage/anypackage/psresourceget/compare/v0.2.4...HEAD +[0.2.4]: https://github.com/anypackage/psresourceget/releases/tag/v0.2.4 +[0.2.3]: https://github.com/anypackage/psresourceget/releases/tag/v0.2.3 +[0.2.2]: https://github.com/anypackage/psresourceget/releases/tag/v0.2.2 +[0.2.1]: https://github.com/anypackage/psresourceget/releases/tag/v0.2.1 +[0.2.0]: https://github.com/anypackage/psresourceget/releases/tag/v0.2.0 +[0.1.0]: https://github.com/anypackage/psresourceget/releases/tag/v0.1.0 diff --git a/README.md b/README.md index 85f6646..db0f4b4 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,27 @@ -# AnyPackage.PowerShellGet +# AnyPackage.PSResourceGet -AnyPackage.PowerShellGet is an AnyPackage provider that facilitates installing PowerShellGet v3 resources from NuGet repositories. +AnyPackage.PSResourceGet is an AnyPackage provider that facilitates installing PSResourceGet resources from NuGet repositories. ## Documentation -AnyPackage.PowerShellGet documentation is located in [Provider Catalog](https://www.anypackage.dev/docs/provider-catalog/powershellget/about_PowerShellGet_Provider) on how to use the provider and what dynamic parameters exist. +AnyPackage.PSResourceGet documentation is located in [Provider Catalog](https://www.anypackage.dev/docs/provider-catalog/psresourceget/about_PSResourceGet_Provider) on how to use the provider and what dynamic parameters exist. -## Install AnyPackage.PowerShellGet +## Install AnyPackage.PSResourceGet -> NOTE! PowerShellGet v3 is required. -Due to a PowerShellGet issue, prerelease modules cannot be defined as dependencies, so manual installation of PowerShellGet v3 is required. +> NOTE! Microsoft.PowerShell.PSResourceGet is required. +Due to a PSResourceGet issue, prerelease modules cannot be defined as dependencies, so manual installation of PSResourceGet is required. ```PowerShell -# Install PowerShellGet v3 -Install-Module PowerShellGet -AllowPrerelease -AllowClobber -Force +# Install Microsoft.PowerShell.PSResourceGet +Install-Module Microsoft.PowerShell.PSResourceGet -AllowPrerelease -AllowClobber -Force -Install-Module AnyPackage.PowerShellGet +Install-Module AnyPackage.PSResourceGet ``` -## Import AnyPackage.PowerShellGet +## Import AnyPackage.PSResourceGet ```PowerShell -Import-Module AnyPackage.PowerShellGet +Import-Module AnyPackage.PSResourceGet ``` ## Sample usages @@ -81,7 +81,7 @@ Publish-Package -Path C:\Temp\module\module.psd1 ### Manage official package sources ```PowerShell -Register-PackageSource -Provider PowerShellGet -PSGallery +Register-PackageSource -Provider PSResourceGet -PSGallery Find-Package -Name Scoop | Install-Package Unregister-PackageSource -Name PSGallery ``` @@ -96,7 +96,7 @@ Unregister-PackageSource -Name Test ## Known Issues -### Missing PowerShellGet parameters +### Missing PSResourceGet parameters There are a few missing dynamic parameters: diff --git a/SignSettings.psd1 b/SignSettings.psd1 index ca0e546..a697f88 100644 --- a/SignSettings.psd1 +++ b/SignSettings.psd1 @@ -1,5 +1,5 @@ @{ - FilePath = @('AnyPackage.PowerShellGet.psd1', 'AnyPackage.PowerShellGet.psm1') + FilePath = @('AnyPackage.PSResourceGet.psd1', 'AnyPackage.PSResourceGet.psm1') TimeStampServer = 'http://timestamp.sectigo.com' HashAlgorithm = 'SHA256' } diff --git a/src/AnyPackage.PowerShellGet.psd1 b/src/AnyPackage.PSResourceGet.psd1 similarity index 53% rename from src/AnyPackage.PowerShellGet.psd1 rename to src/AnyPackage.PSResourceGet.psd1 index fd25463..41162bd 100644 --- a/src/AnyPackage.PowerShellGet.psd1 +++ b/src/AnyPackage.PSResourceGet.psd1 @@ -1,26 +1,26 @@ @{ - RootModule = 'AnyPackage.PowerShellGet.psm1' + RootModule = 'AnyPackage.PSResourceGet.psm1' ModuleVersion = '0.2.4' CompatiblePSEditions = @('Desktop', 'Core') - GUID = 'cc680200-a0c8-40df-a004-64c3899a72c9' + GUID = '4ffeffd3-7f83-4655-ac94-19eb41ebc792' Author = 'Thomas Nieto' Copyright = '(c) 2023 Thomas Nieto. All rights reserved.' - Description = 'PowerShellGet provider for AnyPackage.' + Description = 'PSResourceGet provider for AnyPackage.' PowerShellVersion = '5.1' RequiredModules = @( @{ ModuleName = 'AnyPackage'; ModuleVersion = '0.5.1' }, - 'PowerShellGet') + 'Microsoft.PowerShell.PSResourceGet') FunctionsToExport = @() CmdletsToExport = @() AliasesToExport = @() PrivateData = @{ AnyPackage = @{ - Providers = 'PowerShellGet' + Providers = 'PSResourceGet' } PSData = @{ - Tags = @('AnyPackage', 'Provider', 'PowerShellGet', 'Windows', 'Linux', 'MacOS') - LicenseUri = 'https://github.com/anypackage/powershellget/blob/main/LICENSE' - ProjectUri = 'https://github.com/anypackage/powershellget' + Tags = @('AnyPackage', 'Provider', 'PSResourceGet', 'Windows', 'Linux', 'MacOS') + LicenseUri = 'https://github.com/anypackage/psresourceget/blob/main/LICENSE' + ProjectUri = 'https://github.com/anypackage/psresourceget' } } HelpInfoUri = 'https://go.anypackage.dev/help' diff --git a/src/AnyPackage.PowerShellGet.psm1 b/src/AnyPackage.PSResourceGet.psm1 similarity index 92% rename from src/AnyPackage.PowerShellGet.psm1 rename to src/AnyPackage.PSResourceGet.psm1 index 7ba465c..07c94ea 100644 --- a/src/AnyPackage.PowerShellGet.psm1 +++ b/src/AnyPackage.PSResourceGet.psm1 @@ -3,14 +3,14 @@ # terms of the MIT license. using module AnyPackage -using module PowerShellGet +using module Microsoft.PowerShell.PSResourceGet using namespace System.Collections.Generic using namespace AnyPackage.Provider -using namespace Microsoft.PowerShell.PowerShellGet.UtilClasses +using namespace Microsoft.PowerShell.PSResourceGet.UtilClasses -[PackageProvider('PowerShellGet')] -class PowerShellGetProvider : PackageProvider, IGetPackage, IFindPackage, +[PackageProvider('PSResourceGet')] +class PSResourceGetProvider : PackageProvider, IGetPackage, IFindPackage, IInstallPackage, ISavePackage, IUninstallPackage, IUpdatePackage, IPublishPackage, IGetSource, ISetSource { #region GetPackage @@ -27,7 +27,7 @@ IUpdatePackage, IPublishPackage, IGetSource, ISetSource { $request.DynamicParameters | ConvertTo-Hashtable -Hashtable $params -IsBound - Get-PSResource @params | + Get-InstalledPSResource @params | Write-Package -Request $request } #endregion @@ -134,11 +134,11 @@ IUpdatePackage, IPublishPackage, IGetSource, ISetSource { ConvertTo-Hashtable -Hashtable $uninstallParams -IsBound # Issue to get PassThru parameter added - # https://github.com/PowerShell/PowerShellGet/issues/667 + # https://github.com/PowerShell/PSResourceGet/issues/667 # Prerelease parameter causes it to silently fail - # https://github.com/PowerShell/PowerShellGet/issues/842 - Get-PSResource @params | + # https://github.com/PowerShell/PSResourceGet/issues/842 + Get-InstalledPSResource @params | ForEach-Object { try { $_ | Uninstall-PSResource @uninstallParams -ErrorAction Stop @@ -171,8 +171,8 @@ IUpdatePackage, IPublishPackage, IGetSource, ISetSource { ConvertTo-Hashtable -Hashtable $updateParams -IsBound # Find-PSResource pipeline input - # https://github.com/PowerShell/PowerShellGet/issues/666 - Get-PSResource -Name $request.Name -ErrorAction SilentlyContinue | + # https://github.com/PowerShell/PSResourceGet/issues/666 + Get-InstalledPSResource -Name $request.Name -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name -Unique | Find-PSResource @params -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name -Unique | @@ -196,7 +196,7 @@ IUpdatePackage, IPublishPackage, IGetSource, ISetSource { try { # PassThru parameter - # https://github.com/PowerShell/PowerShellGet/issues/718 + # https://github.com/PowerShell/PSResourceGet/issues/718 Publish-PSResource @params -ErrorAction Stop $params.Remove('Path') @@ -359,19 +359,19 @@ class InstallPackageDynamicParameters : InstallUpdateDynamicParameters { [switch] $Reinstall # Install-PSResource -NoClobber fails - # https://github.com/PowerShell/PowerShellGet/issues/946 + # https://github.com/PowerShell/PSResourceGet/issues/946 # [Parameter()] # [switch] $NoClobber } class SavePackageDynamicParameters : InstallDynamicParameters { # Pipeline input fails with -AsNupkg - # https://github.com/PowerShell/PowerShellGet/issues/948 + # https://github.com/PowerShell/PSResourceGet/issues/948 # [Parameter()] # [switch] $AsNupkg # Pipeline input fails with -IncludeXml - # https://github.com/PowerShell/PowerShellGet/issues/949 + # https://github.com/PowerShell/PSResourceGet/issues/949 # [Parameter()] # [switch] $IncludeXml } @@ -403,7 +403,7 @@ class RegisterPackageSourceDynamicParameters : SetPackageSourceDynamicParameters } [guid] $id = 'c9a39544-274b-4935-9cad-7423e8c47e6b' -[PackageProviderManager]::RegisterProvider($id, [PowerShellGetProvider], $MyInvocation.MyCommand.ScriptBlock.Module) +[PackageProviderManager]::RegisterProvider($id, [PSResourceGetProvider], $MyInvocation.MyCommand.ScriptBlock.Module) $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { [PackageProviderManager]::UnregisterProvider($id) @@ -476,7 +476,7 @@ function Get-Latest { $resources | Group-Object -Property Name | ForEach-Object { - # PowerShellGet returns the latest as the first object + # PSResourceGet returns the latest as the first object $_.Group | Select-Object -First 1 } } @@ -520,7 +520,7 @@ function Write-Package { ) begin { - $sources = Get-PackageSource -Provider AnyPackage.PowerShellGet\PowerShellGet + $sources = Get-PackageSource -Provider AnyPackage.PSResourceGet\PSResourceGet } process { @@ -537,7 +537,7 @@ function Write-Package { Where-Object Name -eq $resource.Repository # Blank RepositorySourceLocation - # https://github.com/PowerShell/PowerShellGet/issues/1052 + # https://github.com/PowerShell/PSResourceGet/issues/1052 if (-not $source -and $resource.RepositorySourceLocation) { $source = [PackageSourceInfo]::new($resource.Repository, $resource.RepositorySourceLocation, $false, $Request.ProviderInfo) } diff --git a/test/Find-Package.Tests.ps1 b/test/Find-Package.Tests.ps1 index 099e43d..88fe899 100644 --- a/test/Find-Package.Tests.ps1 +++ b/test/Find-Package.Tests.ps1 @@ -1,8 +1,8 @@ -#requires -modules AnyPackage.PowerShellGet +#requires -modules AnyPackage.PSResourceGet Describe Find-Package { Context 'with -Name parameter' { - It 'should return results for <_>' -TestCases 'PSReadline', @('PSReadline', 'PowerShellGet'), 'AnyPackage*' { + It 'should return results for <_>' -TestCases 'PSReadLine', @('PSReadLine', 'Microsoft.PowerShell.Archive'), 'AnyPackage*' { $resources = Find-PSResource -Name $_ $results = Find-Package -Name $_ @@ -64,17 +64,17 @@ Describe Find-Package { Context 'with -Prerelease parameter' { It 'should return prerelease versions' { - Find-Package -Name PowerShellGet -Version * -Prerelease | + Find-Package -Name PSReadLine -Version * -Prerelease | Where-Object { $_.Version.IsPrerelease } | Should -Not -BeNullOrEmpty } } Context 'with -Latest parameter' { - It 'should return latest version for <_> version range' -TestCases '[1.0,2.0]' { - $resource = Find-PSResource -Name PowerShellGet -Version $_ | + It 'should return latest version for <_> version range' -TestCases '[2.0,2.2]' { + $resource = Find-PSResource -Name PSReadLine -Version $_ | Select-Object -First 1 - $package = Find-Package -Name PowerShellGet -Version $_ -Provider PowerShellGet -Latest + $package = Find-Package -Name PSReadLine -Version $_ -Provider PSResourceGet -Latest $package.Version.ToString() | Should -Be $resource.Version.ToString() } diff --git a/test/Get-Package.Tests.ps1 b/test/Get-Package.Tests.ps1 index b57df89..84ca8bd 100644 --- a/test/Get-Package.Tests.ps1 +++ b/test/Get-Package.Tests.ps1 @@ -1,6 +1,4 @@ -#requires -modules AnyPackage.PowerShellGet - -using namespace NuGet.Versioning +#requires -modules AnyPackage.PSResourceGet Describe Get-Package { BeforeAll { @@ -21,7 +19,7 @@ Describe Get-Package { Context 'with -Name parameter' { It 'should return results for <_>' -TestCases 'SNMP', @('PSWindowsUpdate', 'DellBIOSProvider'), '*win*' { - $resources = Get-PSResource -Name $_ + $resources = Get-InstalledPSResource -Name $_ $results = Get-Package -Name $_ $results | Should -Not -BeNullOrEmpty @@ -34,7 +32,7 @@ Describe Get-Package { } It 'should have correct properties for <_>' -TestCases 'SNMP' { - $resource = Get-PSResource -Name $_ + $resource = Get-InstalledPSResource -Name $_ $package = Get-Package -Name $_ if ($resource.Prerelease) { @@ -67,7 +65,7 @@ Describe Get-Package { '(0.2.0,0.3.0]', '(0.2.0,0.3.0)', '[0.2.0,0.3.0)' { - $resources = Get-PSResource -Name Cobalt -Version $_ + $resources = Get-InstalledPSResource -Name Cobalt -Version $_ Get-Package -Name Cobalt -Version $_ | Should -HaveCount $resources.Count diff --git a/test/Get-PackageSource.Tests.ps1 b/test/Get-PackageSource.Tests.ps1 index a1a81b5..d37b746 100644 --- a/test/Get-PackageSource.Tests.ps1 +++ b/test/Get-PackageSource.Tests.ps1 @@ -1,4 +1,4 @@ -#requires -modules AnyPackage.PowerShellGet +#requires -modules AnyPackage.PSResourceGet Describe Get-PackageSource { BeforeAll { @@ -11,7 +11,7 @@ Describe Get-PackageSource { Unregister-PSResourceRepository -Name Test } - Context 'with no additonal parameters' { + Context 'with no additional parameters' { It 'should return results' { Get-PackageSource | Should -Not -BeNullOrEmpty diff --git a/test/Install-Package.Tests.ps1 b/test/Install-Package.Tests.ps1 index 866c69c..c07591c 100644 --- a/test/Install-Package.Tests.ps1 +++ b/test/Install-Package.Tests.ps1 @@ -1,4 +1,4 @@ -#requires -modules AnyPackage.PowerShellGet +#requires -modules AnyPackage.PSResourceGet Describe Install-Package { AfterEach { @@ -49,8 +49,7 @@ Describe Install-Package { Unregister-PSResourceRepository -Name Test } - It 'should install from repository' -TestCases @{ Name = 'SNMP'; Source = 'PSGallery'}, - @{ Name = 'PSWindowsUpdate'; Source = 'Test' } { + It 'should install from repository' -TestCases @{ Name = 'SNMP'; Source = 'PSGallery' } { $results = Install-Package -Name $name -Source $source -PassThru $results.Source | Should -Be $source } @@ -58,20 +57,20 @@ Describe Install-Package { Context 'with -Scope parameter' { It 'should install <_> successfully' -TestCases 'SNMP' { - Install-Package -Name $_ -Provider PowerShellGet -Scope CurrentUser -PassThru | + Install-Package -Name $_ -Provider PSResourceGet -Scope CurrentUser -PassThru | Should -Not -BeNullOrEmpty } } Context 'with -Prerelease parameter' { AfterAll { - Get-PSResource -Name Microsoft.PowerShell.Archive -Version '(1.9,2.0.1)' | + Get-InstalledPSResource -Name PSReadLine -Version '2.0.0-rc2' | Where-Object IsPrerelease | Uninstall-PSResource } - It 'should install <_> sucessfully' -TestCases 'Microsoft.PowerShell.Archive' { - $package = Install-Package -Name $_ -Version '[2.0,2.0.1)' -Prerelease -PassThru + It 'should install <_> successfully' -TestCases 'PSReadLine' { + $package = Install-Package -Name $_ -Version '2.0.0-rc2' -Prerelease -PassThru $package.Version.IsPrerelease | Should -BeTrue } @@ -79,7 +78,7 @@ Describe Install-Package { Context 'with -AuthenticodeCheck parameter' { It 'should install <_> successfully' -TestCases 'Microsoft.PowerShell.Archive' { - Install-Package -Name $_ -Provider PowerShellGet -AuthenticodeCheck -PassThru | + Install-Package -Name $_ -Provider PSResourceGet -AuthenticodeCheck -PassThru | Should -Not -BeNullOrEmpty } } @@ -92,7 +91,7 @@ Describe Install-Package { Context 'with -SkipDependencyCheck parameter' { It 'should install <_> successfully' -TestCases 'SNMP' { - Install-Package -Name $_ -Provider PowerShellGet -SkipDependencyCheck -PassThru | + Install-Package -Name $_ -Provider PSResourceGet -SkipDependencyCheck -PassThru | Should -Not -BeNullOrEmpty } } @@ -100,30 +99,30 @@ Describe Install-Package { Context 'with -TemporaryPath parameter' { It 'should install <_> successfully' -TestCases 'SNMP' { $path = Get-PSDrive TestDrive | Select-Object -ExpandProperty Root - Install-Package -Name $_ -Provider PowerShellGet -TemporaryPath $path -PassThru | + Install-Package -Name $_ -Provider PSResourceGet -TemporaryPath $path -PassThru | Should -Not -BeNullOrEmpty } } Context 'with -NoClobber parameter' { # Install-PSResource -NoClobber fails - # https://github.com/PowerShell/PowerShellGet/issues/946 + # https://github.com/PowerShell/PSResourceGet/issues/946 It 'should install <_> successfully' -TestCases 'SNMP' -Skip { - Install-Package -Name $_ -Provider PowerShellGet -NoClobber -PassThru | + Install-Package -Name $_ -Provider PSResourceGet -NoClobber -PassThru | Should -Not -BeNullOrEmpty } } Context 'with -AcceptLicense parameter' { It 'should install <_> successfully' -TestCases 'SNMP' { - Install-Package -Name $_ -Provider PowerShellGet -AcceptLicense -PassThru | + Install-Package -Name $_ -Provider PSResourceGet -AcceptLicense -PassThru | Should -Not -BeNullOrEmpty } } Context 'with -Reinstall parameter' { It 'should install <_> successfully' -TestCases 'SNMP' { - Install-Package -Name $_ -Provider PowerShellGet -Reinstall -PassThru | + Install-Package -Name $_ -Provider PSResourceGet -Reinstall -PassThru | Should -Not -BeNullOrEmpty } } diff --git a/test/Publish-Package.Tests.ps1 b/test/Publish-Package.Tests.ps1 index 4786047..4764374 100644 --- a/test/Publish-Package.Tests.ps1 +++ b/test/Publish-Package.Tests.ps1 @@ -1,4 +1,4 @@ -#requires -modules AnyPackage.PowerShellGet +#requires -modules AnyPackage.PSResourceGet Describe Publish-Package { BeforeAll { @@ -13,7 +13,7 @@ Describe Publish-Package { Context 'with -Path parameter' { It 'should publish <_> to local repository' -TestCases 'SNMP' { - # https://github.com/PowerShell/PowerShellGet/issues/940 + # https://github.com/PowerShell/PSResourceGet/issues/940 $testRoot = Get-PSDrive -Name TestDrive | Select-Object -ExpandProperty Root Save-PSResource -Name $_ -Path $testRoot -TrustRepository @@ -26,7 +26,7 @@ Describe Publish-Package { Context 'with -DestinationPath parameter' { It 'should publish and create nupkg' -TestCases 'SNMP' { - # https://github.com/PowerShell/PowerShellGet/issues/940 + # https://github.com/PowerShell/PSResourceGet/issues/940 $testRoot = Get-PSDrive -Name TestDrive | Select-Object -ExpandProperty Root Save-PSResource -Name $_ -Path $testRoot -TrustRepository diff --git a/test/Register-PackageSource.Tests.ps1 b/test/Register-PackageSource.Tests.ps1 index cfed39d..015399d 100644 --- a/test/Register-PackageSource.Tests.ps1 +++ b/test/Register-PackageSource.Tests.ps1 @@ -1,9 +1,6 @@ -#requires -modules AnyPackage.PowerShellGet +#requires -modules AnyPackage.PSResourceGet -using module PowerShellGet -using namespace Microsoft.PowerShell.PowerShellGet.UtilClasses - -Describe Register-Package { +Describe Register-PackageSource { AfterEach { try { Register-PSResourceRepository -PSGallery @@ -11,10 +8,13 @@ Describe Register-Package { catch { Write-Verbose -Message 'PSGallery already exists.' } - } - AfterEach { - Unregister-PSResourceRepository -Name Test -ErrorAction Ignore + try { + Unregister-PSResourceRepository -Name Test + } + catch { + Write-Verbose -Message 'Test not registered.' + } } Context 'with -Uri parameter' { @@ -24,7 +24,7 @@ Describe Register-Package { $registerPackageSourceParams = @{ Name = 'Test' Location = $path - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' PassThru = $true } @@ -41,7 +41,7 @@ Describe Register-Package { $registerPackageSourceParams = @{ Name = 'Test' Location = $path - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' Trusted = $true PassThru = $true } @@ -58,7 +58,7 @@ Describe Register-Package { $registerPackageSourceParams = @{ Name = 'Test' Location = $path - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' Trusted = $false PassThru = $true } @@ -77,7 +77,7 @@ Describe Register-Package { $registerPackageSourceParams = @{ Name = 'Test' Location = $path - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' PassThru = $true Priority = $_ } @@ -104,7 +104,7 @@ Describe Register-Package { It 'should register' { $registerPackageSourceParams = @{ - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' PassThru = $true PSGallery = $true } @@ -121,7 +121,7 @@ Describe Register-Package { $registerPackageSourceParams = @{ Name = 'Test' Location = $path - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' PassThru = $true CredentialInfo = $_ } diff --git a/test/Save-Package.Tests.ps1 b/test/Save-Package.Tests.ps1 index 4f7b804..a9b68b0 100644 --- a/test/Save-Package.Tests.ps1 +++ b/test/Save-Package.Tests.ps1 @@ -1,4 +1,4 @@ -#requires -modules AnyPackage.PowerShellGet +#requires -modules AnyPackage.PSResourceGet Describe Save-Package { AfterEach { @@ -38,8 +38,8 @@ Describe Save-Package { Context 'with -Prerelease parameter' { It 'should save' { $savePackageParams = @{ - Name = 'Microsoft.PowerShell.Archive' - Version = '[2.0.0,2.0.1)' + Name = 'PSReadLine' + Version = '2.0.0-rc2' Prerelease = $true Path = (Get-PSDrive -Name TestDrive | Select-Object -ExpandProperty Root) PassThru = $true @@ -52,25 +52,18 @@ Describe Save-Package { } Context 'with -Source parameter' { - BeforeEach { + BeforeAll { $path = Get-PSDrive TestDrive | Select-Object -ExpandProperty Root New-Item -Path $path/repo -ItemType Directory - Save-PSResource -Name AnyPackage, SNMP -Path $path/repo -TrustRepository -AsNupkg - - try { - Register-PSResourceRepository -Name Test -Uri $path/repo -Trusted - } - catch { - Write-Verbose -Message 'Test source already exists.' - } + Register-PSResourceRepository -Name Test -Uri $path/repo -Trusted + Save-PSResource -Name PSWindowsUpdate, SNMP -Path $path/repo -TrustRepository -AsNupkg } AfterAll { Unregister-PSResourceRepository -Name Test } - It 'should save from repository' -TestCases @{ Name = 'SNMP'; Source = 'PSGallery'}, - @{ Name = 'AnyPackage'; Source = 'Test' } { + It 'should save from repository' -TestCases @{ Name = 'SNMP'; Source = 'PSGallery' } { $savePackageParams = @{ Name = $Name Source = $Source @@ -86,14 +79,14 @@ Describe Save-Package { Context 'with -AsNupkg parameter' { # Pipeline input fails with -AsNupkg - # https://github.com/PowerShell/PowerShellGet/issues/948 + # https://github.com/PowerShell/PSResourceGet/issues/948 It 'should save <_> successfully' -TestCases 'AnyPackge' -Skip { $savePackageParams = @{ Name = $_ Path = (Get-PSDrive -Name TestDrive | Select-Object -ExpandProperty Root) PassThru = $true AsNupkg = $true - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' } Save-Package @savePackageParams | @@ -103,14 +96,14 @@ Describe Save-Package { Context 'with -IncludeXml parameter' { # Pipeline input fails with -IncludeXml - # https://github.com/PowerShell/PowerShellGet/issues/949 + # https://github.com/PowerShell/PSResourceGet/issues/949 It 'should save <_> successfully' -TestCases 'AnyPackge' -Skip { $savePackageParams = @{ Name = $_ Path = (Get-PSDrive -Name TestDrive | Select-Object -ExpandProperty Root) PassThru = $true IncludeXml = $true - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' } Save-Package @savePackageParams | @@ -124,7 +117,7 @@ Describe Save-Package { Name = $_ Path = (Get-PSDrive -Name TestDrive | Select-Object -ExpandProperty Root) PassThru = $true - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' AuthenticodeCheck = $true } @@ -144,7 +137,7 @@ Describe Save-Package { Path = (Get-PSDrive -Name TestDrive | Select-Object -ExpandProperty Root) PassThru = $true SkipDependencyCheck = $true - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' } Save-Package @savePackageParams | @@ -161,7 +154,7 @@ Describe Save-Package { Name = $_ Path = $path PassThru = $true - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' TemporaryPath = "$path/temp" } diff --git a/test/Set-PackageSource.Tests.ps1 b/test/Set-PackageSource.Tests.ps1 index f718447..87bfa48 100644 --- a/test/Set-PackageSource.Tests.ps1 +++ b/test/Set-PackageSource.Tests.ps1 @@ -1,4 +1,4 @@ -#requires -modules AnyPackage.PowerShellGet +#requires -modules AnyPackage.PSResourceGet Describe Set-PackageSource { BeforeAll { @@ -33,7 +33,7 @@ Describe Set-PackageSource { It 'should have priority <_>' -TestCases 10 { $registerPackageSourceParams = @{ Name = 'Test' - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' PassThru = $true Priority = $_ } @@ -49,7 +49,7 @@ Describe Set-PackageSource { $registerPackageSourceParams = @{ Name = 'Test' - Provider = 'PowerShellGet' + Provider = 'PSResourceGet' PassThru = $true CredentialInfo = $_ } diff --git a/test/Uninstall-Package.Tests.ps1 b/test/Uninstall-Package.Tests.ps1 index bb55487..f6dc08a 100644 --- a/test/Uninstall-Package.Tests.ps1 +++ b/test/Uninstall-Package.Tests.ps1 @@ -1,4 +1,4 @@ -#requires -modules AnyPackage.PowerShellGet +#requires -modules AnyPackage.PSResourceGet Describe Uninstall-Package { BeforeEach { @@ -41,21 +41,21 @@ Describe Uninstall-Package { Context 'with -Scope parameter' { It 'should uninstall <_> successfully' -TestCases 'SNMP' { - Uninstall-Package -Name $_ -Provider PowerShellGet -Scope CurrentUser -PassThru | + Uninstall-Package -Name $_ -Provider PSResourceGet -Scope CurrentUser -PassThru | Should -Not -BeNullOrEmpty } } Context 'with -SkipDependencyCheck' { It 'should uninstall <_> successfully' -TestCases 'SNMP' { - Uninstall-Package -Name $_ -Provider PowerShellGet -SkipDependencyCheck -PassThru | + Uninstall-Package -Name $_ -Provider PSResourceGet -SkipDependencyCheck -PassThru | Should -Not -BeNullOrEmpty } } Context 'with -Scope' { It 'should uninstall <_> successfully' -TestCases 'SNMP' { - Uninstall-Package -Name $_ -Provider PowerShellGet -Scope CurrentUser -PassThru | + Uninstall-Package -Name $_ -Provider PSResourceGet -Scope CurrentUser -PassThru | Should -Not -BeNullOrEmpty } } diff --git a/test/Unregister-PackageSource.Tests.ps1 b/test/Unregister-PackageSource.Tests.ps1 index 17e3e15..606de86 100644 --- a/test/Unregister-PackageSource.Tests.ps1 +++ b/test/Unregister-PackageSource.Tests.ps1 @@ -1,4 +1,4 @@ -#requires -modules AnyPackage.PowerShellGet +#requires -modules AnyPackage.PSResourceGet Describe Unregister-PackageSource { BeforeEach { diff --git a/test/Update-Package.Tests.ps1 b/test/Update-Package.Tests.ps1 index 78e4bd9..67c376a 100644 --- a/test/Update-Package.Tests.ps1 +++ b/test/Update-Package.Tests.ps1 @@ -1,4 +1,4 @@ -#requires -modules AnyPackage.PowerShellGet +#requires -modules AnyPackage.PSResourceGet Describe Update-Package { BeforeEach { @@ -42,7 +42,7 @@ Describe Update-Package { '[0.1.0]', '[0.2.0,]', '(0.1.0,)', - #'(,0.3.0)', https://github.com/PowerShell/PowerShellGet/issues/943 + #'(,0.3.0)', https://github.com/PowerShell/PSResourceGet/issues/943 '(0.2.0,0.3.0]', '(0.2.0,0.3.0)', '[0.2.0,0.3.0)' { @@ -63,7 +63,7 @@ Describe Update-Package { Unregister-PSResourceRepository -Name Test } - It 'should install from repository' -TestCases @{ Name = 'SNMP'; Source = 'PSGallery'}, + It 'should update from repository' -TestCases @{ Name = 'SNMP'; Source = 'PSGallery'}, @{ Name = 'PSWindowsUpdate'; Source = 'Test' } { $results = Update-Package -Name $name -Source $source -PassThru $results.Source | Should -Be $source @@ -72,15 +72,15 @@ Describe Update-Package { Context 'with -Prerelease parameter' { BeforeAll { - Install-PSResource -Name Microsoft.PowerShell.Archive -Version 1.0.1 -TrustRepository + Install-PSResource -Name PSReadLine -Version 1.2 -TrustRepository } AfterAll { - Uninstall-PSResource -Name Microsoft.PowerShell.Archive + Uninstall-PSResource -Name PSReadLine } - It 'should update <_> sucessfully' -TestCases 'Microsoft.PowerShell.Archive' { - $package = Update-Package -Name $_ -Version '[2.0,2.0.1)' -Prerelease -PassThru + It 'should update <_> successfully' -TestCases 'PSReadLine' { + $package = Update-Package -Name $_ -Version '2.0.0-rc2' -Prerelease -PassThru $package.Version.IsPrerelease | Should -BeTrue } @@ -88,7 +88,7 @@ Describe Update-Package { Context 'with -AcceptLicense parameter' { It 'should update <_> successfully' -TestCases 'SNMP' { - Update-Package -Name $_ -Provider PowerShellGet -AcceptLicense -PassThru | + Update-Package -Name $_ -Provider PSResourceGet -AcceptLicense -PassThru | Should -Not -BeNullOrEmpty } } @@ -99,24 +99,24 @@ Describe Update-Package { } } - Context 'with -TemporaryPath paramter' { + Context 'with -TemporaryPath parameter' { It 'should update <_> successfully' -TestCases 'SNMP' { $path = Get-PSDrive TestDrive | Select-Object -ExpandProperty Root - Update-Package -Name $_ -Provider PowerShellGet -TemporaryPath $path -PassThru | + Update-Package -Name $_ -Provider PSResourceGet -TemporaryPath $path -PassThru | Should -Not -BeNullOrEmpty } } Context 'with -Scope parameter' { It 'should update <_> successfully' -TestCases 'SNMP' { - Update-Package -Name $_ -Provider PowerShellGet -Scope CurrentUser -PassThru | + Update-Package -Name $_ -Provider PSResourceGet -Scope CurrentUser -PassThru | Should -Not -BeNullOrEmpty } } Context 'with -SkipDependencyCheck' { It 'should update <_> successfully' -TestCases 'SNMP' { - Update-Package -Name $_ -Provider PowerShellGet -SkipDependencyCheck -PassThru | + Update-Package -Name $_ -Provider PSResourceGet -SkipDependencyCheck -PassThru | Should -Not -BeNullOrEmpty } }