From 1fc5300b73b99243a8ea595df95eb171e8cfbb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Fri, 23 Jan 2026 13:31:53 +0100 Subject: [PATCH 01/10] feat(use_order): add PassThru parameter handling in Use-Order function --- public/items/use_order.ps1 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/public/items/use_order.ps1 b/public/items/use_order.ps1 index 3cf3596..7ac08c7 100644 --- a/public/items/use_order.ps1 +++ b/public/items/use_order.ps1 @@ -5,7 +5,8 @@ function Use-Order { [Parameter(Position = 0)][int]$Ordinal = -1, [Parameter(ValueFromPipeline)][array]$List, [Parameter()][switch]$OpenInEditor, - [Parameter()][Alias("w")][switch]$OpenInBrowser + [Parameter()][Alias("w")][switch]$OpenInBrowser, + [Parameter()][switch]$PassThru ) begin { @@ -37,8 +38,14 @@ function Use-Order { $item = Get-ProjectItem -ItemId $itemId Open-Url $($item.url) } else { - # Show - Show-ProjectItem -Item $itemId -OpenInEditor:$OpenInEditor + if($PassThru) { + #return item + $i = Get-ProjectItem -ItemId $itemId + return [PsCustomObject]$i + } else { + # Show + Show-ProjectItem -Item $itemId -OpenInEditor:$OpenInEditor + } } } else { From 554349a8b9e465e298a2a53187f74b7aaf998f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Mon, 26 Jan 2026 09:18:29 +0100 Subject: [PATCH 02/10] feat(openFilesUrls): add function to invoke URLs based on OS --- include/openFilesUrls.ps1 | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/include/openFilesUrls.ps1 b/include/openFilesUrls.ps1 index 1a2c366..7306bc7 100644 --- a/include/openFilesUrls.ps1 +++ b/include/openFilesUrls.ps1 @@ -1,13 +1,17 @@ -function Open-Url { + +# Include openFilesUrls.ps1 +# Provides controls to open files and URLs in the default system applications. +# Use $MODULE_NAME variable to set up functions names + +Set-MyInvokeCommandAlias -Alias OpenUrl -Command "Invoke-$($MODULE_NAME)OpenUrl -Url {url}" + +function Invoke-ModuleNameOpenUrl{ [CmdletBinding()] - param ( - [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] - [ValidateNotNullOrEmpty()] - [string]$Url + param( + [Parameter(Mandatory = $true)][string]$Url ) - process { - try { + try { # Determine the operating system if ($IsWindows -or $env:OS -match "Windows") { # Windows - use Start-Process @@ -47,6 +51,21 @@ function Open-Url { catch { Write-Error "Failed to open URL: $_" } +} +Copy-Item -path Function:Invoke-ModuleNameOpenUrl -Destination Function:"Invoke-$($MODULE_NAME)OpenUrl" +Export-ModuleMember -Function "Invoke-$($MODULE_NAME)OpenUrl" + + +function Open-Url { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [ValidateNotNullOrEmpty()] + [string]$Url + ) + + process { + Invoke-MyCommand -Command OpenUrl -Parameters @{url = $Url} } } From 611347e188eb36b2d04a1a1ab9126e97747aaede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Mon, 26 Jan 2026 09:18:50 +0100 Subject: [PATCH 03/10] refactor(Show-ProjectItem): rename OpenInWebBrowser parameter to OpenInBrowser --- public/items/project_item_show.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/items/project_item_show.ps1 b/public/items/project_item_show.ps1 index 6c47e21..241764b 100644 --- a/public/items/project_item_show.ps1 +++ b/public/items/project_item_show.ps1 @@ -10,7 +10,7 @@ function Show-ProjectItem{ [Parameter()][array[]]$FieldsToShow, [Parameter()][switch]$AllComments, [Parameter()][switch]$OpenInEditor, - [Parameter()][Alias("W")][switch]$OpenInWebBrowser + [Parameter()][Alias("W")][switch]$OpenInBrowser ) begin{ @@ -26,7 +26,7 @@ function Show-ProjectItem{ $item = Get-ProjectItem -ItemId $ItemId - if($OpenInWebBrowser){ + if($OpenInBrowser){ Open-Url -Url $item.url } From 3402aa1814d4e53643b0e0785646a27e4b9b1a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Mon, 26 Jan 2026 09:22:56 +0100 Subject: [PATCH 04/10] feat(use_order): implement item ordering and add tests for Use-Order function --- Test/private/MockCall_Project700.ps1 | 1 + Test/public/items/use_order.test.ps1 | 59 ++++++++++++++++++++++++++++ Test/traceInvoke.log | 1 + public/items/use_order.ps1 | 37 ++++++++--------- 4 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 Test/public/items/use_order.test.ps1 diff --git a/Test/private/MockCall_Project700.ps1 b/Test/private/MockCall_Project700.ps1 index 57cb88e..16ae130 100644 --- a/Test/private/MockCall_Project700.ps1 +++ b/Test/private/MockCall_Project700.ps1 @@ -85,6 +85,7 @@ function Get-Mock_Project_700 { $issue = $pActual.items.nodes | Where-Object { $_.content.title -eq "Issue for development" } $fss = $issue.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldsingleselect.id) } $project.issue = @{ + order = 20 # order of this item when calling spi id = $issue.id number = $issue.content.number contentId = $issue.content.id diff --git a/Test/public/items/use_order.test.ps1 b/Test/public/items/use_order.test.ps1 new file mode 100644 index 0000000..b743e36 --- /dev/null +++ b/Test/public/items/use_order.test.ps1 @@ -0,0 +1,59 @@ +function Test_UserOrder_Success{ + MockCall_GetProject_700 + + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number + + $list = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -IncludeDone + + # Act + $result = $list | Use-Order + + Assert-Count -Expected $($p.items.totalCount +4) -Presented $result + +} + +function Test_UserOrder_Success_GetItem{ + MockCall_GetProject_700 + + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number + + $list = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -IncludeDone + + # Act + $result = $list | Use-Order 1 -PassThru + + Assert-AreEqual -Expected $($list[1].id) -Presented $result.id +} + +function Test_UserOrder_Success_OpenBrowser{ + MockCall_GetProject_700 + + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number + $order = $p.issue.order ; $url = $p.issue.url + + MockCallToNull -command "Invoke-ProjectHelperOpenUrl -Url $url" + + $list = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -IncludeDone + + # Act + $result = $list | Use-Order $order -OpenInBrowser + + # Assert + Assert-IsNull -Object $result +} + +function Test_UserOrder_Success_Passthru{ + MockCall_GetProject_700 + + $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number + $order = $p.issue.order ; $id = $p.issue.id + + $list = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -IncludeDone + + # Act + $result = $list | Use-Order $order -PassThru + + # Assert + Assert-AreEqual -Expected $id -Presented $result.id +} + diff --git a/Test/traceInvoke.log b/Test/traceInvoke.log index 1f1dcb2..8b78f4d 100644 --- a/Test/traceInvoke.log +++ b/Test/traceInvoke.log @@ -80,3 +80,4 @@ Invoke-GetUser -Handle rauldibildos Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators "MDQ6VXNlcjY4ODQ0MDg= U_kgDOC_E3gw" -Role "WRITER" Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields "" -afterItems "" -query "updated:>=2024-02-18" Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields "" -afterItems "" -query "updated:>=2025-03-15" +Invoke-ProjectHelperOpenUrl -Url https://github.com/octodemo/rulasg-dev-1/issues/26 diff --git a/public/items/use_order.ps1 b/public/items/use_order.ps1 index 7ac08c7..3aca285 100644 --- a/public/items/use_order.ps1 +++ b/public/items/use_order.ps1 @@ -29,27 +29,24 @@ function Use-Order { } end { - if ($Ordinal -gt -1) { - $itemId = $finallist[$Ordinal].id - - - if($OpenInBrowser){ - # Open - $item = Get-ProjectItem -ItemId $itemId - Open-Url $($item.url) - } else { - if($PassThru) { - #return item - $i = Get-ProjectItem -ItemId $itemId - return [PsCustomObject]$i - } else { - # Show - Show-ProjectItem -Item $itemId -OpenInEditor:$OpenInEditor - } - } + + # Show list of items + if ($Ordinal -lt 0) { + return $finalList | Format-Table -AutoSize } - else { - $finalList | Format-Table -AutoSize + + # Show a particular item + $itemId = $finalList[$Ordinal].id + + #return item + if($PassThru) { + $i = Get-ProjectItem -ItemId $itemId + return $i } + + # Show item in console or editor + Show-ProjectItem -Item $itemId -OpenInEditor:$OpenInEditor -OpenInBrowser:$OpenInBrowser + return + } } Export-ModuleMember -Function Use-Order -Alias "uo" \ No newline at end of file From 796ef28b41db4c68fac9f117b1c4039a58d232bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Mon, 26 Jan 2026 09:27:22 +0100 Subject: [PATCH 05/10] style(project_item_show): remove extra space in command string --- Test/public/items/project_item_show.test.ps1 | 2 +- Test/public/items/use_order.test.ps1 | 11 +++++------ Test/traceInvoke.log | 2 +- public/items/project_item_show.ps1 | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Test/public/items/project_item_show.test.ps1 b/Test/public/items/project_item_show.test.ps1 index a77b6cc..e85b7c0 100644 --- a/Test/public/items/project_item_show.test.ps1 +++ b/Test/public/items/project_item_show.test.ps1 @@ -91,7 +91,7 @@ function Test_OpenInEditor{ $text = "Sample Text for Editor" - $command = '"{content}" | code -w - ' + $command = '"{content}" | code -w -' $command = $command -replace '\{content\}', $text MockCallToNull -Command $command diff --git a/Test/public/items/use_order.test.ps1 b/Test/public/items/use_order.test.ps1 index b743e36..ad5beea 100644 --- a/Test/public/items/use_order.test.ps1 +++ b/Test/public/items/use_order.test.ps1 @@ -4,7 +4,7 @@ function Test_UserOrder_Success{ $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $list = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -IncludeDone - + # Act $result = $list | Use-Order @@ -18,7 +18,7 @@ function Test_UserOrder_Success_GetItem{ $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $list = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -IncludeDone - + # Act $result = $list | Use-Order 1 -PassThru @@ -30,11 +30,11 @@ function Test_UserOrder_Success_OpenBrowser{ $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $order = $p.issue.order ; $url = $p.issue.url - + MockCallToNull -command "Invoke-ProjectHelperOpenUrl -Url $url" $list = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -IncludeDone - + # Act $result = $list | Use-Order $order -OpenInBrowser @@ -49,11 +49,10 @@ function Test_UserOrder_Success_Passthru{ $order = $p.issue.order ; $id = $p.issue.id $list = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -IncludeDone - + # Act $result = $list | Use-Order $order -PassThru # Assert Assert-AreEqual -Expected $id -Presented $result.id } - diff --git a/Test/traceInvoke.log b/Test/traceInvoke.log index 8b78f4d..b0266c8 100644 --- a/Test/traceInvoke.log +++ b/Test/traceInvoke.log @@ -29,7 +29,7 @@ Invoke-CreateDraftItem -ProjectId PVT_kwDOAlIw4c4BCe3V -Title "DraftIssue create Invoke-CreateIssue -RepositoryId R_kgDOPrRnkQ -Title "Random value title" -Body "Random value body" Invoke-GetIssueOrPullRequest -Url https://github.com/octodemo/rulasg-dev-1/issues/46 Invoke-AddItemToProject -ProjectId PVT_kwDOAlIw4c4BCe3V -ContentId I_kwDOPrRnkc7T2Al2 -"Sample Text for Editor" | code -w - +"Sample Text for Editor" | code -w - Invoke-RemoveItemFromProject -ProjectId PVT_kwDOAlIw4c4BCe3V -ItemId PVTI_lADOAlIw4c4BCe3VzggVZH8 Invoke-RemoveIssue -IssueId I_kwDOPrRnkc7T2Al2 Import-Module /Users/rulasg/code/ProjectHelper ; Invoke-GitHubUpdateItemValues -ProjectId PVT_kwDOAlIw4c4BCe3V -ItemId PVTI_lADOAlIw4c4BCe3Vzgeiodc -FieldId PVTF_lADOAlIw4c4BCe3Vzg0rhko -Value "new value of the comment 10" -Type text diff --git a/public/items/project_item_show.ps1 b/public/items/project_item_show.ps1 index 241764b..5d7f734 100644 --- a/public/items/project_item_show.ps1 +++ b/public/items/project_item_show.ps1 @@ -1,4 +1,4 @@ -Set-MyinvokeCommandAlias -Alias ShowInEditor -Command '"{content}" | code -w - ' +Set-MyinvokeCommandAlias -Alias ShowInEditor -Command '"{content}" | code -w -' function Show-ProjectItem{ [CmdletBinding()] From 522aaada515f2a3ffe879dc49757cb64d58d4071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Mon, 26 Jan 2026 15:43:58 +0100 Subject: [PATCH 06/10] style(Format-ProjectItem): comment out conditional check for attributes --- public/items/project_item.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/items/project_item.ps1 b/public/items/project_item.ps1 index 782b04a..ac30c1e 100644 --- a/public/items/project_item.ps1 +++ b/public/items/project_item.ps1 @@ -216,9 +216,9 @@ function Format-ProjectItem{ $ret = [pscustomobject]::new() foreach($a in $Attributes){ - if( ! $Item.$a){ - continue - } + # if( ! $Item.$a){ + # continue + # } $ret | Add-Member -MemberType NoteProperty -Name $a -Value $Item.$a -force } From e347b26a575385723b2792e8655e700795bca20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Mon, 26 Jan 2026 16:24:25 +0100 Subject: [PATCH 07/10] refactor(Format-ProjectItem): handle empty attribute names and ensure values are added --- public/items/project_item.ps1 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/public/items/project_item.ps1 b/public/items/project_item.ps1 index ac30c1e..b2ac986 100644 --- a/public/items/project_item.ps1 +++ b/public/items/project_item.ps1 @@ -216,11 +216,15 @@ function Format-ProjectItem{ $ret = [pscustomobject]::new() foreach($a in $Attributes){ - # if( ! $Item.$a){ - # continue - # } + # just in case attribute has an empty name + if( [string]::IsNullOrWhiteSpace($a) ){ + continue + } + + # Add value even if it't empty value + $value = $Item.$a ?? "" - $ret | Add-Member -MemberType NoteProperty -Name $a -Value $Item.$a -force + $ret | Add-Member -MemberType NoteProperty -Name $a -Value $value -force } return $ret @@ -750,4 +754,4 @@ function AreEqual { $ret = $Object1 -eq $Object2 return $ret -} \ No newline at end of file +} From bd57ae9178c0c3c23a181298d9f819bbd6dc9278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Wed, 28 Jan 2026 11:47:42 +0100 Subject: [PATCH 08/10] refactor(use_order): return item as PsCustomObject in Use-Order function --- public/items/use_order.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/items/use_order.ps1 b/public/items/use_order.ps1 index 3aca285..157cced 100644 --- a/public/items/use_order.ps1 +++ b/public/items/use_order.ps1 @@ -41,7 +41,7 @@ function Use-Order { #return item if($PassThru) { $i = Get-ProjectItem -ItemId $itemId - return $i + return [PsCustomObject]$i } # Show item in console or editor From f6163dd95494a9079bbb5b706a31ef12711b33e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Thu, 29 Jan 2026 10:39:40 +0100 Subject: [PATCH 09/10] feat(Show-ProjectItem): add ClearScreen parameter to clear console before output --- public/items/project_item_show.ps1 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/public/items/project_item_show.ps1 b/public/items/project_item_show.ps1 index 5d7f734..e1b0733 100644 --- a/public/items/project_item_show.ps1 +++ b/public/items/project_item_show.ps1 @@ -7,10 +7,13 @@ function Show-ProjectItem{ [Parameter()][string]$Owner, [Parameter()][int]$ProjectNumber, [Parameter(Mandatory, ValueFromPipelineByPropertyName, ValueFromPipeline, Position = 0)][Alias("id")][string]$ItemId, - [Parameter()][array[]]$FieldsToShow, - [Parameter()][switch]$AllComments, - [Parameter()][switch]$OpenInEditor, - [Parameter()][Alias("W")][switch]$OpenInBrowser + [Parameter()][Alias("A")][switch]$AllComments, + [Parameter()][Alias("E")][switch]$OpenInEditor, + [Parameter()][Alias("W")][switch]$OpenInBrowser, + [Parameter()][Alias("C")][switch]$ClearScreen, + + # Custom Fields to show on header + [Parameter()][array[]]$FieldsToShow ) begin{ @@ -42,6 +45,11 @@ function Show-ProjectItem{ ) } + # Clear screen before showing if requested + if($ClearScreen){ + Clear-Host + } + # Before all addJumpLine -message "Header Start" From 9f5299418e191929bbd9aaffbfcdc7d7ac222138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Mon, 2 Feb 2026 07:41:12 +0100 Subject: [PATCH 10/10] feat(Use-Order): add ClearScreen option to clear console and set clipboard in Show-ProjectItem --- public/items/project_item_show.ps1 | 3 ++- public/items/use_order.ps1 | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/public/items/project_item_show.ps1 b/public/items/project_item_show.ps1 index e1b0733..2cb63dd 100644 --- a/public/items/project_item_show.ps1 +++ b/public/items/project_item_show.ps1 @@ -11,7 +11,7 @@ function Show-ProjectItem{ [Parameter()][Alias("E")][switch]$OpenInEditor, [Parameter()][Alias("W")][switch]$OpenInBrowser, [Parameter()][Alias("C")][switch]$ClearScreen, - + # Custom Fields to show on header [Parameter()][array[]]$FieldsToShow ) @@ -48,6 +48,7 @@ function Show-ProjectItem{ # Clear screen before showing if requested if($ClearScreen){ Clear-Host + Set-Clipboard $ItemId } # Before all diff --git a/public/items/use_order.ps1 b/public/items/use_order.ps1 index 157cced..4f1c85f 100644 --- a/public/items/use_order.ps1 +++ b/public/items/use_order.ps1 @@ -6,7 +6,8 @@ function Use-Order { [Parameter(ValueFromPipeline)][array]$List, [Parameter()][switch]$OpenInEditor, [Parameter()][Alias("w")][switch]$OpenInBrowser, - [Parameter()][switch]$PassThru + [Parameter()][switch]$PassThru, + [Parameter()][Alias("C")][switch]$ClearScreen ) begin { @@ -30,7 +31,11 @@ function Use-Order { end { - # Show list of items + if($ClearScreen){ + Clear-Host + } + + # Show list of items if ($Ordinal -lt 0) { return $finalList | Format-Table -AutoSize } @@ -45,7 +50,7 @@ function Use-Order { } # Show item in console or editor - Show-ProjectItem -Item $itemId -OpenInEditor:$OpenInEditor -OpenInBrowser:$OpenInBrowser + Show-ProjectItem -Item $itemId -OpenInEditor:$OpenInEditor -OpenInBrowser:$OpenInBrowser -ClearScreen:$ClearScreen return }