Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review of remove dynamic params #289

Merged
merged 48 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
33fe74a
Add parameter classes
Jan 20, 2020
95860f6
import classes via PSD1, add exportFunctions list
Jan 20, 2020
a265bc7
Replace dynamic parameters with clasess
Jan 20, 2020
a42840a
Move _Supports* functionality into calling fn
Jan 21, 2020
da9245e
remove _isonwindows
Jan 21, 2020
2beaa35
remove _applyTypes
Jan 21, 2020
978e0cc
fix break of Add-VSteamWorkItem, improve build
Jan 21, 2020
1fd09ed
Merge remote-tracking branch 'upstream/master'
jhoneill Feb 27, 2020
c27dc5f
Use Invoke-VSTeamRequest externally and make _callApi Private again
jhoneill Feb 28, 2020
688bdf4
Auto-update of md help with 6.4.4 changes
Feb 28, 2020
e2bb372
Allow $env:testing to bypass validation checks
Feb 28, 2020
3467ddd
fix issue Getting build artifacts with no properties field
Feb 28, 2020
427114f
Fix regressions and modify mocking in tests to work with new classes
jhoneill Mar 1, 2020
d1bc72f
ensure validator doesn't break tests fix a couple more regressions & …
jhoneill Mar 1, 2020
99871e2
Merge remote-tracking branch 'upstream/master'
jhoneill Mar 1, 2020
7af8dab
Merge remote-tracking branch 'upstream/master'
jhoneill Mar 1, 2020
2fab630
Tidy class loading - Merge classes to PSM1 file.
Mar 17, 2020
51d9b49
Merge remote-tracking branch 'upstream/master'
jhoneill Mar 17, 2020
9d53c00
fix ProcessCompleter
Mar 17, 2020
e990b83
fix ProcessCompleter
Mar 17, 2020
80fcb5f
Merge branch 'master' of https://github.com/jhoneill/vsteam
jhoneill Mar 17, 2020
2608b10
Fixed tests to not mix source & built files.
Mar 18, 2020
fed84c4
Re-introduced a mockable to help one test (CI has 3 param not founds …
jhoneill Mar 19, 2020
abdb3a1
Fix build when file encodings are mixed
jhoneill Mar 31, 2020
2dea841
Merge remote-tracking branch 'upstream/master'
jhoneill Apr 7, 2020
54c2006
Updated all the unit tests.
DarqueWarrior Apr 8, 2020
2f10c8c
Initial pass
DarqueWarrior Apr 8, 2020
7f96819
Added tests for ValidateProjectAttribute
DarqueWarrior Apr 8, 2020
a26636b
All tests passing again.
DarqueWarrior Apr 13, 2020
3a97ced
Fixed file casing.
DarqueWarrior Apr 13, 2020
60bbcb4
Modified Invokepester to not load module.
DarqueWarrior Apr 14, 2020
9827016
Updated Invoke-VSTeamRequest Tests.
DarqueWarrior Apr 15, 2020
721d8c7
Polished Tests
DarqueWarrior Apr 17, 2020
eb98259
Fixed Invoke-VSTeamRequest tests
DarqueWarrior Apr 23, 2020
6b8d771
Fixed Set-VSTeamPermissions tests
DarqueWarrior Apr 27, 2020
776e797
Merge branch 'master' into review
DarqueWarrior Apr 27, 2020
ab30bd7
Added ValueFromPipelineByPropertyName = $true to ProjectName parameters
DarqueWarrior Apr 27, 2020
17c607c
Merge branch 'master' into review
DarqueWarrior Apr 28, 2020
cd43ae2
Removed InModuleScope from Init Tests.
DarqueWarrior Apr 29, 2020
2c97ea9
Moved sample files for integration tests.
DarqueWarrior Apr 29, 2020
f3e7e81
Renamed stages of integration tests.
DarqueWarrior Apr 29, 2020
2fb3405
Renamed ProcessCompleter to ProcessTemplateCompleter
DarqueWarrior Apr 29, 2020
9cbdf5c
Fixed tests to Set-VSTeamAlias
DarqueWarrior Apr 29, 2020
cdcdcad
Added comments to Build completers
DarqueWarrior Apr 29, 2020
89ea934
Addressing issue #296
DarqueWarrior May 1, 2020
3680044
Addressing issue #297
DarqueWarrior May 1, 2020
75faa8b
Updated the Compatible PS Editions
DarqueWarrior May 1, 2020
be687d7
Updated change log and version 6.4.7
DarqueWarrior May 1, 2020
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
3 changes: 0 additions & 3 deletions .editorconfig

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Source/Classes/vsteam.classes.ps1
/dist
test-results.xml
coverage.xml
.editorconfig
.vscode/settings.json
.DS_Store
._.DS_Store
**/.DS_Store
Expand Down
19 changes: 5 additions & 14 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,9 @@
"vssgp",
"vssps"
],
"workbench.colorCustomizations": {
"activityBar.background": "#007699",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#ff80e2",
"activityBarBadge.foreground": "#15202b",
"titleBar.activeBackground": "#004f66",
"titleBar.inactiveBackground": "#004f6699",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveForeground": "#e7e7e799",
"statusBar.background": "#004f66",
"statusBarItem.hoverBackground": "#007699",
"statusBar.foreground": "#e7e7e7"
}
"terminal.integrated.commandsToSkipShell": [
"PowerShell.RunSelection",
"workbench.action.files.save",
"workbench.action.files.newUntitled"
]
}
6 changes: 3 additions & 3 deletions Build-Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Copy-Item -Path ./Source/VSTeam.psm1 -Destination "$output/VSTeam.psm1" -Force

Write-Output 'Updating Functions To Export'
$newValue = ((Get-ChildItem -Path "./Source/Public" -Filter '*.ps1').BaseName |
ForEach-Object -Process { Write-Output "'$_'" }) -join ','
ForEach-Object -Process { Write-Output "'$_'" }) -join ','

(Get-Content "./Source/VSTeam.psd1") -Replace ("FunctionsToExport.+", "FunctionsToExport = ($newValue)") | Set-Content "$output/VSTeam.psd1"

Expand All @@ -107,7 +107,7 @@ if ($ipmo.IsPresent -or $runTests.IsPresent) {

# run the unit tests with Pester
if ($runTests.IsPresent) {
if ($null -eq $(Get-Module -Name Pester)) {
if ($null -eq $(Get-Module -ListAvailable Pester)) {
Install-Module -Name Pester -Repository PSGallery -Force -Scope CurrentUser -AllowClobber -SkipPublisherCheck
}

Expand All @@ -120,7 +120,7 @@ if ($runTests.IsPresent) {
}

if ($codeCoverage.IsPresent) {
$pesterArgs.CodeCoverage = "$outputDir\*.ps1"
$pesterArgs.CodeCoverage = "./Source/**/*.ps1"
$pesterArgs.CodeCoverageOutputFile = "coverage.xml"
$pesterArgs.CodeCoverageOutputFileFormat = 'JaCoCo'
}
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

_callAPI, _buildRequestURI and Invoke-VSTeamRequest now support UseProjectId switch if the Project ID is required for the API call.

Addressed following issues:

- Do not change the strict mode setting for the user's PowerShell session [#296](https://github.com/DarqueWarrior/vsteam/issues/296)
- Consider reducing the scope of the default parameter "Project" from "*" to "*-VsTeam*" [#297](https://github.com/DarqueWarrior/vsteam/issues/297)

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/275) from [Jhoneill](https://github.com/jhoneill) which included the following:

- Removing Dynamic parameters for completer and validator attributes.

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/283) from [Sebastian Schütze](https://github.com/SebastianSchuetze) which included the following:

- Added Get-VSTeamBuildTimeline to get timeline of a build
Expand Down Expand Up @@ -898,4 +907,4 @@ Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/3) from [Andy

## 0.1.14

Initial Open Source release
Initial Open Source release
41 changes: 41 additions & 0 deletions Source/Classes/BuildCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using namespace System.Collections
using namespace System.Collections.Generic
using namespace System.Management.Automation

# This class defines an attribute that allows the user the tab complete
# build numbers for function parameters. For this completer to work the
# users must have already provided the ProjectName parameter for the
# function or set a default project.
class BuildCompleter : IArgumentCompleter {
[IEnumerable[CompletionResult]] CompleteArgument(
[string] $CommandName,
[string] $ParameterName,
[string] $WordToComplete,
[Language.CommandAst] $CommandAst,
[IDictionary] $FakeBoundParameters) {

$results = [List[CompletionResult]]::new()

# If the user has explictly added the -ProjectName parameter
# to the command use that instead of the default project.
$projectName = $FakeBoundParameters['ProjectName']

# Only use the default project if the ProjectName parameter was
# not used
if (-not $projectName) {
$projectName = _getDefaultProject
}

# If there is no projectName by this point just return a empty
# list.
if ($projectName) {
foreach ($b in (Get-VSTeamBuild -ProjectName $projectName)) {
if ($b.buildNumber -like "$WordToComplete*") {
$results.Add([CompletionResult]::new($b.buildNumber))
}
}
}

return $results
}
}
41 changes: 41 additions & 0 deletions Source/Classes/BuildDefinitionCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using namespace System.Collections
using namespace System.Collections.Generic
using namespace System.Management.Automation

# This class defines an attribute that allows the user the tab complete
# build definition names for function parameters. For this completer to
# work the users must have already provided the ProjectName parameter for
# the function or set a default project.
class BuildDefinitionCompleter : IArgumentCompleter {
[IEnumerable[CompletionResult]] CompleteArgument(
[string] $CommandName,
[string] $ParameterName,
[string] $WordToComplete,
[Language.CommandAst] $CommandAst,
[IDictionary] $FakeBoundParameters) {

$results = [List[CompletionResult]]::new()

# If the user has explictly added the -ProjectName parameter
# to the command use that instead of the default project.
$projectName = $FakeBoundParameters['ProjectName']

# Only use the default project if the ProjectName parameter was
# not used
if (-not $projectName) {
$projectName = _getDefaultProject
}

# If there is no projectName by this point just return a empty
# list.
if ($projectName) {
foreach ($b in (Get-VSTeamBuildDefinition -ProjectName $projectName)) {
if ($b.name -like "*$WordToComplete*") {
$results.Add([CompletionResult]::new($b.name))
}
}
}

return $results
}
}
30 changes: 30 additions & 0 deletions Source/Classes/ProcessTemplateCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using namespace System.Collections
using namespace System.Collections.Generic
using namespace System.Management.Automation

# This class defines an attribute that allows the user the tab complete
# process templates for function parameters.
class ProcessTemplateCompleter : IArgumentCompleter {
[IEnumerable[CompletionResult]] CompleteArgument(
[string] $CommandName,
[string] $ParameterName,
[string] $WordToComplete,
[Language.CommandAst] $CommandAst,
[IDictionary] $FakeBoundParameters) {

$results = [List[CompletionResult]]::new()

if (_hasProcessTemplateCacheExpired) {
[VSTeamProcessCache]::processes = _getProcesses
[VSTeamProcessCache]::timestamp = (Get-Date).Minute
}

foreach ($p in [VSTeamProcessCache]::processes) {
if ($p -like "*$WordToComplete*") {
$results.Add([CompletionResult]::new($p))
}
}

return $results
}
}
19 changes: 19 additions & 0 deletions Source/Classes/ProcessValidateAttribute.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using namespace System.Management.Automation

class ProcessValidateAttribute : ValidateArgumentsAttribute {
[void] Validate(
[object] $arguments,
[EngineIntrinsics] $EngineIntrinsics) {

if (_hasProcessTemplateCacheExpired) {
[VSTeamProcessCache]::processes = _getProcesses
[VSTeamProcessCache]::timestamp = (Get-Date).Minute
}

if (($null -ne [VSTeamProcessCache]::processes) -and (-not ($arguments -in [VSTeamProcessCache]::processes))) {
throw [ValidationMetadataException]::new(
"'$arguments' is not a valid process. Valid processes are: '" +
([VSTeamProcessCache]::processes -join "', '") + "'")
}
}
}
28 changes: 28 additions & 0 deletions Source/Classes/ProjectCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using namespace System.Collections
using namespace System.Collections.Generic
using namespace System.Management.Automation

class ProjectCompleter : IArgumentCompleter {
[IEnumerable[CompletionResult]] CompleteArgument(
[string] $CommandName,
[string] $ParameterName,
[string] $WordToComplete,
[Language.CommandAst] $CommandAst,
[IDictionary] $FakeBoundParameters) {

$results = [List[CompletionResult]]::new()

if (_hasProjectCacheExpired) {
[VSTeamProjectCache]::projects = _getProjects
[VSTeamProjectCache]::timestamp = (Get-Date).Minute
}

foreach ($p in [VSTeamProjectCache]::projects) {
if ($p -like "*$WordToComplete*") {
$results.Add([CompletionResult]::new($p))
}
}

return $results
}
}
19 changes: 19 additions & 0 deletions Source/Classes/ProjectValidateAttribute.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using namespace System.Management.Automation

class ProjectValidateAttribute : ValidateArgumentsAttribute {
[void] Validate(
[object] $arguments,
[EngineIntrinsics] $EngineIntrinsics) {

if (_hasProjectCacheExpired) {
[VSTeamProjectCache]::projects = _getProjects
[VSTeamProjectCache]::timestamp = (Get-Date).Minute
}

if (($null -ne [VSTeamProjectCache]::projects) -and (-not ($arguments -in [VSTeamProjectCache]::projects))) {
throw [ValidationMetadataException]::new(
"'$arguments' is not a valid project. Valid projects are: '" +
([VSTeamProjectCache]::projects -join "', '") + "'")
}
}
}
37 changes: 37 additions & 0 deletions Source/Classes/ReleaseDefinitionCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using namespace System.Collections
using namespace System.Collections.Generic
using namespace System.Management.Automation

class ReleaseDefinitionCompleter : IArgumentCompleter {
[IEnumerable[CompletionResult]] CompleteArgument(
[string] $CommandName,
[string] $ParameterName,
[string] $WordToComplete,
[Language.CommandAst] $CommandAst,
[IDictionary] $FakeBoundParameters) {

$results = [List[CompletionResult]]::new()

# If the user has explictly added the -ProjectName parameter
# to the command use that instead of the default project.
$projectName = $FakeBoundParameters['ProjectName']

# Only use the default project if the ProjectName parameter was
# not used
if (-not $projectName) {
$projectName = _getDefaultProject
}

# If there is no projectName by this point just return a empty
# list.
if ($projectName) {
foreach ($r in (Get-VSTeamReleaseDefinition -ProjectName $projectName)) {
if ($r.name -like "*$WordToComplete*") {
$results.Add([CompletionResult]::new($r.name))
}
}
}

return $results
}
}
37 changes: 37 additions & 0 deletions Source/Classes/TeamQueueCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using namespace System.Collections
using namespace System.Collections.Generic
using namespace System.Management.Automation

class TeamQueueCompleter : IArgumentCompleter {
[IEnumerable[CompletionResult]] CompleteArgument(
[string] $CommandName,
[string] $ParameterName,
[string] $WordToComplete,
[Language.CommandAst] $CommandAst,
[IDictionary] $FakeBoundParameters) {

$results = [List[CompletionResult]]::new()

# If the user has explictly added the -ProjectName parameter
# to the command use that instead of the default project.
$projectName = $FakeBoundParameters['ProjectName']

# Only use the default project if the ProjectName parameter was
# not used
if (-not $projectName) {
$projectName = _getDefaultProject
}

# If there is no projectName by this point just return a empty
# list.
if ($projectName) {
foreach ($q in (Get-VSTeamQueue -ProjectName $projectName)) {
if ($q.name -like "*$WordToComplete*") {
$results.Add([CompletionResult]::new($q.name))
}
}
}

return $results
}
}
29 changes: 29 additions & 0 deletions Source/Classes/UncachedProjectCompleter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using namespace System.Collections
using namespace System.Collections.Generic
using namespace System.Management.Automation

class UncachedProjectCompleter : IArgumentCompleter {
[IEnumerable[CompletionResult]] CompleteArgument(
[string] $CommandName,
[string] $ParameterName,
[string] $WordToComplete,
[Language.CommandAst] $CommandAst,
[IDictionary] $FakeBoundParameters) {

$results = [List[CompletionResult]]::new()

[VSTeamProjectCache]::projects = _getProjects
[VSTeamProjectCache]::timestamp = (Get-Date).Minute

foreach ($p in [VSTeamProjectCache]::projects) {
if ($p -like "*$WordToComplete*" -and $p -match "\s") {
$results.Add([CompletionResult]::new("'$p'"))
}
elseif ($p -like "*$WordToComplete*") {
$results.Add([CompletionResult]::new($p))
}
}

return $results
}
}
Loading