Skip to content

Fix backwards compatability with output objects - #85

Open
alerickson wants to merge 1 commit into
PowerShell:masterfrom
alerickson:objectCompat
Open

Fix backwards compatability with output objects#85
alerickson wants to merge 1 commit into
PowerShell:masterfrom
alerickson:objectCompat

Conversation

@alerickson

Copy link
Copy Markdown
Member

PR Summary

Output objects were missing properties that v2 scripts can depend on. For example, Get-PSRepository returned v3's Uri/Priority/ApiVersion shape instead of v2's SourceLocation/InstallationPolicy/PackageManagementProvider shape, breaking scripts that check $repo.InstallationPolicy.Output objects were returning PSResourceGet objects instead of PowerShellGet v2 objects. Another example is relayed in the issue #39.

Scripts written for PowerShellGet v2.2.5 and below can expect specific properties on output objects:

  • Get-PSRepository: SourceLocation, InstallationPolicy, Registered, PackageManagementProvider, PublishLocation, ScriptSourceLocation, ScriptPublishLocation, ProviderOptions

  • Find-Module, Get-InstalledModule, etc.: RepositorySourceLocation, PackageManagementProvider

The compat module was only translating input parameters — it was passing through v3 output objects unchanged, which have different property names, different property sets, and different display formatting.

Changes made:

  • Added Add-V2RepositoryProperties helper — converts PSResourceRepository objects into PSCustomObjects with the full v2 property set (Name, SourceLocation, Trusted, Registered, InstallationPolicy, PackageManagementProvider, PublishLocation, ScriptSourceLocation, ScriptPublishLocation, ProviderOptions)
  • Added Add-V2ResourceProperties helper — converts PSResourceInfo objects into PSCustomObjects with v2 property order (Name, Version, Type, Description, ... RepositorySourceLocation, Repository, PackageManagementProvider, AdditionalMetadata, InstalledLocation)
  • Piped output through the appropriate helper in all 17 cmdlets that can return objects
    Added Update-TypeData for both output types to set default table display columns matching v2
  • Added test coverage Get-PSRepository, Register-PSRepository, Find-Module, Find-Script, Find-Command, Find-DscResource, Get-InstalledModule, Get-InstalledScript, plus 2 skipped integration tests for Install-Module/Update-Module with -PassThru

Before:
image
After:
image

PR Context

Resolves issue #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant