Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f9964c6
feat(driver): get projectv2 by url and contentid
rulasg Oct 31, 2025
ce1ebae
feat(get-project): Add query parameter
rulasg Oct 31, 2025
ba143f3
feat(Save-ProjectV2toDatabase): update each of the new items and not …
rulasg Nov 3, 2025
e92d555
wip
rulasg Nov 5, 2025
47170c0
feat(database): log database store path during retrieval
rulasg Nov 5, 2025
60cf5e6
refactor(Show-ProjectItem) improve tracing and jumplines
rulasg Nov 10, 2025
44e3b78
feat(mockdatabase): add Update-Mock_DatabaseFileWithReplace to allow …
rulasg Nov 10, 2025
62f27ba
refactor(test): use Update-Mock_DatabaseFileWithReplace in test
rulasg Nov 10, 2025
819e808
faet(test): getproject with query test
rulasg Nov 10, 2025
1a53e94
refactor(graphql): add more tags and refactor querys for clarity
rulasg Nov 10, 2025
5bd7c27
feat(graphql): add updateProjectV2Collaborators mutation and related …
rulasg Nov 12, 2025
a09205e
feat(user): add Invoke-GetUser and Get-User functions for user retrieval
rulasg Nov 12, 2025
27b2fc1
refactor(callAPI): remove Export-ModuleMember statements for clarity
rulasg Nov 12, 2025
32d131d
refactor(invokeRestMethod): comment out function implementation for c…
rulasg Nov 12, 2025
11323cd
refactor(user): update cache check logic in Get-User function
rulasg Nov 12, 2025
8248bfc
refactor(callAPI): allow call with outfile parameter
rulasg Nov 12, 2025
dff98c0
feat(driver): Invoke-UpdateProjectV2Collaborators
rulasg Nov 12, 2025
1244cdd
feat(project): Add-ProjectUser
rulasg Nov 12, 2025
9da3983
feat(test): tests for add-projectUser
rulasg Nov 12, 2025
5f2cd0e
style(header): update author and date formatting in writeHeader2
rulasg Nov 24, 2025
f05e59e
style(use_order): add alias for OpenInBrowser parameter
rulasg Nov 24, 2025
ceb1e0c
Merge branch 'get-item-by' into projectv2ContributionUpdate
rulasg Nov 25, 2025
e0424ee
fix(test): correct formatting in assertions for author and updatedAt
rulasg Nov 25, 2025
18a7e18
refactor(project): enable ValueFromPipelineByPropertyName for paramet…
rulasg Dec 11, 2025
d8f3da0
refactor(issue): add OpenOnCreation parameter to New-ProjectIssueDire…
rulasg Dec 12, 2025
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
37 changes: 37 additions & 0 deletions Test/include/config.mock.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# CONFIG MOCK

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
#
# This file is used to mock the config path and the config file
# for the tests. It creates a mock config path and a mock config file
# and sets the config path to the mock config path.
#
# THIS INCLUDE REQURED module.helper.ps1
if(-not $MODULE_NAME){ throw "Missing MODULE_NAME varaible initialization. Check for module.helerp.ps1 file." }

$MOCK_CONFIG_PATH = "test_config_path"
$CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-$($MODULE_NAME)GetConfigRootPath"

function Mock_Config{
param(
[Parameter(Position=0)][string] $key = "config",
[Parameter(Position=1)][object] $Config
)

# Remove mock config path if exists
if(Test-Path $MOCK_CONFIG_PATH){
Remove-Item -Path $MOCK_CONFIG_PATH -ErrorAction SilentlyContinue -Recurse -Force
}

# create mock config path
New-Item -Path $MOCK_CONFIG_PATH -ItemType Directory -Force

# if $config is not null save it to a file
if($null -ne $Config){
$configfile = Join-Path -Path $MOCK_CONFIG_PATH -ChildPath "$key.json"
$Config | ConvertTo-Json -Depth 10 | Set-Content $configfile
}

# Mock invoke call
MockCallToString $CONFIG_INVOKE_GET_ROOT_PATH_CMD -OutString $MOCK_CONFIG_PATH

}
20 changes: 20 additions & 0 deletions Test/mockfiles.log
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,25 @@
{
"FileName": "invoke-GitHubOrgProjectWithFields-octodemo-700-query-field-text.json",
"Command": "Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields \"\" -afterItems \"\" -query \"field-text:text1\""
},
{
"FileName": "invoke-GetUser-rulasg.json",
"Command": "Invoke-GetUser -Handle rulasg"
},
{
"FileName": "invoke-UpdateProjectV2Collaborators-MDQ6VXNlcjY4ODQ0MDg=.json",
"Command": "Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators \"MDQ6VXNlcjY4ODQ0MDg=\" -Role \"WRITER\""
},
{
"FileName": "invoke-GetUser-rauldibildos.json",
"Command": "Invoke-GetUser -Handle rauldibildos"
},
{
"FileName": "invoke-UpdateProjectV2Collaborators-MDQ6VXNlcjY4ODQ0MDg=.json",
"Command": "Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators \"MDQ6VXNlcjY4ODQ0MDg= U_kgDOC_E3gw\" -Role \"WRITER\""
},
{
"FileName": "invoke-UpdateProjectV2Collaborators-MDQ6VXNlcjY4ODQ0MDg=.json",
"Command": "Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators \"\" -Role \"WRITER\""
}
]
16 changes: 16 additions & 0 deletions Test/private/MockUsers.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function Get-Mock_Users{

Check warning

Code scanning / PSScriptAnalyzer

The cmdlet 'Get-Mock_Users' uses a plural noun. A singular noun should be used instead. Warning

The cmdlet 'Get-Mock_Users' uses a plural noun. A singular noun should be used instead.
$users = @{
u1 = @{
id = "MDQ6VXNlcjY4ODQ0MDg="
name = "rulasg"
file = "invoke-GetUser-rulasg.json"
}
u2 = @{
id = "U_kgDOC_E3gw"
name = "rauldibildos"
file = "invoke-GetUser-rauldibildos.json"
}
}

return $users
}
4 changes: 4 additions & 0 deletions Test/private/mocks/invoke-GetUser-rauldibildos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"login": "raulDibildos",
"node_id": "U_kgDOC_E3gw"
}
47 changes: 47 additions & 0 deletions Test/private/mocks/invoke-GetUser-rulasg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"login": "rulasg",
"id": 6884408,
"node_id": "MDQ6VXNlcjY4ODQ0MDg=",
"avatar_url": "https://avatars.githubusercontent.com/u/6884408?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/rulasg",
"html_url": "https://github.com/rulasg",
"followers_url": "https://api.github.com/users/rulasg/followers",
"following_url": "https://api.github.com/users/rulasg/following{/other_user}",
"gists_url": "https://api.github.com/users/rulasg/gists{/gist_id}",
"starred_url": "https://api.github.com/users/rulasg/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/rulasg/subscriptions",
"organizations_url": "https://api.github.com/users/rulasg/orgs",
"repos_url": "https://api.github.com/users/rulasg/repos",
"events_url": "https://api.github.com/users/rulasg/events{/privacy}",
"received_events_url": "https://api.github.com/users/rulasg/received_events",
"type": "User",
"user_view_type": "private",
"site_admin": true,
"name": "Raúl (Dibildos) González",
"company": "GitHub",
"blog": "https://rulasg.github.io",
"location": "Madrid, Spain",
"email": "rulasg@github.com",
"hireable": null,
"bio": "A father, an optimist, an idealist, an engineer, a bit of a philosopher, a strategist, passionate about understanding and learning from everyone.",
"twitter_username": "rulasg",
"public_repos": 82,
"public_gists": 8,
"followers": 18,
"following": 12,
"created_at": "2014-03-07T14:47:11Z",
"updated_at": "2025-11-11T23:39:44Z",
"private_gists": 8,
"total_private_repos": 42,
"owned_private_repos": 42,
"disk_usage": 217904,
"collaborators": 4,
"two_factor_authentication": true,
"plan": {
"name": "pro",
"space": 976562499,
"collaborators": 0,
"private_repos": 9999
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"data": {
"updateProjectV2Collaborators": {
"collaborators": {
"totalCount": 2,
"nodes": [
{
"__typename": "User",
"id": "MDQ6VXNlcjY4ODQ0MDg=",
"name": "Raúl (Dibildos) González",
"login": "rulasg",
"email": "rulasg@github.com"
},
{
"__typename": "User",
"id": "U_kgDOC_E3gw",
"name": "Raúl Dibildos",
"login": "rauldibildos",
"email": "rauldibildos@gmail.com"
}
]
}
}
},
"extensions": {
"warnings": [
{
"type": "DEPRECATION",
"message": "The id MDQ6VXNlcjY4ODQ0MDg= is deprecated. Update your cache to use the next_global_id from the data payload.",
"data": {
"legacy_global_id": "MDQ6VXNlcjY4ODQ0MDg=",
"next_global_id": "U_kgDOAGkMOA"
},
"link": "https://docs.github.com"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"data": {
"updateProjectV2Collaborators": {
"collaborators": {
"totalCount": 1,
"nodes": [
{
"__typename": "User",
"id": "MDQ6VXNlcjY4ODQ0MDg=",
"name": "Raúl (Dibildos) González",
"login": "rulasg",
"email": "rulasg@github.com"
}
]
}
}
},
"extensions": {
"warnings": [
{
"type": "DEPRECATION",
"message": "The id MDQ6VXNlcjY4ODQ0MDg= is deprecated. Update your cache to use the next_global_id from the data payload.",
"data": {
"legacy_global_id": "MDQ6VXNlcjY4ODQ0MDg=",
"next_global_id": "U_kgDOAGkMOA"
},
"link": "https://docs.github.com"
}
]
}
}
4 changes: 2 additions & 2 deletions Test/public/items/project_item_show.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ function Test_ShowProjectItem_SUCESS{
Assert-Contains -Presented $tt -Expected "$($i.status)"
Assert-Contains -Presented $tt -Expected "$($i.Body)"

Assert-Contains -Presented $tt -Expected "By: $($i.comments.last.author.login)"
Assert-Contains -Presented $tt -Expected "At: $($i.comments.last.updatedAt)"
Assert-Contains -Presented $tt -Expected "By:[$($i.comments.last.author.login)]"
Assert-Contains -Presented $tt -Expected "At:[$($i.comments.last.updatedAt)]"
Assert-Contains -Presented $tt -Expected $i.comments.last.body

Assert-Contains -Presented $tt -Expected $i.id
Expand Down
50 changes: 50 additions & 0 deletions Test/public/project/addprojectuser.test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
function Test_AddProjectUser_SUCCESS_SingleUser{
Reset-InvokeCommandMock
Mock_DatabaseRoot

# Enable-invokeCommandAliasModule
# Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators "MDQ6VXNlcjY4ODQ0MDg=" -Role "WRITER"


$p =Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number ; $projectId = $p.id
MockCall_GetProject $p -SkipItems

$u = Get-Mock_Users

$userId1 = $u.u1.id ; $userName1 = $u.u1.name
$role ="WRITER"

$fileName = "invoke-UpdateProjectV2Collaborators-$userId1.json"

MockCallJson -Command "Invoke-GetUser -Handle $userName1" -File $u.u1.file
MockCallJson -Command "Invoke-UpdateProjectV2Collaborators -ProjectId $projectId -collaborators ""$userId1"" -Role ""$role""" -File $fileName

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$result = Add-ProjectUser -Owner $owner -ProjectNumber $projectNumber -Handle $userName1 -Role $role

Assert-IsTrue $result
}

function Test_AddProjectUser_SUCCESS_MultipleUser{
Reset-InvokeCommandMock
Mock_DatabaseRoot

$p =Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number ; $projectId = $p.id
MockCall_GetProject $p -SkipItems

$u = Get-Mock_Users

$userId1 = $u.u1.id ; $userName1 = $u.u1.name
$userId2 = $u.u2.id ; $userName2 = $u.u2.name
$userNames = "$userName1","$userName2"
$usersIds ="$userId1 $userId2"
$role ="WRITER"
$fileName = "invoke-UpdateProjectV2Collaborators-$userId1-$userId2.json"

MockCallJson -Command "Invoke-GetUser -Handle $userName1" -File $u.u1.file
MockCallJson -Command "Invoke-GetUser -Handle $userName2" -File $u.u2.file
MockCallJson -Command "Invoke-UpdateProjectV2Collaborators -ProjectId $projectId -collaborators ""$usersIds"" -Role ""$role""" -File $fileName

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$result = $userNames | Add-ProjectUser -Owner $owner -ProjectNumber $projectNumber -Role $role

Assert-IsTrue $result
}
4 changes: 4 additions & 0 deletions Test/traceInvoke.log
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ Invoke-GitHubOrgProjectWithFields -Owner SomeOrg -ProjectNumber 164 -afterFields
Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 625 -afterFields "" -afterItems "" -query ""
Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 626 -afterFields "" -afterItems "" -query ""
Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields "" -afterItems "" -query "field-text:text1"
Invoke-GetUser -Handle rulasg
Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators "MDQ6VXNlcjY4ODQ0MDg=" -Role "WRITER"
Invoke-GetUser -Handle rauldibildos
Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators "MDQ6VXNlcjY4ODQ0MDg= U_kgDOC_E3gw" -Role "WRITER"
14 changes: 9 additions & 5 deletions include/callAPI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ function Invoke-GraphQL {
# Send the request
$start = Get-Date
">>> Invoke-RestMethod - $apiUri" | writedebug
$response = Invoke-RestMethod -Uri $apiUri -Method Post -Body $body -Headers $headers -OutFile $OutFile
if([string]::IsNullOrWhiteSpace($OutFile))
{ $response = Invoke-RestMethod -Uri $apiUri -Method Post -Body $body -Headers $headers }
else { $response = Invoke-RestMethod -Uri $apiUri -Method Post -Body $body -Headers $headers -OutFile $OutFile }
"<<< Invoke-RestMethod - $apiUri [ $(((Get-Date) - $start).TotalSeconds) seconds]" | writedebug

# Trace response
Expand All @@ -58,10 +60,12 @@ function Invoke-GraphQL {
return $response
}
catch {
"[[THROW]]" | writedebug
$_.Exception.Message | ConvertTo-Json -Depth 100 | writedebug
throw New-Object system.Exception("Error calling GraphQL",$_.Exception)

}
} Export-ModuleMember -Function Invoke-GraphQL
}

function Invoke-RestAPI {
param(
Expand Down Expand Up @@ -132,7 +136,7 @@ function Invoke-RestAPI {
catch {
throw
}
} Export-ModuleMember -Function Invoke-RestAPI
}

####################################################################################################

Expand All @@ -158,7 +162,7 @@ function Get-ApiHost {

"Default host $DEFAULT_GH_HOST" | writedebug
return $DEFAULT_GH_HOST
} Export-ModuleMember -Function Get-ApiHost
}


####################################################################################################
Expand Down Expand Up @@ -198,7 +202,7 @@ function Get-ApiToken {
}

return $result
} Export-ModuleMember -Function Get-ApiToken
}

####################################################################################################

Expand Down
Loading
Loading