Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/PowerShellGet.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
FormatsToProcess = 'PSGet.Format.ps1xml'
CmdletsToExport = @(
'Find-PSResource',
'Get-PSResource',
'Get-InstalledPSResource',
'Get-PSResourceRepository',
'Get-PSScriptFileInfo',
'Install-PSResource',
'Register-PSResourceRepository',
'Save-PSResource',
'Set-PSResourceRepository',
'New-PSScriptFileInfo',
'Test-PSScriptFileInfo',
'New-PSScriptFile',
'Test-PSScriptFile',
'Update-PSScriptFileInfo',
'Publish-PSResource',
'Uninstall-PSResource',
Expand All @@ -48,7 +48,7 @@
## 3.0.20-beta20

- Move off of NuGet client APIs and use direct REST API calls for remote repositories (#1023)

### Bug Fixes
- Updates to dependency installation (#1010) (#996) (#907)
- Update to retrieving all packages installed on machine (#999)
Expand All @@ -57,7 +57,7 @@
- `Find-PSResource` no longer returns duplicate results (#755)
- `Find-PSResource` lists repository 'PSGalleryScripts' which does not exist for `Get-PSResourceRepository` (#1028)

## 3.0.19-beta19
## 3.0.19-beta19

### New Features
- Add `-SkipModuleManifestValidate` parameter to `Publish-PSResource` (#904)
Expand Down
8 changes: 4 additions & 4 deletions src/code/GetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
{
/// <summary>
/// Get helper class provides the core functionality for Get-PSResource.
/// Get helper class provides the core functionality for Get-InstalledPSResource.
/// </summary>
internal class GetHelper
{
Expand All @@ -38,7 +38,7 @@ public GetHelper(PSCmdlet cmdletPassedIn)
#region Public methods

/// <summary>
/// Retrieves package paths from provided search paths for installed packages
/// Retrieves package paths from provided search paths for installed packages
/// by name *and* version.
/// </summary>
public IEnumerable<PSResourceInfo> GetInstalledPackages(
Expand Down Expand Up @@ -134,7 +134,7 @@ public List<string> FilterPkgPathsByName(string[] names, List<string> dirsToSear
public IEnumerable<String> FilterPkgPathsByVersion(VersionRange versionRange, List<string> dirsToSearch, bool selectPrereleaseOnly)
{
Dbg.Assert(versionRange != null, "Version Range cannot be null");

// if no version is specified, just get the latest version
foreach (string pkgPath in dirsToSearch)
{
Expand Down Expand Up @@ -177,7 +177,7 @@ public IEnumerable<String> FilterPkgPathsByVersion(VersionRange versionRange, Li

// For Uninstall-PSResource Prerelease parameter equates to selecting prerelease versions only to uninstall.
// For other cmdlets (Find-PSResource, Install-PSResource) Prerelease parmater equates to selecting stable and prerelease versions.
// We will not just select prerelase versions. For Get-PSResource, there is no Prerelease parameter.
// We will not just select prerelase versions. For Get-InstalledPSResource, there is no Prerelease parameter.
if (versionRange.Satisfies(pkgNugetVersion))
{
if (!selectPrereleaseOnly || pkgNugetVersion.IsPrerelease)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
/// It retrieves a resource that was installed with Install-PSResource
/// Returns a single resource or multiple resource.
/// </summary>
[Cmdlet(VerbsCommon.Get, "PSResource")]
[Cmdlet(VerbsCommon.Get, "InstalledPSResource")]
[OutputType(typeof(PSResourceInfo))]
public sealed class GetPSResource : PSCmdlet
public sealed class GetInstalledPSResourceCommand : PSCmdlet
{
#region Members

Expand All @@ -34,20 +34,20 @@ public sealed class GetPSResource : PSCmdlet
public string[] Name { get; set; }

/// <summary>
/// Specifies the version of the resource to include to look for.
/// Specifies the version of the resource to include to look for.
/// </summary>
[SupportsWildcards]
[Parameter]
[ValidateNotNullOrEmpty()]
public string Version { get; set; }

/// <summary>
/// Specifies the path to look in.
/// Specifies the path to look in.
/// </summary>
[Parameter]
[ValidateNotNullOrEmpty()]
public string Path { get; set; }

/// <summary>
/// Specifies the scope of installation.
/// </summary>
Expand All @@ -60,7 +60,7 @@ public sealed class GetPSResource : PSCmdlet

protected override void BeginProcessing()
{
// Validate that if a -Version param is passed in that it can be parsed into a NuGet version range.
// Validate that if a -Version param is passed in that it can be parsed into a NuGet version range.
// an exact version will be formatted into a version range.
if (Version == null)
{
Expand Down Expand Up @@ -117,7 +117,7 @@ protected override void BeginProcessing()

protected override void ProcessRecord()
{
WriteVerbose("Entering GetPSResource");
WriteVerbose("Entering GetInstalledPSResource");

var namesToSearch = Utils.ProcessNameWildcards(Name, removeWildcardEntries:false, out string[] errorMsgs, out bool _);
foreach (string error in errorMsgs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
/// <summary>
/// Creates a new .ps1 file with script information required for publishing a script.
/// </summary>
[Cmdlet(VerbsCommon.New, "PSScriptFileInfo")]
public sealed class NewPSScriptFileInfo : PSCmdlet
[Cmdlet(VerbsCommon.New, "PSScriptFile")]
public sealed class NewPSScriptFile : PSCmdlet
{
#region Parameters

Expand Down Expand Up @@ -182,7 +182,7 @@ protected override void EndProcessing()
var exMessage = "Path needs to end with a .ps1 file. Example: C:/Users/john/x/MyScript.ps1";
var ex = new ArgumentException(exMessage);
var InvalidPathError = new ErrorRecord(ex, "InvalidPath", ErrorCategory.InvalidArgument, null);
ThrowTerminatingError(InvalidPathError);
ThrowTerminatingError(InvalidPathError);
}

var resolvedPath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(Path);
Expand All @@ -193,7 +193,7 @@ protected override void EndProcessing()
var InvalidPathArgumentError = new ErrorRecord(ex, "InvalidPathArgumentError", ErrorCategory.InvalidArgument, null);
ThrowTerminatingError(InvalidPathArgumentError);
}

if (File.Exists(resolvedPath) && !Force)
{
// .ps1 file at specified location already exists and Force parameter isn't used to rewrite the file
Expand Down Expand Up @@ -250,7 +250,7 @@ protected override void EndProcessing()
return;
}

File.WriteAllLines(resolvedPath, psScriptFileContents);
File.WriteAllLines(resolvedPath, psScriptFileContents);
}

#endregion
Expand Down
10 changes: 5 additions & 5 deletions src/code/PSScriptContents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal void ParseContent(string[] commentLines)

/// <summary>
/// This function is called by PSScriptFileInfo.TryCreateScriptFileInfoString(),
/// by the New-PSScriptFileInfo cmdlet (in which case EndOfFileContents is an empty string so there's no signature that'll get removed)
/// by the New-PSScriptFile cmdlet (in which case EndOfFileContents is an empty string so there's no signature that'll get removed)
/// or by Update-PSScriptFileInfo cmdlet (in which case EndOfFileContents may not be empty and may contain a signature.
/// When emitting contents, any file signature is always removed because it is invalidated when the content is updated.
/// </summary>
Expand All @@ -80,7 +80,7 @@ internal string[] EmitContent()
#endregion

#region Private Methods

/// <summary>
/// Checks if the end of file contents contain a signature.
/// </summary>
Expand All @@ -106,9 +106,9 @@ private void RemoveSignatureString()
{
if (ContainsSignature)
{
// The script signature comment block always appears at the end of the script file,
// so its start location becomes the end of the content section after the signature
// comment block is removed, and is also the length of the content section minus the
// The script signature comment block always appears at the end of the script file,
// so its start location becomes the end of the content section after the signature
// comment block is removed, and is also the length of the content section minus the
// signature block.
string[] contentsWithoutSignature = new string[_signatureStartIndex];
Array.Copy(ScriptContents, contentsWithoutSignature, _signatureStartIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
/// Tests the contents of a .ps1 file to see if it has all properties and is in correct format
/// for publishing the script with the file.
/// </summary>
[Cmdlet(VerbsDiagnostic.Test, "PSScriptFileInfo")]
[Cmdlet(VerbsDiagnostic.Test, "PSScriptFile")]
[OutputType(typeof(bool))]
public sealed class TestPSScriptFileInfo : PSCmdlet
public sealed class TestPSScriptFile : PSCmdlet
{
#region Parameters

Expand All @@ -36,7 +36,7 @@ protected override void EndProcessing()
var exMessage = "Path needs to end with a .ps1 file. Example: C:/Users/john/x/MyScript.ps1";
var ex = new ArgumentException(exMessage);
var InvalidPathError = new ErrorRecord(ex, "InvalidPath", ErrorCategory.InvalidArgument, null);
ThrowTerminatingError(InvalidPathError);
ThrowTerminatingError(InvalidPathError);
}

var resolvedPaths = SessionState.Path.GetResolvedPSPathFromPSPath(Path);
Expand All @@ -62,7 +62,7 @@ protected override void EndProcessing()
scriptFileInfoPath: resolvedPath,
parsedScript: out PSScriptFileInfo _,
errors: out ErrorRecord[] errors,
out string[] verboseMsgs);
out string[] verboseMsgs);

if (!isValidScript)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$ProgressPreference = "SilentlyContinue"
Import-Module "$psscriptroot\PSGetTestUtils.psm1" -Force

Describe 'Test Get-PSResource for Module' -Tags 'CI' {
Describe 'Test Get-InstalledPSResource for Module' -Tags 'CI' {

BeforeAll{
$PSGalleryName = Get-PSGalleryName
Expand All @@ -26,17 +26,17 @@ Describe 'Test Get-PSResource for Module' -Tags 'CI' {
}

It "Get resources without any parameter values" {
$pkgs = Get-PSResource
$pkgs = Get-InstalledPSResource
$pkgs.Count | Should -BeGreaterThan 1
}

It "Get specific module resource by name" {
$pkg = Get-PSResource -Name $testModuleName
$pkg = Get-InstalledPSResource -Name $testModuleName
$pkg.Name | Should -Contain $testModuleName
}

It "Get specific script resource by name" {
$pkg = Get-PSResource -Name $testScriptName
$pkg = Get-InstalledPSResource -Name $testScriptName
$pkg.Name | Should -Be $testScriptName
}

Expand All @@ -47,11 +47,11 @@ Describe 'Test Get-PSResource for Module' -Tags 'CI' {
@{Name="tes*ule"; ExpectedName=$testModuleName; Reason="validate name, with wildcard in middle of name: tes*ule"}
) {
param($Version, $ExpectedVersion)
$pkgs = Get-PSResource -Name $Name
$pkgs = Get-InstalledPSResource -Name $Name
$pkgs.Name | Should -Contain $testModuleName
}

$testCases =
$testCases =
@{Version="[1.0.0.0]"; ExpectedVersion="1.0.0.0"; Reason="validate version, exact match"},
@{Version="1.0.0.0"; ExpectedVersion="1.0.0.0"; Reason="validate version, exact match without bracket syntax"},
@{Version="[1.0.0.0, 5.0.0.0]"; ExpectedVersion=@("5.0.0.0", "3.0.0.0", "1.0.0.0"); Reason="validate version, exact range inclusive"},
Expand All @@ -64,7 +64,7 @@ $testCases =

It "Get resource when given Name to <Reason> <Version>" -TestCases $testCases {
param($Version, $ExpectedVersion)
$pkgs = Get-PSResource -Name $testModuleName -Version $Version
$pkgs = Get-InstalledPSResource -Name $testModuleName -Version $Version
$pkgs.Name | Should -Contain $testModuleName
$pkgs.Version | Should -Be $ExpectedVersion
}
Expand All @@ -86,7 +86,7 @@ $testCases =
$res = Find-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -ErrorAction Ignore
}
catch {}

$res | Should -BeNullOrEmpty
}

Expand All @@ -103,52 +103,52 @@ $testCases =
$res = Find-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -ErrorAction Ignore
}
catch {}

$res | Should -BeNullOrEmpty
}

It "Get resources when given Name, and Version is '*'" {
$pkgs = Get-PSResource -Name $testModuleName -Version "*"
$pkgs = Get-InstalledPSResource -Name $testModuleName -Version "*"
$pkgs.Count | Should -BeGreaterOrEqual 2
}

It "Get prerelease version module when version with correct prerelease label is specified" {
Install-PSResource -Name $testModuleName -Version "5.2.5-alpha001" -Repository $PSGalleryName -TrustRepository
$res = Get-PSResource -Name $testModuleName -Version "5.2.5"
$res = Get-InstalledPSResource -Name $testModuleName -Version "5.2.5"
$res | Should -BeNullOrEmpty
$res = Get-PSResource -Name $testModuleName -Version "5.2.5-alpha001"
$res = Get-InstalledPSResource -Name $testModuleName -Version "5.2.5-alpha001"
$res.Name | Should -Be $testModuleName
$res.Version | Should -Be "5.2.5"
$res.Prerelease | Should -Be "alpha001"
}

It "Get prerelease version script when version with correct prerelease label is specified" {
Install-PSResource -Name $testScriptName -Version "3.0.0-alpha" -Repository $PSGalleryName -TrustRepository
$res = Get-PSResource -Name $testScriptName -Version "3.0.0"
$res = Get-InstalledPSResource -Name $testScriptName -Version "3.0.0"
$res | Should -BeNullOrEmpty
$res = Get-PSResource -Name $testScriptName -Version "3.0.0-alpha"
$res = Get-InstalledPSResource -Name $testScriptName -Version "3.0.0-alpha"
$res.Name | Should -Be $testScriptName
$res.Version | Should -Be "3.0.0"
$res.Prerelease | Should -Be "alpha"
}

# Windows only
It "Get resource under CurrentUser scope - Windows only" -Skip:(!(Get-IsWindows)) {
$pkg = Get-PSResource -Name $testModuleName -Scope CurrentUser
$pkg = Get-InstalledPSResource -Name $testModuleName -Scope CurrentUser
$pkg[0].Name | Should -Be $testModuleName
$pkg[0].InstalledLocation.ToString().Contains("Documents") | Should -Be $true
}

# Windows only
It "Get resource under AllUsers scope when module is installed under CurrentUser - Windows only" -Skip:(!(Get-IsWindows)) {
$pkg = Get-PSResource -Name $testModuleName -Scope AllUsers
$pkg = Get-InstalledPSResource -Name $testModuleName -Scope AllUsers
$pkg | Should -BeNullOrEmpty
}

# Windows only
It "Get resource under AllUsers scope - Windows only" -Skip:(!((Get-IsWindows) -and (Test-IsAdmin))) {
Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope AllUsers
$pkg = Get-PSResource -Name $testModuleName -Scope AllUsers
$pkg = Get-InstalledPSResource -Name $testModuleName -Scope AllUsers
$pkg.Name | Should -Be $testModuleName
$pkg.InstalledLocation.ToString().Contains("Program Files") | Should -Be $true
}
Expand All @@ -157,15 +157,15 @@ $testCases =
It "Get resource under CurrentUser scope when module is installed under AllUsers - Windows only" -Skip:(!((Get-IsWindows) -and (Test-IsAdmin))) {
Uninstall-PSResource -Name $testModuleName -Version "*"
Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope AllUsers
$pkg = Get-PSResource -Name $testModuleName -Scope CurrentUser
$pkg = Get-InstalledPSResource -Name $testModuleName -Scope CurrentUser
$pkg | Should -BeNullOrEmpty
}

# Unix only
# Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules'
It "Get resource under CurrentUser scope - Unix only" -Skip:(Get-IsWindows) {
Install-PSResource -Name "testmodule99" -Repository $PSGalleryName -TrustRepository -Scope CurrentUser
$pkg = Get-PSResource "testmodule99" -Scope CurrentUser
$pkg = Get-InstalledPSResource "testmodule99" -Scope CurrentUser
$pkg.Name | Should -contain "testmodule99"
$pkg.InstalledLocation.ToString().Contains("/.local") | Should -Be $true
}
Expand Down
Loading