Skip to content

Commit cf05988

Browse files
authored
Add artifacts cmdlets (#161)
* Correct input variable name * Add GetArtifactFeed * Fix package version * Add GetArtifactFeedView * Update Winget manifest * Add new itfs alias * Add group as team admin, add Artifacts initial support (#163) * Remove restriction on adding groups * Add AreaPaths to New-Team * Resume using the latest Azure DevOps SDK * Fix empty return in GetTeamMember and GetTeamAdmin * Fix handling of NoDefaultArea, NoBacklogIteration * Update release notes * Improve error message when using Server scope * Update release notes +semver: minor * Rename TfsQueryMembership to WebApi* * Add Remove-TfsGitBranch cmdlet * Bring back support for long queries * Add artifact feed format * Update release notes * Add FeedView formatting * Add get feed by id * Add Artifact cmdlets * Improve parameter handling * Update artifact formatting * Bump packages version * Update release notes * Add formatting * Improve parameter logging * Enumerate returned collections * Improve "sequence has no elements" message * Adjust argument list * Add GetArtifactVersion
1 parent 4868f14 commit cf05988

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+875
-46
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ jobs:
330330
id: tweet
331331
uses: snow-actions/[email protected]
332332
env:
333-
BUILD_NAME: ${{ needs.Build.outputs.BUILD_NAME }}
333+
BUILD_NAME: ${{ needs.Release.outputs.BUILD_NAME }}
334334
CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
335335
CONSUMER_API_SECRET_KEY: ${{ secrets.TWITTER_CONSUMER_API_SECRET_KEY }}
336336
ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}

CSharp/TfsCmdlets.Common/Cmdlets/CmdletBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private void InjectDependencies()
151151

152152
private void LogParameters()
153153
{
154-
Logger.LogParameters(Parameters);
154+
Logger.LogParameters(DisplayName, Parameters);
155155
}
156156

157157
private string GetVerb()

CSharp/TfsCmdlets.Common/Controllers/ControllerBase.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public abstract class ControllerBase : IController
1515
protected T GetClient<T>() => Data.GetClient<T>();
1616

1717
protected T GetItem<T>(object overridingParameters = null) => Data.GetItem<T>(overridingParameters);
18-
18+
1919
protected bool TestItem<T>(object overridingParameters = null) => Data.TestItem<T>(overridingParameters);
20-
20+
2121
protected IEnumerable<T> GetItems<T>(object overridingParameters = null) => Data.GetItems<T>(overridingParameters);
2222

2323
protected IParameterManager Parameters { get; }
@@ -35,7 +35,9 @@ public abstract class ControllerBase : IController
3535
public IEnumerable InvokeCommand()
3636
{
3737
CacheParameters();
38-
38+
39+
Logger.LogParameters(DisplayName, Parameters);
40+
3941
return Run();
4042
}
4143

CSharp/TfsCmdlets.Common/Enums.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,28 @@ public enum GroupScope
7373
Project
7474
}
7575

76+
/// <summary>
77+
/// Project or Collection scope
78+
/// </summary>
79+
[Flags]
80+
public enum ProjectOrCollectionScope
81+
{
82+
/// <summary>
83+
/// Collection-level scope
84+
/// </summary>
85+
Collection = 1,
86+
87+
/// <summary>
88+
/// Project-level scope
89+
/// </summary>
90+
Project = 2,
91+
92+
/// <summary>
93+
/// Both scopes
94+
/// </summary>
95+
All = 3,
96+
}
97+
7698
/// <summary>
7799
/// Board card rule
78100
/// </summary>

CSharp/TfsCmdlets.Common/GlobalUsings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
global using WebApiProcess = Microsoft.TeamFoundation.Core.WebApi.Process;
1717
global using WebApiTeamProjectRef = Microsoft.TeamFoundation.Core.WebApi.TeamProjectReference;
1818
global using WebApiWorkItemType = Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItemType;
19-
global using TfsQueryMembership = Microsoft.VisualStudio.Services.Identity.QueryMembership;
19+
global using WebApiQueryMembership = Microsoft.VisualStudio.Services.Identity.QueryMembership;
2020
global using WebApiWorkItemRelation = Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItemRelation;
2121
global using WebApiBoard = Microsoft.TeamFoundation.Work.WebApi.Board;
2222
global using WebApiTeam = Microsoft.TeamFoundation.Core.WebApi.WebApiTeam;
23+
global using WebApiFeed = Microsoft.VisualStudio.Services.Feed.WebApi.Feed;
24+
global using WebApiPackage = Microsoft.VisualStudio.Services.Feed.WebApi.Package;

CSharp/TfsCmdlets.Common/Services/ILogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public interface ILogger
1212

1313
void LogError(Exception ex, string errorId = null, ErrorCategory category = ErrorCategory.NotSpecified, object targetObject = null);
1414

15-
void LogParameters(IParameterManager parameters);
15+
void LogParameters(string commandName, IParameterManager parameters);
1616
}
1717
}

CSharp/TfsCmdlets.Common/Services/Impl/DataManagerImpl.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public IEnumerable<T> Invoke<T>(string verb, object overridingParameters = null)
3030

3131
foreach (var item in DoInvokeCommand(controller, overridingParameters))
3232
{
33+
if (item is IEnumerable<T> items)
34+
{
35+
foreach (var i in items) yield return i;
36+
continue;
37+
}
38+
3339
yield return (T)item;
3440
}
3541
}
@@ -45,7 +51,7 @@ public IEnumerable Invoke(string verb, string noun, object overridingParameters
4551
}
4652

4753
public T GetItem<T>(object overridingParameters = null)
48-
=> GetItems<T>(overridingParameters).First();
54+
=> GetItems<T>(overridingParameters).FirstOrDefault() ?? throw new ArgumentException($"Invalid or non-existent {typeof(T).Name}. Check the supplied arguments and try again.");
4955

5056
public IEnumerable<T> GetItems<T>(object overridingParameters = null)
5157
=> Invoke<T>(VerbsCommon.Get, overridingParameters);

CSharp/TfsCmdlets.Common/Services/Impl/LoggerImpl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void LogWarn(string message)
3333
}
3434

3535

36-
public void LogParameters(IParameterManager parameters)
36+
public void LogParameters(string commandName, IParameterManager parameters)
3737
{
3838
if (!PowerShell.IsVerbose) return;
3939

@@ -78,7 +78,7 @@ public void LogParameters(IParameterManager parameters)
7878
.Replace("\":", "\" = ")
7979
.Replace(",\"", "; \"");
8080

81-
Log($"<START> Running cmdlet with {(hasParameterSetName ? $"parameter set '{parameterSetName}' and " : "")}the following implicit and explicit arguments:");
81+
Log($"Running [{commandName}] with {(hasParameterSetName ? $"parameter set '{parameterSetName}' and " : "")}the following implicit and explicit arguments:");
8282
Log(args);
8383

8484
}

CSharp/TfsCmdlets.Common/TfsCmdlets.Common.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<PackageReference Include="Microsoft.VisualStudio.Services.Search.Client" Version="16.*-*" />
2323
<PackageReference Include="Microsoft.VisualStudio.Services.ServiceEndpoints.WebApi" Version="16.*-*" />
2424
<PackageReference Include="Microsoft.VisualStudio.Services.ServiceHooks.WebApi" Version="16.*-*" />
25+
<PackageReference Include="Microsoft.VisualStudio.Services.Packaging.Client" Version="16.*-*" />
2526
<PackageReference Include="PowerShellStandard.Library" Version="7.0.0-preview.1" PrivateAssets="all" />
2627
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
2728
<PackageReference Include="System.Composition" Version="5.0.1" />
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
namespace TfsCmdlets.Cmdlets.Artifact
2+
{
3+
/// <summary>
4+
/// Gets information from one or more artifact feeds.
5+
/// </summary>
6+
[TfsCmdlet(CmdletScope.Project, OutputType = typeof(WebApiPackage))]
7+
partial class GetArtifact
8+
{
9+
/// <summary>
10+
/// Specifies the package (artifact) name. Wildcards are supported.
11+
/// When omitted, returns all packages in the specified feed.
12+
/// </summary>
13+
[Parameter(Position = 0)]
14+
[ValidateNotNullOrEmpty]
15+
[Alias("Package")]
16+
public object Artifact { get; set; } = "*";
17+
18+
/// <summary>
19+
/// Specifies the feed name.
20+
/// </summary>
21+
[Parameter(ValueFromPipeline = true, Mandatory = true)]
22+
[ValidateNotNullOrEmpty]
23+
public object Feed { get; set; }
24+
25+
/// <summary>
26+
/// Includes deletes packages in the result.
27+
/// </summary>
28+
[Parameter()]
29+
public SwitchParameter IncludeDeleted { get; set; }
30+
31+
/// <summary>
32+
/// Includes the package description in the results.
33+
/// </summary>
34+
[Parameter()]
35+
public SwitchParameter IncludeDescription { get; set; }
36+
37+
/// <summary>
38+
/// Includes prerelease packages in the results. Applies only to Nuget packages.
39+
/// </summary>
40+
[Parameter()]
41+
public SwitchParameter IncludePrerelease { get; set; }
42+
43+
/// <summary>
44+
/// Includes delisted packages in the results. Applies only to Nuget packages.
45+
/// </summary>
46+
[Parameter()]
47+
public SwitchParameter IncludeDelisted { get; set; }
48+
49+
/// <summary>
50+
/// Returns only packages of the specified protocol type.
51+
/// </summary>
52+
[Parameter()]
53+
public string ProtocolType { get; set; }
54+
55+
[Parameter()]
56+
internal bool IncludeAllVersions { get; set; }
57+
}
58+
}

0 commit comments

Comments
 (0)