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

🩹 [Patch]: Add context, cleanup parameters and param handling #177

Merged
merged 6 commits into from
Dec 4, 2024
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 Coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
</tr>
<tr>
<td>Covered functions</td>
<td>153</td>
<td>155</td>
</tr>
<tr>
<td>Missing functions</td>
<td>832</td>
<td>830</td>
</tr>
<tr>
<td>Coverage</td>
<td>15.53%</td>
<td>15.74%</td>
</tr>
</table>

Expand All @@ -30,8 +30,8 @@
| `/advisories/{ghsa_id}` | | :x: | | | |
| `/app` | | :white_check_mark: | | | |
| `/app-manifests/{code}/conversions` | | | | :x: | |
| `/app/hook/config` | | :x: | :x: | | |
| `/app/hook/deliveries` | | :x: | | | |
| `/app/hook/config` | | :white_check_mark: | :x: | | |
| `/app/hook/deliveries` | | :white_check_mark: | | | |
| `/app/hook/deliveries/{delivery_id}` | | :x: | | | |
| `/app/hook/deliveries/{delivery_id}/attempts` | | | | :x: | |
| `/app/installation-requests` | | :x: | | | |
Expand Down
2 changes: 1 addition & 1 deletion scripts/Set-CoverageReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function Find-APIMethod {
.SYNOPSIS
Find API methods in a directory
#>
param (
param(
[Parameter(Mandatory)]
[string] $SearchDirectory,

Expand Down
12 changes: 8 additions & 4 deletions src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
filter Get-GitHubGitignoreByName {
filter Get-GitHubGitignoreByName {
<#
.SYNOPSIS
Get a gitignore template
Expand All @@ -17,14 +17,18 @@ filter Get-GitHubGitignoreByName {

#>
[CmdletBinding()]
param (
param(
[Parameter(Mandatory)]
[string] $Name,

# The context to run the command in.
[Parameter()]
[ValidateNotNullOrEmpty()]
[string] $Name
[string] $Context
)

process {
$inputObject = @{
Context = $Context
APIEndpoint = "/gitignore/templates/$Name"
Accept = 'application/vnd.github.raw+json'
Method = 'GET'
Expand Down
10 changes: 7 additions & 3 deletions src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
filter Get-GitHubGitignoreList {
filter Get-GitHubGitignoreList {
<#
.SYNOPSIS
Get all gitignore templates
Expand All @@ -18,15 +18,19 @@ filter Get-GitHubGitignoreList {
#>
[OutputType([string[]])]
[CmdletBinding()]
param ()
param(
# The context to run the command in.
[Parameter()]
[string] $Context
)

$inputObject = @{
Context = $Context
APIEndpoint = '/gitignore/templates'
Method = 'GET'
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}

}
15 changes: 9 additions & 6 deletions src/functions/private/License/Get-GitHubLicenseByName.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
filter Get-GitHubLicenseByName {
filter Get-GitHubLicenseByName {
<#
.SYNOPSIS
Get a license
Expand All @@ -18,16 +18,20 @@ filter Get-GitHubLicenseByName {
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding()]
param (
param(
# The license keyword, license name, or license SPDX ID. For example, mit or mpl-2.0.
[Parameter()]
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory)]
[Alias('license')]
[string] $Name
[string] $Name,

# The context to run the command in.
[Parameter()]
[string] $Context
)

process {
$inputObject = @{
Context = $Context
APIEndpoint = "/licenses/$Name"
Accept = 'application/vnd.github+json'
Method = 'GET'
Expand All @@ -36,6 +40,5 @@ filter Get-GitHubLicenseByName {
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}

}
}
9 changes: 7 additions & 2 deletions src/functions/private/License/Get-GitHubLicenseList.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
filter Get-GitHubLicenseList {
filter Get-GitHubLicenseList {
<#
.SYNOPSIS
Get all commonly used licenses
Expand All @@ -19,9 +19,14 @@ filter Get-GitHubLicenseList {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[OutputType([string[]])]
[CmdletBinding()]
param ()
param(
# The context to run the command in.
[Parameter()]
[string] $Context
)

$inputObject = @{
Context = $Context
APIEndpoint = '/licenses'
Method = 'GET'
}
Expand Down
15 changes: 10 additions & 5 deletions src/functions/private/License/Get-GitHubRepositoryLicense.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
filter Get-GitHubRepositoryLicense {
filter Get-GitHubRepositoryLicense {
<#
.SYNOPSIS
Get the license for a repository
Expand All @@ -19,17 +19,22 @@ filter Get-GitHubRepositoryLicense {

#>
[CmdletBinding()]
param (
param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[string] $Owner = (Get-GitHubContextSetting -Name Owner),
[Parameter(Mandatory)]
[string] $Owner,

# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter(Mandatory)]
[string] $Repo,

# The context to run the command in.
[Parameter()]
[string] $Repo = (Get-GitHubContextSetting -Name Repo)
[string] $Context
)

$inputObject = @{
Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/license"
Accept = 'application/vnd.github+json'
Method = 'GET'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
param (
param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
Expand All @@ -36,11 +36,15 @@
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
[Alias('login')]
[string] $Username
[string] $Username,

# The context to run the command in.
[Parameter()]
[string] $Context
)

$inputObject = @{
Context = $Context
APIEndpoint = "/orgs/$OrganizationName/blocks/$Username"
Method = 'PUT'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
param (
param(
# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('org')]
Expand All @@ -27,14 +27,19 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
[int] $PerPage = 30
[int] $PerPage = 30,

# The context to run the command in.
[Parameter()]
[string] $Context
)

$body = @{
per_page = $PerPage
}

$inputObject = @{
Context = $Context
APIEndpoint = "/orgs/$OrganizationName/blocks"
Method = 'GET'
Body = $body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
param (
param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
Expand All @@ -35,10 +35,15 @@
Mandatory,
ValueFromPipelineByPropertyName
)]
[string] $Username
[string] $Username,

# The context to run the command in.
[Parameter()]
[string] $Context
)

$inputObject = @{
Context = $Context
APIEndpoint = "/orgs/$OrganizationName/blocks/$Username"
Method = 'GET'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
param (
param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
Expand All @@ -36,10 +36,15 @@
ValueFromPipelineByPropertyName
)]
[Alias('login')]
[string] $Username
[string] $Username,

# The context to run the command in.
[Parameter()]
[string] $Context
)

$inputObject = @{
Context = $Context
APIEndpoint = "/orgs/$OrganizationName/blocks/$Username"
Method = 'DELETE'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding()]
param (
param(
# A organization ID. Only return organizations with an ID greater than this ID.
[Parameter()]
[int] $Since = 0,

# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
[int] $PerPage = 30
[int] $PerPage = 30,

# The context to run the command in.
[Parameter()]
[string] $Context
)

$body = @{
Expand All @@ -38,6 +42,7 @@
}

$inputObject = @{
Context = $Context
APIEndpoint = '/organizations'
Method = 'GET'
Body = $body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,23 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
param (
param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
[int] $PerPage = 30
[int] $PerPage = 30,

# The context to run the command in.
[Parameter()]
[string] $Context
)

$body = @{
per_page = $PerPage
}

$inputObject = @{
Context = $Context
APIEndpoint = '/user/orgs'
Method = 'GET'
Body = $body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
param (
param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
Expand All @@ -34,11 +34,16 @@
[Alias('login')]
[Alias('org')]
[Alias('owner')]
[string] $OrganizationName
[string] $OrganizationName,

# The context to run the command in.
[Parameter()]
[string] $Context
)


$inputObject = @{
Context = $Context
APIEndpoint = "/orgs/$OrganizationName"
Method = 'GET'
}
Expand Down
Loading
Loading