From eb6b8e3dbdbfee6cce7fc364325fc59c0540c2a1 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 6 Feb 2025 18:50:30 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Rename=20`Url`=20para?= =?UTF-8?q?meter=20to=20`HomepageUrl`=20and=20add=20`Description`=20and=20?= =?UTF-8?q?`CallbackUrls`=20parameters=20for=20GitHub=20App=20creation=20f?= =?UTF-8?q?unctions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GitHub App}/Convert-GitHubAppManifest.ps1 | 4 +- .../Invoke-GitHubAppCreationForm.ps1 | 4 +- .../public/Apps/GitHub App/New-GitHubApp.ps1 | 44 +++++++++++-------- 3 files changed, 29 insertions(+), 23 deletions(-) rename src/functions/{private/Apps/GitHub Apps => public/Apps/GitHub App}/Convert-GitHubAppManifest.ps1 (100%) rename src/functions/{private/Apps/GitHub Apps => public/Apps/GitHub App}/Invoke-GitHubAppCreationForm.ps1 (98%) diff --git a/src/functions/private/Apps/GitHub Apps/Convert-GitHubAppManifest.ps1 b/src/functions/public/Apps/GitHub App/Convert-GitHubAppManifest.ps1 similarity index 100% rename from src/functions/private/Apps/GitHub Apps/Convert-GitHubAppManifest.ps1 rename to src/functions/public/Apps/GitHub App/Convert-GitHubAppManifest.ps1 index ade3da18e..f85cfbaac 100644 --- a/src/functions/private/Apps/GitHub Apps/Convert-GitHubAppManifest.ps1 +++ b/src/functions/public/Apps/GitHub App/Convert-GitHubAppManifest.ps1 @@ -36,9 +36,9 @@ process { $inputObject = @{ - Context = $Context - APIEndpoint = "/app-manifests/$Code/conversions" Method = 'GET' + APIEndpoint = "/app-manifests/$Code/conversions" + Context = $Context } $response = Invoke-GitHubAPI @inputObject | Select-Object -ExpandProperty Response diff --git a/src/functions/private/Apps/GitHub Apps/Invoke-GitHubAppCreationForm.ps1 b/src/functions/public/Apps/GitHub App/Invoke-GitHubAppCreationForm.ps1 similarity index 98% rename from src/functions/private/Apps/GitHub Apps/Invoke-GitHubAppCreationForm.ps1 rename to src/functions/public/Apps/GitHub App/Invoke-GitHubAppCreationForm.ps1 index 12d484de1..25e31c579 100644 --- a/src/functions/private/Apps/GitHub Apps/Invoke-GitHubAppCreationForm.ps1 +++ b/src/functions/public/Apps/GitHub App/Invoke-GitHubAppCreationForm.ps1 @@ -34,7 +34,7 @@ function Invoke-GitHubAppCreationForm { # The homepage URL of the GitHub App. [Parameter(Mandatory)] - [string] $Url, + [string] $HomepageUrl, # Enables webhook support for the GitHub App. [Parameter()] @@ -107,7 +107,7 @@ function Invoke-GitHubAppCreationForm { # Build the manifest object $manifest = @{ name = $Name - url = $Url + url = $HomepageUrl hook_attributes = @{ url = $WebhookURL active = $WebhookEnabled diff --git a/src/functions/public/Apps/GitHub App/New-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/New-GitHubApp.ps1 index 2a3fcc866..1bea8b384 100644 --- a/src/functions/public/Apps/GitHub App/New-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/New-GitHubApp.ps1 @@ -15,16 +15,24 @@ .NOTES [GitHub Apps](https://docs.github.com/apps) - #> + #> [CmdletBinding(DefaultParameterSetName = 'Personal', SupportsShouldProcess)] param( # The name of the GitHub App. [Parameter()] [string] $Name, + # A brief description of the GitHub App. + [Parameter()] + [string] $Description, + # The main URL of the GitHub App. [Parameter(Mandatory)] - [string] $Url, + [string] $HomepageUrl, + + # List of callback URLs for OAuth authentication. + [Parameter()] + [string[]] $CallbackUrls, # The webhook URL for event notifications. [Parameter()] @@ -38,18 +46,10 @@ [Parameter()] [string] $RedirectUrl, - # List of callback URLs for OAuth authentication. - [Parameter()] - [string[]] $CallbackUrls, - # The setup URL for the GitHub App. [Parameter()] [string] $SetupUrl, - # A brief description of the GitHub App. - [Parameter()] - [string] $Description, - # Specifies whether the app should be publicly visible. [Parameter()] [switch] $Public, @@ -70,17 +70,22 @@ [Parameter()] [switch] $SetupOnUpdate, - # The organization under which the app is being created (Organization parameter set). - [Parameter(ParameterSetName = 'Organization', Mandatory)] - [string] $Organization, - # The enterprise under which the app is being created (Enterprise parameter set). [Parameter(ParameterSetName = 'Enterprise', Mandatory)] [string] $Enterprise, + # The organization under which the app is being created (Organization parameter set). + [Parameter(ParameterSetName = 'Organization', Mandatory)] + [string] $Organization, + # The state parameter for additional configuration. [Parameter()] - [string] $State + [string] $State, + + # The context to run the command in. Used to get the details for the API call. + # Can be either a string or a GitHubContext object. + [Parameter()] + [object] $Context = (Get-GitHubContext) ) begin { $stackPath = $MyInvocation.MyCommand.Name @@ -90,22 +95,23 @@ Write-Verbose 'Initiating GitHub App creation process...' # Step 1: Send manifest and get the temporary code $params = @{ + Enterprise = $Enterprise + Organization = $Organization Name = $Name - Url = $Url + HomepageUrl = $HomepageUrl WebhookEnabled = $WebhookEnabled WebhookURL = $WebhookURL RedirectUrl = $RedirectUrl CallbackUrls = $CallbackUrls SetupUrl = $SetupUrl Description = $Description - Public = $Public Events = $Events Permissions = $Permissions RequestOAuthOnInstall = $RequestOAuthOnInstall SetupOnUpdate = $SetupOnUpdate - Enterprise = $Enterprise - Org = $Organization + Public = $Public State = $State + Context = $Context } $code = Invoke-GitHubAppCreationForm @params