Skip to content

Commit 348a60f

Browse files
committed
Merge branch 'master' of https://github.com/powershell/PowerShellGet into publishPsm1
2 parents d081939 + cff7960 commit 348a60f

10 files changed

+275
-622
lines changed

.github/fabricbot.json

Lines changed: 0 additions & 591 deletions
This file was deleted.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
id:
2+
name: GitOps.PullRequestIssueManagement
3+
description: GitOps.PullRequestIssueManagement primitive
4+
owner:
5+
resource: repository
6+
disabled: false
7+
where:
8+
configuration:
9+
resourceManagementConfiguration:
10+
scheduledSearches:
11+
- description:
12+
frequencies:
13+
- hourly:
14+
hour: 6
15+
filters:
16+
- isIssue
17+
- isOpen
18+
- hasLabel:
19+
label: Needs-Repro-Info
20+
- hasLabel:
21+
label: Status-No Recent Activity
22+
- noActivitySince:
23+
days: 3
24+
actions:
25+
- closeIssue
26+
- description:
27+
frequencies:
28+
- hourly:
29+
hour: 6
30+
filters:
31+
- isIssue
32+
- isOpen
33+
- hasLabel:
34+
label: Needs-Repro-Info
35+
- noActivitySince:
36+
days: 4
37+
- isNotLabeledWith:
38+
label: Status-No Recent Activity
39+
actions:
40+
- addLabel:
41+
label: Status-No Recent Activity
42+
- addReply:
43+
reply: This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
44+
- description:
45+
frequencies:
46+
- hourly:
47+
hour: 6
48+
filters:
49+
- isIssue
50+
- isOpen
51+
- hasLabel:
52+
label: Resolution-Duplicate
53+
- noActivitySince:
54+
days: 1
55+
actions:
56+
- addReply:
57+
reply: This issue has been marked as duplicate and has not had any activity for **1 day**. It will be closed for housekeeping purposes.
58+
- closeIssue
59+
eventResponderTasks:
60+
- if:
61+
- payloadType: Issue_Comment
62+
- isAction:
63+
action: Created
64+
- isActivitySender:
65+
issueAuthor: True
66+
- hasLabel:
67+
label: Needs-Repro-Info
68+
- isOpen
69+
then:
70+
- addLabel:
71+
label: 'Needs-Attention :wave:'
72+
- removeLabel:
73+
label: Needs-Repro-Info
74+
description:
75+
- if:
76+
- payloadType: Issues
77+
- not:
78+
isAction:
79+
action: Closed
80+
- hasLabel:
81+
label: Status-No Recent Activity
82+
then:
83+
- removeLabel:
84+
label: Status-No Recent Activity
85+
description:
86+
- if:
87+
- payloadType: Issue_Comment
88+
- hasLabel:
89+
label: Status-No Recent Activity
90+
then:
91+
- removeLabel:
92+
label: Status-No Recent Activity
93+
description:
94+
- if:
95+
- payloadType: Pull_Request
96+
then:
97+
- inPrLabel:
98+
label: 'Status: In PR'
99+
description:
100+
- if:
101+
- payloadType: Issues
102+
- or:
103+
- hasLabel:
104+
label: Resolution-Answered
105+
- hasLabel:
106+
label: Resolution-External
107+
- hasLabel:
108+
label: Resolution-Fixed
109+
- hasLabel:
110+
label: Resolution-Inactive
111+
then:
112+
- closeIssue
113+
description:
114+
onFailure:
115+
onSuccess:

src/Microsoft.PowerShell.PSResourceGet.psd1

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
# Licensed under the MIT License.
33

44
@{
5-
RootModule = './Microsoft.PowerShell.PSResourceGet.dll'
6-
ModuleVersion = '0.5.22'
7-
CompatiblePSEditions = @('Core', 'Desktop')
8-
GUID = 'e4e0bda1-0703-44a5-b70d-8fe704cd0643'
9-
Author = 'Microsoft Corporation'
10-
CompanyName = 'Microsoft Corporation'
11-
Copyright = '(c) Microsoft Corporation. All rights reserved.'
12-
Description = 'PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Modules, Scripts, and DSC Resources.'
13-
PowerShellVersion = '5.1'
5+
RootModule = './Microsoft.PowerShell.PSResourceGet.dll'
6+
NestedModules = @('./Microsoft.PowerShell.PSResourceGet.psm1')
7+
ModuleVersion = '0.5.23'
8+
CompatiblePSEditions = @('Core', 'Desktop')
9+
GUID = 'e4e0bda1-0703-44a5-b70d-8fe704cd0643'
10+
Author = 'Microsoft Corporation'
11+
CompanyName = 'Microsoft Corporation'
12+
Copyright = '(c) Microsoft Corporation. All rights reserved.'
13+
Description = 'PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Modules, Scripts, and DSC Resources.'
14+
PowerShellVersion = '5.1'
1415
DotNetFrameworkVersion = '2.0'
15-
CLRVersion = '4.0.0'
16-
FormatsToProcess = 'PSGet.Format.ps1xml'
17-
CmdletsToExport = @(
16+
CLRVersion = '4.0.0'
17+
FormatsToProcess = 'PSGet.Format.ps1xml'
18+
CmdletsToExport = @(
1819
'Find-PSResource',
1920
'Get-InstalledPSResource',
2021
'Get-PSResourceRepository',
@@ -30,22 +31,28 @@
3031
'Uninstall-PSResource',
3132
'Unregister-PSResourceRepository',
3233
'Update-PSModuleManifest',
33-
'Update-PSResource')
34-
34+
'Update-PSResource'
35+
)
36+
FunctionsToExport = @(
37+
'Import-PSGetRepository'
38+
)
3539
VariablesToExport = 'PSGetPath'
3640
AliasesToExport = @('Get-PSResource')
3741
PrivateData = @{
3842
PSData = @{
39-
Prerelease = 'beta22'
40-
Tags = @('PackageManagement',
43+
Prerelease = 'beta23'
44+
Tags = @('PackageManagement',
4145
'PSEdition_Desktop',
4246
'PSEdition_Core',
4347
'Linux',
4448
'Mac',
4549
'Windows')
46-
ProjectUri = 'https://go.microsoft.com/fwlink/?LinkId=828955'
47-
LicenseUri = 'https://go.microsoft.com/fwlink/?LinkId=829061'
50+
ProjectUri = 'https://go.microsoft.com/fwlink/?LinkId=828955'
51+
LicenseUri = 'https://go.microsoft.com/fwlink/?LinkId=829061'
4852
ReleaseNotes = @'
53+
## 0.5.22-beta23
54+
- Add Import-PSGetRepository
55+
4956
## 0.5.22-beta22
5057
5158
### Breaking Changes
@@ -72,12 +79,12 @@
7279
- Bug fix for Install-PSResource -NoClobber parameter (#1121)
7380
- Save-PSResource now searches through all repos when no repo is specified (#1125)
7481
- Caching for improved performance in Uninstall-PSResource (#1175)
75-
- Bug fix for parsing package tags from local repository (#1119)
82+
- Bug fix for parsing package tags from local repository (#1119)
7683
7784
See change log (CHANGELOG.md) at https://github.com/PowerShell/PSResourceGet
7885
'@
7986
}
8087
}
8188

82-
HelpInfoUri = 'https://go.microsoft.com/fwlink/?linkid=2238183'
89+
HelpInfoUri = 'https://go.microsoft.com/fwlink/?linkid=2238183'
8390
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<#
2+
.SYNOPSIS
3+
Finds the repositories registered with PowerShellGet and registers them for PSResourceGet.
4+
#>
5+
function Import-PSGetRepository {
6+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
7+
param(
8+
# Use the -Force switch to overwrite existing repositories.
9+
[switch]$Force
10+
)
11+
if ($IsWindows) {
12+
$PSGetAppLocalPath = Microsoft.PowerShell.Management\Join-Path -Path $env:LOCALAPPDATA -ChildPath 'Microsoft\Windows\PowerShell\PowerShellGet\'
13+
}
14+
else {
15+
$PSGetAppLocalPath = Microsoft.PowerShell.Management\Join-Path -Path ([System.Management.Automation.Platform]::SelectProductNameForDirectory('CACHE')) -ChildPath 'PowerShellGet'
16+
}
17+
$PSRepositoriesFilePath = Microsoft.PowerShell.Management\Join-Path -Path $PSGetAppLocalPath -ChildPath "PSRepositories.xml"
18+
$PSGetRepositories = Microsoft.PowerShell.Utility\Import-Clixml $PSRepositoriesFilePath -ea SilentlyContinue
19+
20+
Microsoft.PowerShell.Utility\Write-Verbose ('Found {0} registered PowerShellGet repositories.' -f $PSGetRepositories.Count)
21+
22+
if ($PSGetRepositories.Count) {
23+
$repos = $PSGetRepositories.Values |
24+
Microsoft.PowerShell.Core\Where-Object {$_.PackageManagementProvider -eq 'NuGet'-and $_.Name -ne 'PSGallery'} |
25+
Microsoft.PowerShell.Utility\Select-Object Name, Trusted, SourceLocation
26+
27+
Microsoft.PowerShell.Utility\Write-Verbose ('Selected {0} NuGet repositories.' -f $repos.Count)
28+
29+
if ($repos.Count) {
30+
$repos | Microsoft.PowerShell.Core\ForEach-Object {
31+
try {
32+
$message = 'Registering {0} at {1} -Trusted:${2} -Force:${3}.' -f $_.Name,
33+
$_.SourceLocation, $_.Trusted, $Force
34+
if ($PSCmdlet.ShouldProcess($message, $_.Name, 'Register-PSResourceRepository')) {
35+
$registerPSResourceRepositorySplat = @{
36+
Name = $_.Name
37+
Uri = $_.SourceLocation
38+
Trusted = $_.Trusted
39+
PassThru = $true
40+
Force = $Force
41+
}
42+
Register-PSResourceRepository @registerPSResourceRepositorySplat
43+
}
44+
}
45+
catch [System.Management.Automation.PSInvalidOperationException] {
46+
if ($_.Exception.Message -match 'already exists') {
47+
Microsoft.PowerShell.Utility\Write-Warning $_.Exception.Message
48+
Microsoft.PowerShell.Utility\Write-Warning 'Use the -Force switch to overwrite existing repositories.'
49+
}
50+
else {
51+
throw $_.Exception
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}

src/code/FindHelper.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,15 @@ private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, R
417417
// Example: Find-PSResource -Name "Az*" -Tag "Storage"
418418
string tagMsg = String.Empty;
419419
FindResults responses = null;
420+
string tagsAsString = string.Empty;
420421
if (_tag.Length == 0)
421422
{
422423
responses = currentServer.FindNameGlobbing(pkgName, _prerelease, _type, out errRecord);
423424
}
424425
else
425426
{
426427
responses = currentServer.FindNameGlobbingWithTag(pkgName, _tag, _prerelease, _type, out errRecord);
427-
string tagsAsString = String.Join(", ", _tag);
428+
tagsAsString = String.Join(", ", _tag);
428429
tagMsg = $" and Tags {tagsAsString}";
429430
}
430431

@@ -439,8 +440,10 @@ private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, R
439440
if (currentResult.exception != null && !currentResult.exception.Message.Equals(string.Empty))
440441
{
441442
// write warning?
443+
string message = _tag.Length == 0 ? $"Package '{pkgName}' could not be found." : $"Package '{pkgName}' with tags '{tagsAsString}' could not be found.";
444+
442445
_cmdletPassedIn.WriteError(new ErrorRecord(
443-
new PackageNotFoundException($"Package '{pkgName}' with tags '{tagMsg}' could not be found", currentResult.exception),
446+
new PackageNotFoundException(message, currentResult.exception),
444447
"FindNameGlobbingConvertToPSResourceFailure",
445448
ErrorCategory.InvalidResult,
446449
this));
@@ -460,14 +463,15 @@ private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, R
460463
// Example: Find-PSResource -Name "Az" -Tag "Storage"
461464
string tagMsg = String.Empty;
462465
FindResults responses = null;
466+
string tagsAsString = string.Empty;
463467
if (_tag.Length == 0)
464468
{
465469
responses = currentServer.FindName(pkgName, _prerelease, _type, out errRecord);
466470
}
467471
else
468472
{
469473
responses = currentServer.FindNameWithTag(pkgName, _tag, _prerelease, _type, out errRecord);
470-
string tagsAsString = String.Join(", ", _tag);
474+
tagsAsString = String.Join(", ", _tag);
471475
tagMsg = $" and Tags {tagsAsString}";
472476
}
473477

@@ -481,8 +485,10 @@ private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, R
481485

482486
if (currentResult.exception != null && !currentResult.exception.Message.Equals(string.Empty))
483487
{
488+
string message = _tag.Length == 0 ? $"Package '{pkgName}' could not be found." : $"Package '{pkgName}' with tags '{tagsAsString}' could not be found.";
489+
484490
_cmdletPassedIn.WriteError(new ErrorRecord(
485-
new PackageNotFoundException($"Package '{pkgName}' with tags '{tagMsg}' could not be found", currentResult.exception),
491+
new PackageNotFoundException(message, currentResult.exception),
486492
"FindNameConvertToPSResourceFailure",
487493
ErrorCategory.InvalidResult,
488494
this));

src/code/GetHelper.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
using System.IO;
99
using System.Management.Automation;
1010

11-
using Dbg = System.Diagnostics.Debug;
12-
1311
namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
1412
{
1513
/// <summary>
@@ -133,8 +131,6 @@ public List<string> FilterPkgPathsByName(string[] names, List<string> dirsToSear
133131
// Filter by user provided version
134132
public IEnumerable<String> FilterPkgPathsByVersion(VersionRange versionRange, List<string> dirsToSearch, bool selectPrereleaseOnly)
135133
{
136-
Dbg.Assert(versionRange != null, "Version Range cannot be null");
137-
138134
// if no version is specified, just get the latest version
139135
foreach (string pkgPath in dirsToSearch)
140136
{

src/code/GetInstalledPSResource.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using NuGet.Versioning;
66
using System;
77
using System.Collections.Generic;
8+
using System.Linq;
89
using System.Management.Automation;
910

1011
namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
@@ -139,14 +140,56 @@ protected override void ProcessRecord()
139140

140141
// SelectPrereleaseOnly is false because we want both stable and prerelease versions all the time..
141142
GetHelper getHelper = new GetHelper(this);
143+
List<string> pkgsFound = new List<string>();
142144
foreach (PSResourceInfo pkg in getHelper.GetPackagesFromPath(
143145
name: namesToSearch,
144146
versionRange: _versionRange,
145147
pathsToSearch: _pathsToSearch,
146148
selectPrereleaseOnly: false))
147149
{
150+
pkgsFound.Add(pkg.Name);
148151
WriteObject(pkg);
149152
}
153+
154+
List<string> pkgsNotFound = new List<string>();
155+
foreach (string name in namesToSearch)
156+
{
157+
if (!pkgsFound.Contains(name, StringComparer.OrdinalIgnoreCase))
158+
{
159+
if (name.Contains('*'))
160+
{
161+
WildcardPattern nameWildCardPattern = new WildcardPattern(name, WildcardOptions.IgnoreCase);
162+
163+
bool foundWildcardMatch = false;
164+
foreach (string pkgFound in pkgsFound)
165+
{
166+
if (nameWildCardPattern.IsMatch(pkgFound))
167+
{
168+
foundWildcardMatch = true;
169+
break;
170+
}
171+
}
172+
173+
if (!foundWildcardMatch)
174+
{
175+
pkgsNotFound.Add(name);
176+
}
177+
}
178+
else
179+
{
180+
pkgsNotFound.Add(name);
181+
}
182+
}
183+
}
184+
185+
if (pkgsNotFound.Count > 0)
186+
{
187+
WriteError(new ErrorRecord(
188+
new PackageNotFoundException($"No match was found for package '{string.Join(", ", pkgsNotFound)}'."),
189+
"InstalledPackageNotFound",
190+
ErrorCategory.ObjectNotFound,
191+
this));
192+
}
150193
}
151194

152195
#endregion

0 commit comments

Comments
 (0)