diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 194474c..db52110 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,7 @@ "name": "PowerShell", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/powershell:lts-ubuntu-22.04", - + "features": { "ghcr.io/devcontainers/features/common-utils:2": {}, "ghcr.io/devcontainers/features/sshd:1": {}, @@ -20,10 +20,10 @@ // Configure properties specific to VS Code. "vscode": { // Set *default* container specific settings.json values on container create. - "settings": { + "settings": { "terminal.integrated.defaultProfile.linux": "pwsh" }, - + // Add the IDs of extensions you want installed when the container is created. "extensions": [ "ms-vscode.powershell", @@ -40,4 +40,3 @@ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" } - diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 8ace082..e0ee098 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -60,7 +60,7 @@ Disable-ProjectHelperDebug ### GraphQL Integration 1. Store GraphQL in template files: `/public/graphql/queryName.query` or `.mutant` -2. Retrieve via: `Get-GraphQLString "queryName.query"` +2. Retrieve via: `Get-GraphQLString "queryName.query"` 3. Execute: `Invoke-GraphQL -Query $query -Variables $variables` Example: @@ -110,7 +110,7 @@ The folder structure in `Test/` must exactly match the structure in the main mod - `Test_FindProject_SUCCESS` (success case) - `Test_AddProjectUser_SUCCESS_SingleUser` (specific variant) - `Test_GetProjectIssue_NotFound` (error case) -- **Conventions**: +- **Conventions**: - Use PascalCase matching the actual function name (e.g., `Get-SomeInfo` → `Test_GetSomeInfo_`) - `` should be a descriptive word indicating the test goal (SUCCESS, NotFound, InvalidInput, etc.) - Use assertions: `Assert-IsTrue`, `Assert-Contains`, `Assert-AreEqual`, `Assert-Count`, `Assert-IsNull` diff --git a/.github/copilot-pull-request-description-instructions.md b/.github/copilot-pull-request-description-instructions.md index 31a8730..b871512 100644 --- a/.github/copilot-pull-request-description-instructions.md +++ b/.github/copilot-pull-request-description-instructions.md @@ -1,6 +1,6 @@ # Pull Request Code Instructions -## PR TITLE +## PR TITLE Follow this guidelines to construct the title of your pull request. @@ -39,6 +39,3 @@ References: - Add a summery of the intention of the PR. Use the title and the messages of the commits to create a summary. - Add a list with all the commit messages in the PR. - - - diff --git a/.github/workflows/deploy_module_on_release.yml b/.github/workflows/deploy_module_on_release.yml index cad2ee8..9a2a58c 100644 --- a/.github/workflows/deploy_module_on_release.yml +++ b/.github/workflows/deploy_module_on_release.yml @@ -21,9 +21,9 @@ jobs: - name: Run test.ps1 shell: pwsh - run: | + run: | $result = ./test.ps1 -ShowTestErrors - + Write-Output $result import-module ./tools/Test_Helper/ @@ -31,7 +31,7 @@ jobs: $passed = Test-Result -Result $result if($passed) - { "All test passed" | Write-Verbose -verbose ; exit 0 } + { "All test passed" | Write-Verbose -verbose ; exit 0 } else { "Not all tests passed" | Write-Verbose -verbose ; exit 1 } @@ -42,7 +42,7 @@ jobs: EVENT_REF: ${{ github.event.ref }} RELEASE_TAG: ${{ github.event.release.tag_name }} RELEASE_NAME: ${{ github.event.release.name }} - run: | + run: | # Import required modules for deployment import-module ./tools/Test_Helper/ @@ -50,7 +50,7 @@ jobs: Get-RequiredModule -Verbose | Import-RequiredModule -AllowPrerelease # GET TAG NAME - + ## Ref definition. Branch or Tag $env:EVENT_REF = $env:REF If ([string]::IsNullOrEmpty($env:EVENT_REF)) { @@ -70,4 +70,3 @@ jobs: # DEPLOYMENT ./deploy.ps1 -VersionTag $tag -NugetApiKey $env:NUGETAPIKEY - diff --git a/.github/workflows/powershell.yml b/.github/workflows/powershell.yml index 775a40c..bae227e 100644 --- a/.github/workflows/powershell.yml +++ b/.github/workflows/powershell.yml @@ -12,7 +12,7 @@ name: PSScriptAnalyzer on: workflow_dispatch: pull_request: - + permissions: contents: read @@ -21,7 +21,7 @@ jobs: permissions: contents: read # for actions/checkout to fetch code security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status + actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status name: PSScriptAnalyzer runs-on: ubuntu-latest steps: @@ -33,15 +33,14 @@ jobs: # Check https://github.com/microsoft/action-psscriptanalyzer for more info about the options. # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. path: .\ - recurse: true + recurse: true severity: 'Error' - # Include your own basic security rules. Removing this option will run all the rules + # Include your own basic security rules. Removing this option will run all the rules # includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' output: results.sarif - + # Upload the SARIF file generated in the previous step - name: Upload SARIF results file uses: github/codeql-action/upload-sarif@v3 with: sarif_file: results.sarif - diff --git a/.github/workflows/test_with_TestingHelper.yml b/.github/workflows/test_with_TestingHelper.yml index 7163d24..a11f66f 100644 --- a/.github/workflows/test_with_TestingHelper.yml +++ b/.github/workflows/test_with_TestingHelper.yml @@ -31,9 +31,9 @@ jobs: # Runs a single command using the runners shell - name: Run test.ps1 shell: pwsh - run: | + run: | $result = ./test.ps1 -ShowTestErrors - + Write-Output $result import-module ./tools/Test_Helper/ @@ -41,7 +41,6 @@ jobs: $passed = Test-Result -Result $result if($passed) - { "All test passed" | Write-Verbose -verbose ; exit 0 } - else + { "All test passed" | Write-Verbose -verbose ; exit 0 } + else { "Not all tests passed" | Write-Verbose -verbose ; exit 1 } - diff --git a/.vscode/launch.json b/.vscode/launch.json index 668bddc..8f78fe0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,7 +4,7 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 // // Module V2 - https://raw.githubusercontent.com/rulasg/DemoPsModule/main/.vscode/launch.json - + "version": "0.2.0", "configurations": [ { diff --git a/Notes.md b/Notes.md index ff48feb..b625ee2 100644 --- a/Notes.md +++ b/Notes.md @@ -7,7 +7,7 @@ Notes used during the development of the module ```mermaid graph TD; - + subgraph Module 0([Sync-ProjectItemStaged]) @@ -33,7 +33,7 @@ graph TD; H <--> I - + ``` ## Update-ProjectDatabase @@ -50,10 +50,10 @@ graph TD; end I<-->G - + U<-- GitHubOrgProjectWithFields--> I[InvokeHelper] G <--> H[Invoke-RestMethod] H <--> Q([GitHub GraphQL API]) - -``` \ No newline at end of file + +``` diff --git a/ProjectHelper.psd1 b/ProjectHelper.psd1 index 13212ed..face666 100644 --- a/ProjectHelper.psd1 +++ b/ProjectHelper.psd1 @@ -129,4 +129,3 @@ PrivateData = @{ # DefaultCommandPrefix = '' } - diff --git a/ProjectHelper.psm1 b/ProjectHelper.psm1 index 13e3365..f53096f 100644 --- a/ProjectHelper.psm1 +++ b/ProjectHelper.psm1 @@ -10,4 +10,3 @@ $MODULE_PATH = $PSScriptRoot catch { Write-Error -Message "Failed to import $($import.fullname): $_" } } } - diff --git a/Test/helper/module.helper.ps1 b/Test/helper/module.helper.ps1 index 7fd1786..79e9af3 100644 --- a/Test/helper/module.helper.ps1 +++ b/Test/helper/module.helper.ps1 @@ -19,7 +19,7 @@ function Find-ModuleRootPath{ $path = $path | Split-Path -Parent continue } - + # foudn module return $path } diff --git a/Test/include/InvokeMockList.ps1 b/Test/include/InvokeMockList.ps1 index 3223779..3c867a8 100644 --- a/Test/include/InvokeMockList.ps1 +++ b/Test/include/InvokeMockList.ps1 @@ -40,9 +40,9 @@ function readMockCommandFile{ function writeMockCommandFile($Content){ - $list = $Content | ConvertTo-Json - + $list = $Content | ConvertTo-Json + $sorted = $list | Sort-Object fileName - + $sorted | Out-File -FilePath $MockCommandFile } \ No newline at end of file diff --git a/Test/include/callPrivateContext.ps1 b/Test/include/callPrivateContext.ps1 index c4bae5d..a7e7f83 100644 --- a/Test/include/callPrivateContext.ps1 +++ b/Test/include/callPrivateContext.ps1 @@ -21,13 +21,12 @@ function Invoke-PrivateContext { if ([string]::IsNullOrEmpty($ModulePath)) { $modulePath = $MODULE_PATH | Split-Path -Parent } - + $module = Import-Module -Name $modulePath -PassThru if ($null -eq $module) { throw "Failed to import the main module." } - & $module $ScriptBlock + & $module $ScriptBlock } Export-ModuleMember -Function Invoke-PrivateContext - diff --git a/Test/include/config.mock.ps1 b/Test/include/config.mock.ps1 index a4bd7db..8353236 100644 --- a/Test/include/config.mock.ps1 +++ b/Test/include/config.mock.ps1 @@ -1,5 +1,5 @@ -# CONFIG MOCK +# CONFIG MOCK # # 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 @@ -38,8 +38,8 @@ function Mock_Config{ if([string]::IsNullOrWhiteSpace($ModuleName)){ $moduleName = $MODULE_NAME - } - + } + $invokefunction = $CONFIG_INVOKE_GET_ROOT_PATH_CMD -replace "ProjectHelper", $moduleName # Mock invoke call diff --git a/Test/include/invokeCommand.mock.ps1 b/Test/include/invokeCommand.mock.ps1 index 8aaaf93..78304de 100644 --- a/Test/include/invokeCommand.mock.ps1 +++ b/Test/include/invokeCommand.mock.ps1 @@ -293,8 +293,3 @@ function Assert-MockFileNotfound{ throw "File not found or wrong case name. Expected[ $filename ] - Found[$( $file.name )]" } } - - - - - diff --git a/Test/include/run_BeforeAfter.ps1 b/Test/include/run_BeforeAfter.ps1 index 80273af..a0e534a 100644 --- a/Test/include/run_BeforeAfter.ps1 +++ b/Test/include/run_BeforeAfter.ps1 @@ -1,5 +1,5 @@ # Run Before and After any test -# +# # Supported by TestingHelper 4.1.0 we can specify code that will run : # - Before each test # - After each test @@ -25,4 +25,3 @@ function Run_AfterEach{ } Export-ModuleMember -Function Run_* - diff --git a/Test/include/transcriptHelp.ps1 b/Test/include/transcriptHelp.ps1 index 79e17dc..267480e 100644 --- a/Test/include/transcriptHelp.ps1 +++ b/Test/include/transcriptHelp.ps1 @@ -17,7 +17,7 @@ function Start-MyTranscript { } function Stop-MyTranscript { - + $null = Stop-Transcript $transcriptContent = Get-Content -Path $TEST_TRANSCRIPT_FILE @@ -41,7 +41,6 @@ function Export-MyTranscript { $lastLine = $i[2] - 1 $retlist = $transcriptContent[$firstLine..$lastLine] - + return $retlist } - diff --git a/Test/private/MockCall_GitHubUpdateItemValues.ps1 b/Test/private/MockCall_GitHubUpdateItemValues.ps1 index 02d6ac1..23bb01a 100644 --- a/Test/private/MockCall_GitHubUpdateItemValues.ps1 +++ b/Test/private/MockCall_GitHubUpdateItemValues.ps1 @@ -19,7 +19,7 @@ function MockCall_GitHubUpdateItemValues { $command = 'Import-Module {modulepath} ; ' + $command $command = $command -replace '{modulepath}', $modulePath - } + } $command = $command -replace '{ProjectId}', $ProjectId $command = $command -replace '{ItemId}', $ItemId diff --git a/Test/private/MockCall_Project.ps1 b/Test/private/MockCall_Project.ps1 index b106e4b..cc31a13 100644 --- a/Test/private/MockCall_Project.ps1 +++ b/Test/private/MockCall_Project.ps1 @@ -4,7 +4,7 @@ function Get-Mock_Project_625 { <# Reset-InvokeCommandMock - Enable-InvokeCommandAliasModule + Enable-InvokeCommandAliasModule $cmd = 'Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 625 -afterFields "" -afterItems ""' save-invokeAsMockFile $cmd "invoke-GitHubOrgProjectWithFields-octodemo-625.json" #> @@ -43,7 +43,7 @@ function Get-Mock_Project_625 { PVTI_lADOAlIw4c4A0Lf4zgfN-44 draft6 2025-03-15 Planned Change to AR as P and Today PVTI_lADOAlIw4c4A0Lf4zgYNTc0 draft7 2025-03-05 Done Ignore as Done | (Change AR as Past) PVTI_lADOAlIw4c4A0Lf4zgYNTwo draft8 9999-12-12 In Progress Ignore future - PVTI_lADOAlIw4c4A0Lf4zgfOmpo draft9 9999-12-12 Todo (Ignore not P) + PVTI_lADOAlIw4c4A0Lf4zgfOmpo draft9 9999-12-12 Todo (Ignore not P) PVTI_lADOAlIw4c4A0Lf4zgfJYv4 Issue for development skip no DueDate PVTI_lADOAlIw4c4A0Lf4zgfJYvk PullRequest for development skip no DueDate @@ -52,7 +52,7 @@ function Get-Mock_Project_625 { $dateFieldName = "DueDate" $statusAction = "ActionRequired" $statusPlanned = "Planned" - + $sf = ($content.data.organization.projectV2.fields.nodes | Where-Object { $_.name -eq $statusFieldName }) $df = ($content.data.organization.projectV2.fields.nodes | Where-Object { $_.name -eq $dateFieldName }) $project.updateStatusOnDueDate = @{ @@ -68,11 +68,11 @@ function Get-Mock_Project_625 { anyStatus = @{ "PVTI_lADOAlIw4c4A0Lf4zgYNTxI" = @{ $($sf.id) = $statusAction } # draft4 "PVTI_lADOAlIw4c4A0Lf4zgfN77A" = @{ $($sf.id) = $statusAction } # draft9 - + } includeDone = @{ "PVTI_lADOAlIw4c4A0Lf4zgYNTc0" = @{ $($df.id) = "" } # draft8 - + } includeDoneOther = @{ "PVTI_lADOAlIw4c4A0Lf4zgfN77A" = @{ $($df.id) = "" } # draft5 @@ -93,7 +93,7 @@ function Get-Mock_Project_625 { fieldSlug = "sf_" integrationField = "sfUrl" fields = @("sf_Int2","sf_Text1") - + integrationCommand = "Get-SfAccount" mockdata1 = @{ @@ -126,7 +126,7 @@ function Get-Mock_Project_625 { PVTF_lADOAlIw4c4A0Lf4zg15NMg = "value11" } - } + } } ############################# @@ -216,7 +216,7 @@ function MockCall_GetProject { MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName $filename -SkipItems:$SkipItems Mock_Today - + if ($Cache) { $null = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems } @@ -265,6 +265,6 @@ function Add-ItemsToMock { title = $draftIssue.content.title status = ($draftIssue.fieldValues.nodes | Where-Object { $_.field.name -eq "Status" }).name fieldtext = ($draftIssue.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldtext.id) }).text - + } } \ No newline at end of file diff --git a/Test/private/MockCall_Project700.ps1 b/Test/private/MockCall_Project700.ps1 index 2c9b4ea..57cb88e 100644 --- a/Test/private/MockCall_Project700.ps1 +++ b/Test/private/MockCall_Project700.ps1 @@ -3,7 +3,7 @@ function Get-Mock_Project_700 { <# Reset-InvokeCommandMock - Enable-InvokeCommandAliasModule + Enable-InvokeCommandAliasModule $cmd = 'Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields "" -afterItems ""' save-invokeAsMockFile $cmd "invoke-GitHubOrgProjectWithFields-octodemo-700.json" #> @@ -40,7 +40,7 @@ function Get-Mock_Project_700 { } $project.repo.object.Remove('parent') $project.repo.object.owner = $repoContent.data.repository.owner.login - + # Project info $project.id = $pActual.id $project.owner = $pActual.owner.login @@ -57,7 +57,7 @@ function Get-Mock_Project_700 { $project.fieldnumber = @{ id = $fieldnumber.id ; name = $fieldnumber.name } $project.fielddate = @{ id = $fielddate.id ; name = $fielddate.name } $project.fieldsingleselect = @{ id = $fieldsingleselect.id ; name = $fieldsingleselect.name ; options = $fieldsingleselect.options } - + # Items $project.items = @{} $project.items.totalCount = $pActual.items.nodes.count @@ -104,7 +104,7 @@ function Get-Mock_Project_700 { propertyCount = ($issue.content.comments.nodes[-1] | Get-Member -MemberType *Property).Count } } - + # PullRequest for developer $pullRequest = $pActual.items.nodes | Where-Object { $_.content.title -eq "PullRequest for development" } $fss = $pullRequest.fieldValues.nodes | Where-Object { $_.field.id -eq $($fieldsingleselect.id) } @@ -164,7 +164,7 @@ function Get-Mock_Project_700 { getProjectWithQueryMockFile = "invoke-GitHubOrgProjectWithFields-octodemo-700-query-field-text.json" totalCount = 7 } - + # searchIn Title like $project.searchInTitle = @{} $project.searchInTitle.titleFilter = "development" @@ -177,7 +177,7 @@ function Get-Mock_Project_700 { $fnValues = ( $pActual.items.nodes.fieldValues.nodes | Where-Object {$_.Field.Name -eq "field-text"}).text # $fnValues = $pActual.items.nodes | Where-Object {$_.fieldValues.nodes.text -eq "text2"} $project.searchInFieldName = @{} - + # searchIn FieldName Like $fn = "xt3" $project.searchInFieldName.Like = @{ @@ -242,7 +242,7 @@ function MockCall_GetProject_700 { MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName $filename -SkipItems:$SkipItems Mock_Today - + if ($Cache) { $null = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems } @@ -262,9 +262,8 @@ function MockCall_GetProject_700_CaseSensitive { MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -FileName $filename -SkipItems:$SkipItems Mock_Today - + if ($Cache) { $null = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems:$SkipItems } } - diff --git a/Test/private/mocks/Itesm700.md b/Test/private/mocks/Itesm700.md index 421bae3..349fc67 100644 --- a/Test/private/mocks/Itesm700.md +++ b/Test/private/mocks/Itesm700.md @@ -7,7 +7,7 @@ invoke-GitHubOrgProjectWithFields-octodemo-700-skipitems.json Name Value ---- ----- items {System.Management.Automation.OrderedHashtable} -readme +readme ProjectId PVT_kwDOAlIw4c4BCe3V title rulasg-dev-700 shortDescription Project used as development environment by rulasg @@ -35,14 +35,14 @@ Name Value ---- ----- updatedAt 9/9/2025 14:04:20 Milestone Milestone 1: Project Setup -field-iteration +field-iteration createdAt 9/9/2025 13:56:05 number 25 Repository https://github.com/octodemo/rulasg-dev-1 Assignees rulasg field-number 111 Status Todo -body +body id PVTI_lADOAlIw4c4BCe3VzgeioBY state OPEN type PullRequest @@ -57,7 +57,7 @@ Name Value ---- ----- updatedAt 9/9/2025 14:01:23 Milestone Milestone 3: Quality and Deployment -field-iteration +field-iteration createdAt 9/9/2025 14:01:17 number 26 Repository https://github.com/octodemo/rulasg-dev-1 @@ -78,15 +78,15 @@ Name Value ---- ----- updatedAt 9/9/2025 13:59:33 field-number 222 -field-iteration +field-iteration createdAt 9/9/2025 13:59:21 -number +number field-singleselect option-2 Status In Progress -body +body id PVTI_lADOAlIw4c4BCe3Vzgeiodc -state +state type DraftIssue -url +url Title DraftIssue for development -field-text text2 \ No newline at end of file +field-text text2 diff --git a/Test/public/edit-sync-projectitem-comments.test.ps1 b/Test/public/edit-sync-projectitem-comments.test.ps1 index 216f20d..a8ef15e 100644 --- a/Test/public/edit-sync-projectitem-comments.test.ps1 +++ b/Test/public/edit-sync-projectitem-comments.test.ps1 @@ -3,7 +3,7 @@ function Test_Edit_Sync_ProjectItem_AddComments_Issue { $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $i = $p.issue - $comment = "New comment" + $comment = "New comment" $comment2 = "Another comment2" @@ -19,7 +19,7 @@ function Test_Edit_Sync_ProjectItem_AddComments_Issue { # Act the edit part Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber -ItemId $i.id -FieldName "AddComment" -Value $comment - + # Assert the Edit part $staged = Get-ProjectItemStaged -Owner $owner -ProjectNumber $projectNumber Assert-AreEqual -Expected $comment -Presented $staged.$($i.id).addcomment.Value diff --git a/Test/public/integrations/sync-ProjectItemsBetweenProjects.test.ps1 b/Test/public/integrations/sync-ProjectItemsBetweenProjects.test.ps1 index cde1583..504f1eb 100644 --- a/Test/public/integrations/sync-ProjectItemsBetweenProjects.test.ps1 +++ b/Test/public/integrations/sync-ProjectItemsBetweenProjects.test.ps1 @@ -25,7 +25,7 @@ function Test_UpdateProjectItemsBetweenProjects{ $staged = Get-ProjectItemStaged -Owner $owner -ProjectNumber $destinationProjectNumber $p = $p626.syncBtwPrj_625 - + Assert-AreEqual -Expected $p.staged.Count -Presented $staged.Count foreach ($itemId in $staged.Keys) { Assert-AreEqual -Expected $p.staged.$itemId.Count -Presented $staged.$itemId.Count diff --git a/Test/public/integrations/update-ProjectImtesWithInjection.test.ps1 b/Test/public/integrations/update-ProjectImtesWithInjection.test.ps1 index 7c988c4..7762664 100644 --- a/Test/public/integrations/update-ProjectImtesWithInjection.test.ps1 +++ b/Test/public/integrations/update-ProjectImtesWithInjection.test.ps1 @@ -154,7 +154,7 @@ function Test_UpdateProjectWithInjection_Failed_1{ Assert-AreEqual -Expected $expectedStaged.$id.$field -Presented $staged.$id.$field.Value -Comment "Item $id Field $field" } } - + } function Test_InvokeProjectInjection{ diff --git a/Test/public/integrations/update-ProjectItemsStatusOnDueDate.test.ps1 b/Test/public/integrations/update-ProjectItemsStatusOnDueDate.test.ps1 index 6aadf28..72f8a1a 100644 --- a/Test/public/integrations/update-ProjectItemsStatusOnDueDate.test.ps1 +++ b/Test/public/integrations/update-ProjectItemsStatusOnDueDate.test.ps1 @@ -64,7 +64,3 @@ function Test_UpdateProjectItemStatusOnDueDate { Assert-DueDateStaged $false $false $otherDone -Expected ($p.staged + $p.includeDoneOther ) } - - - - diff --git a/Test/public/interactive_test/getproject.test.ps1 b/Test/public/interactive_test/getproject.test.ps1 index a54e28b..7ff74be 100644 --- a/Test/public/interactive_test/getproject.test.ps1 +++ b/Test/public/interactive_test/getproject.test.ps1 @@ -3,7 +3,7 @@ function Test_Get_Project_ItemId_Equal_Case_Sensitive { $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number MockCall_GetProject_700_CaseSensitive - + # Project -Owner github -ProjectNumber 20521 has two items with the same Id case sensitive # Forces project 700n with two item ids with case difference last leter of their id $item1 = "PVTI_lADOAlIw4c4BCe3Vzgec8pU" @@ -64,7 +64,7 @@ function Test_Get_Project_ItemId_Equal_Case_Sensitive_2 { $ht22 = @{} $ht22 += $ht22 - + } function Test_Get_Project_ItemId_Equal_Case_Sensitive_4 { @@ -89,7 +89,7 @@ function Test_Get_Project_ItemId_Equal_Case_Sensitive_4 { Assert-Count -Expected 4 -Presented $source.keys - # This will throw. + # This will throw. # Wrong way to merge hashtables $hasthrow = $false try{ diff --git a/Test/public/issues/Add-IssuePullRequestComment.test.ps1 b/Test/public/issues/Add-IssuePullRequestComment.test.ps1 index 0d78d72..543259c 100644 --- a/Test/public/issues/Add-IssuePullRequestComment.test.ps1 +++ b/Test/public/issues/Add-IssuePullRequestComment.test.ps1 @@ -22,7 +22,7 @@ function Test_AddComment_SUCCESS_Using_Cache{ function Test_AddComment_SUCCESS_Using_Direct{ - $p = Get-Mock_Project_700 + $p = Get-Mock_Project_700 $i = $p.Issue $id = $i.id $contentId = $i.contentId @@ -41,7 +41,7 @@ function Test_AddComment_SUCCESS_Using_Direct{ function Test_AddComment_SUCCESS_Using_Direct_PR{ - $p = Get-Mock_Project_700 + $p = Get-Mock_Project_700 $i = $p.PullRequest $id = $i.id $contentId = $i.contentId diff --git a/Test/public/issues/Add-ProjectSubIssue.test.ps1 b/Test/public/issues/Add-ProjectSubIssue.test.ps1 index 5405884..fda166b 100644 --- a/Test/public/issues/Add-ProjectSubIssue.test.ps1 +++ b/Test/public/issues/Add-ProjectSubIssue.test.ps1 @@ -6,12 +6,12 @@ function Test_AddProjectSubIssue_SUCCESS{ $parent = $p.Issue $i0 = $p.subIssuesToAdd[0] $i1 = $p.subIssuesToAdd[1] - + MockCall_GetProject $p -Cache MockCallJson -Command "Invoke-AddSubIssue -IssueId $($parent.contentId) -SubIssueUrl $($i0.url) -ReplaceParent False" -File "$($i0.addSubIssueMockfile)" MockCallJson -Command "Invoke-AddSubIssue -IssueId $($parent.contentId) -SubIssueUrl $($i1.url) -ReplaceParent False" -File "$($i1.addSubIssueMockfile)" - + # Act add SubIssue 1 $params = @{ @@ -50,7 +50,7 @@ function Test_GetProjectSubIssue_SUCCESS { $p = Get-Mock_Project_700 ; $owner = $p.Owner ; $projectNumber = $p.Number $i = $p.subIssueToShow - + MockCall_GetProject $p -SkipItems MockCallJson -Command "Invoke-GetItem -ItemId $($i.id)" -File "invoke-getitem-$($i.id).json" diff --git a/Test/public/issues/New-ProjectIssue.test.ps1 b/Test/public/issues/New-ProjectIssue.test.ps1 index 4862b48..fbd32a2 100644 --- a/Test/public/issues/New-ProjectIssue.test.ps1 +++ b/Test/public/issues/New-ProjectIssue.test.ps1 @@ -1,13 +1,13 @@ function Test_NewProjectIssueDirect{ - $p = Get-Mock_Project_700 - $r = $p.repo + $p = Get-Mock_Project_700 + $r = $p.repo $i = $p.issueToCreateAddAndRemove $issueTitle = "Random value title" $issueBody = "Random value body" $mockfilename = $i.createIssueMockfile - + # MockCall_GetProject $p MockCallJson -Command "Invoke-Repository -Owner $($r.owner) -Name $($r.name)" -FileName $r.getRepoMockFile MockCallJson -Command "Invoke-CreateIssue -RepositoryId $($r.id) -Title ""$issueTitle"" -Body ""$issueBody""" -FileName $mockfilename @@ -51,9 +51,8 @@ function Test_NewProjectIssue{ Title = $issueTitle Body = $issueBody } - + $result = New-ProjectIssue @params Assert-AreEqual -Expected $result -Presented $i.itemId } - diff --git a/Test/public/issues/Remove-ProjectIssue.test.ps1 b/Test/public/issues/Remove-ProjectIssue.test.ps1 index 58e4498..09f0b31 100644 --- a/Test/public/issues/Remove-ProjectIssue.test.ps1 +++ b/Test/public/issues/Remove-ProjectIssue.test.ps1 @@ -2,9 +2,9 @@ function Test_RemoveProjectIssue_SUCCESS { $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $i = $p.issueToCreateAddAndRemove - + MockCall_GetProject $p - + # Add item to project to remover it later MockCallJson -Command "Invoke-GetIssueOrPullRequest -Url $($i.url)" -fileName $i.getIssueOrPullRequestMockFile MockCallJson -Command "Invoke-AddItemToProject -ProjectId $($p.id) -ContentId $($i.id)" -fileName $i.addIssueToOProjectMockFile diff --git a/Test/public/items/project_item_show.test.ps1 b/Test/public/items/project_item_show.test.ps1 index 20e28c0..a77b6cc 100644 --- a/Test/public/items/project_item_show.test.ps1 +++ b/Test/public/items/project_item_show.test.ps1 @@ -2,7 +2,7 @@ function Test_Write_Sucess { Invoke-PrivateContext { Start-Transcript -Path test.log - + #Factors to test $factors = @( @{ Text = "Test with no other parameters"; ExpectedText = "Test with no other parameters" } @@ -14,7 +14,7 @@ function Test_Write_Sucess { @{ Color = "Cyan"; Text = " "; BetweenQuotes = $false; PreFix = "WhiteSpace: "; ; ExpectedText = "WhiteSpace: (empty)" } @{ Color = "Cyan"; Text = " "; BetweenQuotes = $true; PreFix = "WhiteSpace2: "; ; ExpectedText = 'WhiteSpace2: "(empty)"' } ) - + foreach ($factor in $factors) { $color = $factor.Color $text = $factor.Text @@ -29,7 +29,7 @@ function Test_Write_Sucess { write -color $color -text $text -BetweenQuotes:$BetweenQuotes -PreFix $PreFix -DefaultValue $DefaultValue } - + # Can not use MyTranscript as we are on a private context that does not hase access to Test private functions # Code loggic here to extract from transcript Stop-Transcript ; @@ -37,11 +37,11 @@ function Test_Write_Sucess { $i = 0..($transcriptContent.Count - 1) | Where-Object { $transcriptContent[$_] -eq "**********************" } $firstLine = $i[1] + 1 ; $lastLine = $i[2] - 1 $result = $transcriptContent[$firstLine..$lastLine] - + # Assert. $assertLine = 0 foreach ($factor in $factors) { - Assert-AreEqual -Expected $factor.ExpectedText -Presented $result[$assertLine] + Assert-AreEqual -Expected $factor.ExpectedText -Presented $result[$assertLine] $assertLine++ } } @@ -83,7 +83,7 @@ function Test_ShowProjectItem_SUCESS{ 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 } @@ -104,5 +104,5 @@ function Test_OpenInEditor{ Assert-IsNull -Object $result } - + } \ No newline at end of file diff --git a/Test/public/mockdatabase.test.ps1 b/Test/public/mockdatabase.test.ps1 index a05ecbf..554bc90 100644 --- a/Test/public/mockdatabase.test.ps1 +++ b/Test/public/mockdatabase.test.ps1 @@ -13,7 +13,7 @@ function Test_UpdateMock_DatabaseFileWithReplace{ # find "Issue for development" from database file $result = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -FieldName $fieldName -Filter $fieldValueActual -Exact -IncludeDone Assert-Count -Expected $totalCount -Presented $result - + $result = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -FieldName $fieldName -Filter $fieldValueNew -Exact -IncludeDone Assert-Count -Expected 0 -Presented $result diff --git a/Test/public/project/addprojectuser.test.ps1 b/Test/public/project/addprojectuser.test.ps1 index fc3ec29..d9ce11d 100644 --- a/Test/public/project/addprojectuser.test.ps1 +++ b/Test/public/project/addprojectuser.test.ps1 @@ -16,7 +16,7 @@ function Test_AddProjectUser_SUCCESS_SingleUser{ MockCallJson -Command "Invoke-GetUser -Handle $userName1" -File $u.u1.file MockCallJson -Command "Invoke-UpdateProjectV2Collaborators -ProjectId $projectId -collaborators ""$userId1"" -Role ""$role""" -File $fileName - + $result = Add-ProjectUser -Owner $owner -ProjectNumber $projectNumber -Handle $userName1 -Role $role Assert-IsTrue $result @@ -39,7 +39,7 @@ function Test_AddProjectUser_SUCCESS_MultipleUser{ 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 - + $result = $userNames | Add-ProjectUser -Owner $owner -ProjectNumber $projectNumber -Role $role Assert-IsTrue $result diff --git a/Test/public/project/getproject.test.ps1 b/Test/public/project/getproject.test.ps1 index 4529ce3..d566248 100644 --- a/Test/public/project/getproject.test.ps1 +++ b/Test/public/project/getproject.test.ps1 @@ -48,7 +48,7 @@ function Test_UpdateProject_With_Query_Success{ $query = $p.getProjectWithQuery.query $fileName = $p.getProjectWithQuery.getProjectWithQueryMockFile $totalCount = $p.getProjectWithQuery.totalCount - + MockCall_GitHubOrgProjectWithFields -Owner $owner -ProjectNumber $projectNumber -Query $query -FileName $fileName $result = Update-Project -Owner $owner -ProjectNumber $projectNumber -Query $query diff --git a/Test/public/project/updateprojectrecent.test.ps1 b/Test/public/project/updateprojectrecent.test.ps1 index fbe6669..e11b332 100644 --- a/Test/public/project/updateprojectrecent.test.ps1 +++ b/Test/public/project/updateprojectrecent.test.ps1 @@ -44,7 +44,7 @@ function Test_UpdateProjectRecent_UpdateBasedOn_FirstTime{ # Arrange $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $today = (Get-Mock_Today).today - + # Act - use the mock to run the project full sync to set the last recent update to today MockCall_GetProject_700 @@ -60,7 +60,7 @@ function Test_UpdateProjectRecent_UpdateBasedOn_SetToToday{ # Arrange $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $today = (Get-Mock_Today).today - + # Act - use the mock to run the project full sync to set the last recent update to today MockCall_GetProject_700 -Cache @@ -87,7 +87,7 @@ function Test_UpdateProjectRecent_UpdateBasedOn_SetToTehPast{ # Arrange $p = Get-Mock_Project_700 ; $owner = $p.owner ; $projectNumber = $p.number $d = Get-Mock_Today ; $today = $d.today ; $pastDate = $d.past - + # Act - use the mock to run the project full sync to set the last recent update to today MockCall_GetProject_700 -Cache diff --git a/Test/public/projectDatabase/project_database.test.ps1 b/Test/public/projectDatabase/project_database.test.ps1 index d385fe9..d8a36eb 100644 --- a/Test/public/projectDatabase/project_database.test.ps1 +++ b/Test/public/projectDatabase/project_database.test.ps1 @@ -12,12 +12,12 @@ function Test_SaveProjectDatabase_SafeId_Flag_PrivateCall{ $prj = Get-ProjectFromDatabase -Owner $Owner -ProjectNumber $ProjectNumber Assert-IsNotNull -Object $prj.safeId - + # Update project and the safeId should be updated $oldSafeId = $prj.safeId Save-ProjectDatabaseSafe -Database $prj $prj2 = Get-ProjectFromDatabase -Owner $Owner -ProjectNumber $ProjectNumber - + Assert-IsNotNull -Object $prj2.safeId Assert-AreNotEqual -Presented $oldSafeId -Expected $prj2.safeId } @@ -41,7 +41,7 @@ function Test_SaveProjectDatabase_Safe_PrivateCall{ # Check that safeId has changed $prj2 = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber Assert-AreNotEqual -Presented $prj2.safeId -Expected $prj1.safeId - + ## When saving again as prj1 that has been saved before it will throw $hasThrow = $false try{ diff --git a/Test/public/project_fields_list.test.ps1 b/Test/public/project_fields_list.test.ps1 index 8ecdb6b..1b339fe 100644 --- a/Test/public/project_fields_list.test.ps1 +++ b/Test/public/project_fields_list.test.ps1 @@ -11,7 +11,7 @@ function Test_GetProjectFields_SUCCESS_AllFields{ foreach ($expField in $p.fields.list){ $f = $result | Where-Object { $_.Name -eq $expField.Name } - + Assert-AreEqual -Presented $f.Name -Expected $expField.Name Assert-AreEqual -Presented $f.dataType -Expected $expField.dataType } diff --git a/Test/public/project_item.test.ps1 b/Test/public/project_item.test.ps1 index b48be58..df6a952 100644 --- a/Test/public/project_item.test.ps1 +++ b/Test/public/project_item.test.ps1 @@ -21,7 +21,7 @@ function Test_GetProjectItem_SUCCESS{ # Even if id is in project we make a direct call when with Force MockCallJson -Command "Invoke-GetItem -itemid $itemId" -FileName "invoke-getitem-$itemId-updated.json" - + # Act get value from project $result = Get-ProjectItem -Owner $Owner -ProjectNumber $ProjectNumber -ItemId $itemId @@ -203,13 +203,13 @@ function Test_ResetProjectItem_Value_SUCCESS{ # Act - reset F1 Reset-ProjectItem -Owner $owner -ProjectNumber $projectNumber -ItemId $itemId -FieldName $f1 - + $reset1 = Get-ProjectItem $itemId Assert-AreEqual -Expected $f1Actual -Presented $reset1.$f1 Assert-AreEqual -Expected $f2Value -Presented $reset1.$f2 - + # Act Reset F2 - + Reset-ProjectItem -Owner $owner -ProjectNumber $projectNumber -ItemId $itemId -FieldName $f2 $reset2 = Get-ProjectItem $itemId Assert-AreEqual -Expected $f1Actual -Presented $reset2.$f1 @@ -245,7 +245,7 @@ function Test_ResetProjectItem_SUCCESS{ # Act - reset F1 Reset-ProjectItem -Owner $owner -ProjectNumber $projectNumber -ItemId $itemId - + $reset = Get-ProjectItem $itemId Assert-AreEqual -Expected $f1Actual -Presented $reset.$f1 Assert-AreEqual -Expected $f2Actual -Presented $reset.$f2 @@ -357,7 +357,7 @@ function Test_ShowProjectItem_SUCCESS{ $p = Get-Mock_Project_700; $Owner = "octodemo" ; $ProjectNumber = 700 $i = $p.issue - + MockCall_GetProject -MockProject $p -SkipItems MockCall_GetItem -ItemId $i.id @@ -371,14 +371,14 @@ function Test_ShowProjectItem_SUCCESS{ # Act 0 $result0 = $item | Format-ProjectItem - + Assert-Count -Expected 1 -Presented $result0 Assert-AreEqual -Expected $id -Presented $result0[0].id Assert-AreEqual -Expected $title -Presented $result0[0].Title $result1 = $item | Format-ProjectItem -Attributes "id","Title","Status" - + Assert-Count -Expected 1 -Presented $result1 Assert-AreEqual -Expected $id -Presented $result1[0].id @@ -423,11 +423,11 @@ function Test_WhereLikeField_SUCCESS{ id = "1" title = "This is a sample title for testing" } - + # Test case 1: Single value match $result = $item | Test-WhereLikeField -Fieldname "title" -Values "sample" Assert-IsTrue -Condition $result - + # Test case 2: Multiple values match (AND logic) $result = $item | Test-WhereLikeField -Fieldname "title" -Values "sample","testing" Assert-IsTrue -Condition $result diff --git a/Test/public/project_item_list.test.ps1 b/Test/public/project_item_list.test.ps1 index 94e94b6..5b2276b 100644 --- a/Test/public/project_item_list.test.ps1 +++ b/Test/public/project_item_list.test.ps1 @@ -16,7 +16,7 @@ function Test_GetProjetItems_SUCCESS{ $randomItem = $result | Where-Object {$_.id -eq $i.id} Assert-AreEqual -Presented $randomItem.Title -Expected "Issue for development" - Assert-AreEqual -Presented $randomItem.Body -Expected "Body of issue for development" + Assert-AreEqual -Presented $randomItem.Body -Expected "Body of issue for development" Assert-AreEqual -Presented $randomItem.state -Expected "OPEN" Assert-AreEqual -Presented $randomItem.id -Expected "PVTI_lADOAlIw4c4BCe3Vzgeio4o" Assert-AreEqual -Presented $randomItem.type -Expected "Issue" @@ -88,5 +88,3 @@ function Test_ProjectItemList_ExcludeDone{ Assert-AreEqual -Expected ($itemsCount - $itemsDone) -Presented $result.Count } - - diff --git a/Test/public/project_item_search.test.ps1 b/Test/public/project_item_search.test.ps1 index ffcd17e..a148bcb 100644 --- a/Test/public/project_item_search.test.ps1 +++ b/Test/public/project_item_search.test.ps1 @@ -11,7 +11,7 @@ function Test_SearchProjectItem_SUCCESS_NoParameters { Assert-Count -Expected $p.items.totalCount -Presented $result } - + function Test_SearchProjectItem_SUCCESS_DefaultTitle{ @@ -74,7 +74,7 @@ function Test_SearchProjectItem_SUCCESS_AnyField{ $result = Search-ProjectItem -Owner $owner -ProjectNumber $projectNumber -Filter $_ -IncludeDone -AnyField Assert-Count -Expected $p.searchInAnyField.$_.totalCount -Presented $result - + foreach ($r in $result) { Assert-Contains -Expected $r.Title -Presented $p.searchInAnyField.$_.Titles } diff --git a/Test/public/project_items_staged.test.ps1 b/Test/public/project_items_staged.test.ps1 index c0832fa..d97cf17 100644 --- a/Test/public/project_items_staged.test.ps1 +++ b/Test/public/project_items_staged.test.ps1 @@ -22,9 +22,9 @@ function Test_SyncProjectItemsStaged_SUCCESS_Number{ $itemId1 = "PVTI_lADOAlIw4c4BCe3VzgeioBY" $contentId1 = "I_kwDOPrRnkc7KkwSq" - $fieldName = "field-number" + $fieldName = "field-number" $fieldBeforeValueNumber = 111.0 - $fieldValue = "10,1" + $fieldValue = "10,1" $fieldValueToUpdate = "10.1" $fieldId = "PVTF_lADOAlIw4c4BCe3Vzg0rhjU" $type = "number" @@ -74,7 +74,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Number{ $staged = Get-ProjectItemStaged -Owner $Owner -ProjectNumber $ProjectNumber Assert-Count -Expected 0 -Presented $staged - + $item1 = Get-ProjectItem -Owner $Owner -ProjectNumber $ProjectNumber -ItemId $itemId1 Assert-AreEqual -Expected $fieldValue -Presented $item1.$fieldName } @@ -88,7 +88,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Date{ $itemId1 = "PVTI_lADOAlIw4c4BCe3VzgeioBY" $contentId1 = "I_kwDOPrRnkc7KkwSq" - $fieldName = "field-date" + $fieldName = "field-date" $fieldBeforeValueDate = "2025-09-01" $fieldValue = "2021-01-10" $fieldValueToUpdate = "2021-01-10" @@ -153,7 +153,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_SingleSelect{ $field = $p.fieldsingleselect $itemId1 = $item.id - + $fieldName = $field.name $fieldId = $field.id $type = "singleSelectOptionId" @@ -185,7 +185,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_SingleSelect{ # Mock get-project MockCall_GetProject -MockProject $p -Cache - + Edit-ProjectItem -Owner $owner -ProjectNumber $projectNumber $itemId1 $fieldName $fieldNewValue @@ -214,7 +214,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_SingleSelect{ # Assert Assert-IsTrue -Condition $result - + $staged = Get-ProjectItemStaged -Owner $Owner -ProjectNumber $ProjectNumber Assert-Count -Expected 0 -Presented $staged @@ -500,7 +500,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_Issue { # Mock this call to cache the project in the test MockCall_GetProject_700 - + $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId @@ -591,7 +591,7 @@ function Test_SyncProjectItemsStaged_SUCCESS_Content_PullRequest { # Mock this call to cache the project in the test MockCall_GetProject_700 - + $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId @@ -916,7 +916,7 @@ function Test_Sync_ProjectDatabaseAsync_ClearValues{ $f = $p.fieldtext $fss = $p.fieldsingleselect - $projectId = $p.Id + $projectId = $p.Id $itemId1 = $i.Id $fieldComment1 = $f.name ; $fieldComment1Id = $f.Id ; $fieldCommentName = "field-text" $fieldPriority1 = $fss.name ; $fieldPriority1Id = $fss.Id ; $fieldPriorityName = "field-singleselect" @@ -964,7 +964,7 @@ function Test_Sync_ProjectDatabaseAsync_ClearValues{ "Done" "Saving [$projectId/$itemId1/$fieldPriority1Id ($fieldPriorityName) = """" ] ..." "Calling to update ItemField Async[True][$projectId/$itemId1/$fieldPriority1Id (singleSelectOptionId) = """" ]" - ) | ForEach-Object { + ) | ForEach-Object { Assert-Contains -Presented $transcript -Expected $_ -Comment "Not found in transcript: '$_'" } @@ -985,7 +985,7 @@ function Test_Sync_ProjectDatabase_ClearValues{ $f = $p.fieldtext $fss = $p.fieldsingleselect - $projectId = $p.Id + $projectId = $p.Id $itemId1 = $i.Id $fieldComment1 = $f.name ; $fieldComment1Id = $f.Id ; $fieldCommentName = "field-text" $fieldPriority1 = $fss.name ; $fieldPriority1Id = $fss.Id ; $fieldPriorityName = "field-singleselect" @@ -1028,7 +1028,7 @@ function Test_Sync_ProjectDatabase_ClearValues{ "Done" "Saving [$projectId/$itemId1/$fieldPriority1Id ($fieldPriorityName) = """" ] ..." "Calling to update ItemField Async[False][$projectId/$itemId1/$fieldPriority1Id (singleSelectOptionId) = """" ]" - ) | ForEach-Object { + ) | ForEach-Object { Assert-Contains -Presented $transcript -Expected $_ -Comment "Not found in transcript: '$_'" } diff --git a/Test/public/project_items_staged_Async.test.ps1 b/Test/public/project_items_staged_Async.test.ps1 index fb08cbc..5274bb0 100644 --- a/Test/public/project_items_staged_Async.test.ps1 +++ b/Test/public/project_items_staged_Async.test.ps1 @@ -310,7 +310,7 @@ function Test_SyncProjectItemsStaged_Async_SUCCESS_Content_Issue { # Mock this call to cache the project in the test MockCall_GetProject_700 - + $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force $projectId = $project.ProjectId diff --git a/Test/public/repository/get-repository.test.ps1 b/Test/public/repository/get-repository.test.ps1 index a2d37cc..a06711f 100644 --- a/Test/public/repository/get-repository.test.ps1 +++ b/Test/public/repository/get-repository.test.ps1 @@ -4,7 +4,7 @@ function Test_GetRepository{ $r = $p.repo $ro = $p.repo.object - + MockCallJson -Command "Invoke-Repository -Owner $($r.owner) -Name $($r.name)" -FileName $p.repoFile $result = Get-Repository -Owner $r.owner -Name $r.name @@ -17,7 +17,7 @@ function Test_GetRepository{ # Assert repo cache created $dbpath = get-Mock_DatabaseRootPath $dbname = "$($r.owner)-$($r.name).json" - + Assert-ItemExist -Path (Join-Path -Path $dbpath -ChildPath $dbname) # reset mocks and get repo to use cache diff --git a/deploy.ps1 b/deploy.ps1 index c6a5c21..c78abaf 100644 --- a/deploy.ps1 +++ b/deploy.ps1 @@ -19,7 +19,7 @@ .EXAMPLE $env:$NUGETAPIKEY = '****' - .\deploy.ps1 -VersionTag v10.0.01-alpha + .\deploy.ps1 -VersionTag v10.0.01-alpha .EXAMPLE .\deploy.ps1 -VersionTag v10.0.01-alpha -NuGetApiKey $NUGETAPIKEY -DependencyInjection $SCRIPTBLOCK_FOR_TESTING @@ -45,12 +45,12 @@ $MODULE_NAME = $MODULE_PATH | Split-Path -LeafBase $MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1" $MODULE_TOOLS = Join-Path -Path $MODULE_PATH -ChildPath "tools" -# Load helper +# Load helper # We dot souce the ps1 to allow all code to be in the same scope as the script # Easier to inject for testing with DependecyInjection parameter . ($MODULE_TOOLS | Join-Path -ChildPath "deploy.Helper.ps1") -if ($DependencyInjection) { - . $DependencyInjection +if ($DependencyInjection) { + . $DependencyInjection } # Process Tag @@ -79,4 +79,3 @@ if ( [string]::IsNullOrWhiteSpace($NuGetApiKey) ) { # Deploy module to PSGallery Invoke-DeployModuleToPSGallery -NuGetApiKey $NuGetApiKey -Force -ModuleManifestPath $MODULE_PSD1 - diff --git a/helper/module.helper.ps1 b/helper/module.helper.ps1 index 7fd1786..79e9af3 100644 --- a/helper/module.helper.ps1 +++ b/helper/module.helper.ps1 @@ -19,7 +19,7 @@ function Find-ModuleRootPath{ $path = $path | Split-Path -Parent continue } - + # foudn module return $path } diff --git a/include/MyWrite.ps1 b/include/MyWrite.ps1 index f451b55..7e8ffbb 100644 --- a/include/MyWrite.ps1 +++ b/include/MyWrite.ps1 @@ -195,16 +195,11 @@ function Get-ObjetString { if ($null -eq $Object) { return "null" } - + if ($Object -is [string]) { return $Object } - + return $Object | ConvertTo-Json -Depth 10 -ErrorAction SilentlyContinue } } - - - - - diff --git a/include/callAPI.ps1 b/include/callAPI.ps1 index efce501..f99c1e7 100644 --- a/include/callAPI.ps1 +++ b/include/callAPI.ps1 @@ -20,27 +20,27 @@ function Invoke-GraphQL { try { $apiUri = "https://api.$ApiHost/graphql" - + # Define the headers for the request $headers = @{ "Authorization" = "Bearer $token" "Content-Type" = "application/json" "GraphQL-Features" = $GRAPHQL_FEATURES } - + # Define the body for the request $body = @{ query = $Query variables = $Variables } | ConvertTo-Json -Depth 100 - + # Trace request "[[QUERY]]" | writedebug $Query | writedebug - + "[[VARIABLES]]" | writedebug $Variables | ConvertTo-Json -Depth 100 | writedebug - + # Send the request $start = Get-Date ">>> Invoke-RestMethod - $apiUri" | writedebug @@ -48,15 +48,15 @@ function Invoke-GraphQL { { $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 "[[RESPONSE]]" | writedebug $response | ConvertTo-Json -Depth 100 | writedebug - + if($response.errors){ throw "GraphQL query return errors - Error: $($response.errors.message)" } - + return $response } catch { @@ -82,21 +82,21 @@ function Invoke-RestAPI { try { $apiHost = "api.$ApiHost" - + # Define the headers for the request $headers = @{ "Authorization" = "Bearer $token" "Content-Type" = "application/json" } - + $uriBuilder = New-Object System.UriBuilder $uriBuilder.Scheme = "https" $uriBuilder.Host = $apiHost $uriBuilder.Path = $api $uriBuilder.Query = "?per_page=$PageSize" - + $url = $uriBuilder.Uri.AbsoluteUri - + # Send the request $start = Get-Date ">>> Invoke-RestMethod - $url" | writedebug @@ -125,7 +125,7 @@ function Invoke-RestAPI { } "<<< Invoke-RestMethod - $url [ $(((Get-Date) - $start).TotalSeconds) seconds]" | writedebug - + # Trace response "[[RESPONSE]]" | writedebug $response | ConvertTo-Json -Depth 100 | writedebug @@ -232,4 +232,3 @@ function writedebug{ Write-MyDebug $Message -Section "api" } } - diff --git a/include/config.ps1 b/include/config.ps1 index 741525c..87f8599 100644 --- a/include/config.ps1 +++ b/include/config.ps1 @@ -101,7 +101,7 @@ function Save-Configuration { return $false } finally{ - Remove-Variable -Scope Script -Name "config-$Key" -ErrorAction SilentlyContinue + Remove-Variable -Scope Script -Name "config-$Key" -ErrorAction SilentlyContinue } return $true diff --git a/include/featureflag.ps1 b/include/featureflag.ps1 index 7f32e12..aaed2a5 100644 --- a/include/featureflag.ps1 +++ b/include/featureflag.ps1 @@ -2,7 +2,7 @@ # # Feature Flags management module # -# This module will allow set Feature Flags to the module to quicker release +# This module will allow set Feature Flags to the module to quicker release # features with less risk # # Include design description @@ -120,7 +120,7 @@ function Get-ModuleNameRegisteredFeatureFlags{ return } - $Json = Get-Content $ffPath + $Json = Get-Content $ffPath $ff = $Json | ConvertFrom-Json @@ -164,4 +164,3 @@ if( -not (Test-Path function:$destFunction )){ Rename-Item -path Function:$function -NewName $destFunction Export-ModuleMember -Function $destFunction } - diff --git a/private/invokeRestMethord.ps1 b/private/invokeRestMethord.ps1 index a01d66c..7827c3c 100644 --- a/private/invokeRestMethord.ps1 +++ b/private/invokeRestMethord.ps1 @@ -15,14 +15,14 @@ # Headers = $Headers # Body = $Body # } - + # if (-not [string]::IsNullOrWhiteSpace($OutFile)) { # $params.OutFile = $OutFile # } -# ">> $Method $Uri" | Write-MyDebug -section "invokeRestMethod" +# ">> $Method $Uri" | Write-MyDebug -section "invokeRestMethod" # $result = Microsoft.PowerShell.Utility\Invoke-RestMethod @params -# "<< $Method $Uri" | Write-MyDebug -section "invokeRestMethod" +# "<< $Method $Uri" | Write-MyDebug -section "invokeRestMethod" # return $result diff --git a/private/item/convertItemToHash.ps1 b/private/item/convertItemToHash.ps1 index a316eb9..b8b36a3 100644 --- a/private/item/convertItemToHash.ps1 +++ b/private/item/convertItemToHash.ps1 @@ -43,7 +43,7 @@ function Convert-NodeItemToHash { $item.RepositoryOwner = $NodeItem.content.repository.owner.login $item.createdAt = GetDateTime -DateTimeString $NodeItem.content.createdAt $item.updatedAt = GetDateTime -DateTimeString $NodeItem.content.updatedAt - + # Url $item.urlPanel = Build-ItemPanelUrl -Item $item $item.url = [string]::IsNullOrWhiteSpace($item.urlContent) ? $item.urlPanel : $item.urlContent @@ -98,7 +98,7 @@ function Build-ItemPanelUrl { param( [Parameter(Position = 1)][object]$Item ) - + $baseUrl = $item.projectUrl $uriBuilder = [System.UriBuilder]::new($baseUrl) $uriBuilder.Path += "/views/1" @@ -115,7 +115,7 @@ function Build-ItemPanelUrl { # Get the final URL $finalUrl = $uriBuilder.ToString() - + return $finalUrl } diff --git a/private/item/itemValueTransformations.ps1 b/private/item/itemValueTransformations.ps1 index d8d412e..bf07fdf 100644 --- a/private/item/itemValueTransformations.ps1 +++ b/private/item/itemValueTransformations.ps1 @@ -6,16 +6,16 @@ function Convertto-ItemTransformedValue{ # Check if the Value contains any {{tag}} patterns if ($Value -match '\{\{[^}]+\}\}') { - + # Find all {{tag}} patterns in the value $m = [regex]::Matches($Value, '\{\{([^}]+)\}\}') - + $transformedValue = $Value - + foreach ($match in $m) { $fullTag = $match.Value # The full {{tag}} including braces $fieldName = $match.Groups[1].Value # Just the tag name without braces - + # Check if the item has this field if (! [string]::IsNullOrEmpty($Item.$fieldName)) { $fieldValue = $Item.$fieldName @@ -28,10 +28,10 @@ function Convertto-ItemTransformedValue{ Write-Warning "Field '$fieldName' not found in item. Tag '$fullTag' will remain unchanged." } } - + return $transformedValue } - + # No {{tag}} patterns found, return original value return $Value } \ No newline at end of file diff --git a/private/projectDatabase/project_database.ps1 b/private/projectDatabase/project_database.ps1 index 96e3f47..04506ba 100644 --- a/private/projectDatabase/project_database.ps1 +++ b/private/projectDatabase/project_database.ps1 @@ -137,7 +137,7 @@ function Save-ProjectDatabase{ if($projectnumber -le 0){ throw "Database.number is null or not a positive integer" } - + $dbkey = Get-DatabaseKey -Owner $owner -ProjectNumber $projectnumber if($Safe){ diff --git a/private/projectDatabase/project_database_Async.ps1 b/private/projectDatabase/project_database_Async.ps1 index d6fee4c..99b8f66 100644 --- a/private/projectDatabase/project_database_Async.ps1 +++ b/private/projectDatabase/project_database_Async.ps1 @@ -48,7 +48,7 @@ function Sync-ProjectAsync { $ItemsStagedId = $db.Staged.Keys | Copy-MyStringArray foreach ($itemId in $ItemsStagedId) { - + $itemStaged = $db.Staged.$itemId $FieldStagedId = $itemStaged.Keys | Copy-MyStringArray diff --git a/private/projectDatabase/project_database_Item.ps1 b/private/projectDatabase/project_database_Item.ps1 index d012481..ddb5d66 100644 --- a/private/projectDatabase/project_database_Item.ps1 +++ b/private/projectDatabase/project_database_Item.ps1 @@ -15,7 +15,7 @@ function Get-Item{ # Check if is staged if($database.Staged.$ItemId){ - + # Update ret with all staged fields values foreach($fieldKey in $database.Staged.$ItemId.keys){ @@ -38,7 +38,7 @@ function Get-Item{ } # Add the item id if not present - # This will happen if we have edited items + # This will happen if we have edited items # not downloading the item from server $ret.id = $ret.id ?? $ItemId @@ -84,7 +84,7 @@ function Find-Item { ) process { - + $found = @() foreach($item in $Database.items.Values){ $item = Get-Item -Database $Database -ItemId $item.id @@ -241,7 +241,7 @@ function Remove-ItemValueStaged{ # Remove value "Removing staged field [$FieldId] for item [$ItemId] in project [$($db.ProjectId)]" | Write-MyDebug $db.Staged.$ItemId.Remove($FieldId) - + # If no more fields in item remove item if ($db.Staged.$ItemId.Count -eq 0) { $db.Staged.Remove($ItemId)} diff --git a/private/projectDatabase/project_database_Item_Resolve.ps1 b/private/projectDatabase/project_database_Item_Resolve.ps1 index 39ae0e7..e2b0a65 100644 --- a/private/projectDatabase/project_database_Item_Resolve.ps1 +++ b/private/projectDatabase/project_database_Item_Resolve.ps1 @@ -13,7 +13,7 @@ function Resolve-ProjectItem { if (( ! $item ) -or $Force) { "Fetching item [$ItemId] from API" | Write-Verbose - + # Get direct. No cache as we are in a database modification context $item = Get-ProjectItemDirect -ItemId $ItemId diff --git a/private/projectDatabase/project_database_Sync.ps1 b/private/projectDatabase/project_database_Sync.ps1 index 655713a..22b17bb 100644 --- a/private/projectDatabase/project_database_Sync.ps1 +++ b/private/projectDatabase/project_database_Sync.ps1 @@ -41,7 +41,7 @@ function Sync-Project{ $ItemsStagedId = $db.Staged.Keys | Copy-MyStringArray foreach($itemId in $ItemsStagedId){ - + $itemStaged = $db.Staged.$itemId $FieldStagedId = $itemStaged.Keys | Copy-MyStringArray diff --git a/private/projectDatabase/project_database_call.ps1 b/private/projectDatabase/project_database_call.ps1 index af2ebda..0db49d0 100644 --- a/private/projectDatabase/project_database_call.ps1 +++ b/private/projectDatabase/project_database_call.ps1 @@ -47,7 +47,7 @@ function Update-ProjectItem { break } - default { + default { throw "Item type $($item.type) not supported for update" } } @@ -162,13 +162,13 @@ function Update-Issue { if([string]::IsNullOrWhiteSpace($Value)){ "Comment value is empty" | Write-MyWarning return $null, $null, "addComment" - } + } $params = @{ subjectid = $Id comment = $Value } - + if ($Async) { $params.projecthelper = $MODULE_PATH $job = Start-MyJob -Command AddCommentAsync -Parameters $params @@ -179,25 +179,25 @@ function Update-Issue { } $returnType = "addComment" - + } else { # TITLE AND BODY - + $params = @{ id = $Id title = if ($FieldId -eq "title") { $Value } else { "" } body = if ($FieldId -eq "body") { $Value } else { "" } } - + if ($Async) { $params.projecthelper = $MODULE_PATH $job = Start-MyJob -Command UpdateIssueAsync -Parameters $params - + } else { $result = Invoke-MyCommand -Command UpdateIssue -Parameters $params } - + $returnType = "updateIssue" } @@ -221,13 +221,13 @@ function Update-PullRequest { if([string]::IsNullOrWhiteSpace($Value)){ "Comment value is empty" | Write-MyWarning return $null, $null, "addComment" - } + } $params = @{ subjectid = $Id comment = $Value } - + if ($Async) { $params.projecthelper = $MODULE_PATH $job = Start-MyJob -Command AddCommentAsync -Parameters $params @@ -238,20 +238,20 @@ function Update-PullRequest { } $returnType = "addComment" - + } else { # TITLE AND BODY - + $params = @{ id = $Id title = if ($FieldId -eq "title") { $Value } else { "" } body = if ($FieldId -eq "body") { $Value } else { "" } } - + if ($Async) { $params.projecthelper = $MODULE_PATH $job = Start-MyJob -Command UpdatePullRequestAsync -Parameters $params - + } else { $result = Invoke-MyCommand -Command UpdatePullRequest -Parameters $params @@ -327,7 +327,7 @@ function Update-ItemField { } } else { - + if ([string]::IsNullOrWhiteSpace($value)) { $result = Invoke-MyCommand -Command GitHub_ClearProjectV2ItemFieldValue -Parameters $params $resultDataType = "clearProjectV2ItemFieldValue" diff --git a/private/projectDatabase/project_database_update.ps1 b/private/projectDatabase/project_database_update.ps1 index fc4896a..f492643 100644 --- a/private/projectDatabase/project_database_update.ps1 +++ b/private/projectDatabase/project_database_update.ps1 @@ -193,7 +193,7 @@ function Set-ContentFields { param( [Parameter(ValueFromPipeline)][hashtable]$Fields ) - + # TITLE # Remove Title field comming from CustomFields $fieldTitleId = $fields.Keys | Where-Object {$fields.$_.dataType -eq "TITLE"} @@ -204,7 +204,7 @@ function Set-ContentFields { if($fieldTitleId){ throw "Set-ContentFields: [ Title ] field already exists. Please remove or rename this field from the project" } - + # Add new title field $fields.title = @{ id = "title" diff --git a/public/driver/issue/Invoke-AddComment.ps1 b/public/driver/issue/Invoke-AddComment.ps1 index 158a8fc..8fec723 100644 --- a/public/driver/issue/Invoke-AddComment.ps1 +++ b/public/driver/issue/Invoke-AddComment.ps1 @@ -5,7 +5,7 @@ function Invoke-AddComment { [Parameter(Mandatory = $true)][string]$Comment ) - # Use the environmentraviable + # Use the environmentraviable $token = Get-GithubToken if(-not $token){ throw "GH Cli Auth Token not available. Run 'gh auth login' in your terminal." diff --git a/public/driver/issue/Invoke-CreateIssue.ps1 b/public/driver/issue/Invoke-CreateIssue.ps1 index 5fc0e49..b4af1dc 100644 --- a/public/driver/issue/Invoke-CreateIssue.ps1 +++ b/public/driver/issue/Invoke-CreateIssue.ps1 @@ -3,7 +3,7 @@ function Invoke-CreateIssue { [Parameter(Mandatory=$true)][string]$RepositoryId, # Node ID of the repository [Parameter(Mandatory=$true)][string]$Title, # Title for the issue [Parameter()][string]$Body # Issue body/description - + #[Parameter()][string[]]$ProjectIds # Node IDs of projects # [Parameter()][string]$ParentIssueId, # Node ID of parent issue # [Parameter()][string]$ClientMutationId, # Client mutation identifier @@ -21,7 +21,7 @@ function Invoke-CreateIssue { repositoryId = $RepositoryId title = $Title | ConvertTo-InvokeParameterString body = $Body | ConvertTo-InvokeParameterString - + #projectIds = $ProjectIds # assigneeIds = $AssigneeIds # clientMutationId= $ClientMutationId diff --git a/public/driver/issue/Invoke-GetItem.ps1 b/public/driver/issue/Invoke-GetItem.ps1 index a16127d..fef6600 100644 --- a/public/driver/issue/Invoke-GetItem.ps1 +++ b/public/driver/issue/Invoke-GetItem.ps1 @@ -4,7 +4,7 @@ function Invoke-GetItem { [Parameter(Mandatory = $true)][string]$ItemId ) - # Use the environmentraviable + # Use the environmentraviable $token = Get-GithubToken if(-not $token){ throw "GH Cli Auth Token not available. Run 'gh auth login' in your terminal." diff --git a/public/driver/issue/Invoke-UpdateIssue.ps1 b/public/driver/issue/Invoke-UpdateIssue.ps1 index d2eeaa9..b65d130 100644 --- a/public/driver/issue/Invoke-UpdateIssue.ps1 +++ b/public/driver/issue/Invoke-UpdateIssue.ps1 @@ -45,7 +45,7 @@ function Invoke-UpdateIssue{ # Title can not be empty if(-not [string]::IsNullOrWhiteSpace($Title)){ $variables.input.title = $Title | ConvertTo-InvokeParameterString - } + } # This will avoid to empty the body if(-not [string]::IsNullOrWhiteSpace($Body)){ diff --git a/public/driver/user/user.ps1 b/public/driver/user/user.ps1 index 755c291..7b03f04 100644 --- a/public/driver/user/user.ps1 +++ b/public/driver/user/user.ps1 @@ -28,7 +28,7 @@ function Get-User{ } else { Write-MyDebug "Get-User: User retreived" -Section "Get-User" $result = Invoke-MyCommand -Command "getUser" -Parameters @{handle=$Handle} - + # Cache Save-Database -Key "user-$Handle" -Database $result } diff --git a/public/environment/environmentCache.ps1 b/public/environment/environmentCache.ps1 index 4560aa5..53300f1 100644 --- a/public/environment/environmentCache.ps1 +++ b/public/environment/environmentCache.ps1 @@ -70,7 +70,7 @@ function Get-OwnerAndProjectNumber{ Set-EnvItem -Name "EnvironmentCache_Owner" -Value $Owner } } - + $projectNumberCache = Get-EnvItem -Name "EnvironmentCache_ProjectNumber" if([string]::IsNullOrWhiteSpace($ProjectNumber)){ $ProjectNumber = $projectNumberCache diff --git a/public/graphql/getContentId.query b/public/graphql/getContentId.query index 76bfd8a..8ff9033 100644 --- a/public/graphql/getContentId.query +++ b/public/graphql/getContentId.query @@ -7,7 +7,7 @@ query GetContentId($owner: String!, $name: String!, $number: Int!) { projectItems(first: 100) { nodes { id - project { + project { id title number @@ -29,7 +29,7 @@ query GetContentId($owner: String!, $name: String!, $number: Int!) { projectItems(first: 100) { nodes { id - project { + project { id title number @@ -48,4 +48,4 @@ query GetContentId($owner: String!, $name: String!, $number: Int!) { } } } -} \ No newline at end of file +} diff --git a/public/integrations/Edit-ProjectItemWithValues.ps1 b/public/integrations/Edit-ProjectItemWithValues.ps1 index 749b44f..761d7e8 100644 --- a/public/integrations/Edit-ProjectItemWithValues.ps1 +++ b/public/integrations/Edit-ProjectItemWithValues.ps1 @@ -33,4 +33,3 @@ function Edit-ProjectItemWithValues { } } Export-ModuleMember -Function Edit-ProjectItemWithValues - diff --git a/public/integrations/update-ProjectItemsStatusOnDueDate.ps1 b/public/integrations/update-ProjectItemsStatusOnDueDate.ps1 index 4cf4d3f..64607e5 100644 --- a/public/integrations/update-ProjectItemsStatusOnDueDate.ps1 +++ b/public/integrations/update-ProjectItemsStatusOnDueDate.ps1 @@ -6,7 +6,7 @@ This cmdlet helps you maintain the status of project items based on a planning date field (e.g. 'DueDate', 'Target', etc.). The goal is set items to Action Required when due date is passed or reached, or set a Planned status if the due date is in the future. If items are closed (aka status "Done"), their due date is cleared. - + To achieve this objective here the loggig implemented: For each project item that has the specified due date field: - If the due date is today or in the past: @@ -75,7 +75,7 @@ Clears Due on items whose status is Cancelled (treating them as done-like). .NOTES - Throws if both -AnyStatus and -StatusDone are supplied. + Throws if both -AnyStatus and -StatusDone are supplied. Avoid conflict when item is in the past with the Specified Done Status. reopening closed items when Status Done and has Due field in the past. In this cases we could set to Action status or clear DueDate. #> @@ -199,5 +199,3 @@ function Invoke-ProjectInjectionOnDueDate { } } } # Do not export this function to avoid conflicts with Update-ProjectItemsWithIntegration - - diff --git a/public/integrations/update-ProjectItemsWithInjection.ps1 b/public/integrations/update-ProjectItemsWithInjection.ps1 index a63cb35..875a924 100644 --- a/public/integrations/update-ProjectItemsWithInjection.ps1 +++ b/public/integrations/update-ProjectItemsWithInjection.ps1 @@ -59,7 +59,7 @@ function Invoke-ProjectInjectionFunctions { param() $functions = 'Get-Command -Name "Invoke-ProjectInjection_*" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty name' - + # Get all functions that start with Invoke-ProjectInjection_ if ($functions) { diff --git a/public/issues/Add-IssuePullRequestComment.ps1 b/public/issues/Add-IssuePullRequestComment.ps1 index d69d8e5..3180ae8 100644 --- a/public/issues/Add-IssuePullRequestComment.ps1 +++ b/public/issues/Add-IssuePullRequestComment.ps1 @@ -8,7 +8,7 @@ function Add-IssuePullRequestCommentDirect { # Try to find item on context project ($Owner, $ProjectNumber) = Get-OwnerAndProjectNumber -Owner $Owner -ProjectNumber $ProjectNumber - if (! [string]::IsNullOrWhiteSpace($owner) -and ! [string]::IsNullOrWhiteSpace($ProjectNumber)) { + if (! [string]::IsNullOrWhiteSpace($owner) -and ! [string]::IsNullOrWhiteSpace($ProjectNumber)) { $item = Get-ProjectItem -ItemId $ItemId -Owner $Owner -ProjectNumber $ProjectNumber } diff --git a/public/issues/Get-ProjectIssue.ps1 b/public/issues/Get-ProjectIssue.ps1 index 2d23033..6a47fad 100644 --- a/public/issues/Get-ProjectIssue.ps1 +++ b/public/issues/Get-ProjectIssue.ps1 @@ -36,11 +36,11 @@ function Get-ProjectIssue { ) # Check the active project cache just in case is there. - # We could try to check all cached projects but that could be + # We could try to check all cached projects but that could be # Challenging as we are not user of the cache status for that item $owner,$projectNumber = Get-OwnerAndProjectNumber $item = Get-ProjectItemByUrl -Owner $owner -ProjectNumber $projectNumber -Url $Url -PassThru -Force:$Force - if( $item ) { + if( $item ) { $issue = $item | Convert-ItemToIssue return $issue } diff --git a/public/issues/New-ProjectIssue.ps1 b/public/issues/New-ProjectIssue.ps1 index a9719af..a74437c 100644 --- a/public/issues/New-ProjectIssue.ps1 +++ b/public/issues/New-ProjectIssue.ps1 @@ -60,17 +60,17 @@ function New-ProjectIssue { # Create Issue $url = New-ProjectIssueDirect -RepoOwner $RepoOwner -RepoName $RepoName -Title $Title -Body $Body - + if(! $url ){ "Issue could not be created" | Write-MyError return $null } - + # Add issue to project $ProjectOwner,$ProjectNumber = Get-OwnerAndProjectNumber -Owner $ProjectOwner -ProjectNumber $ProjectNumber - + $itemId = Add-ProjectItem -Owner $ProjectOwner -ProjectNumber $ProjectNumber -Url $url - + return $itemId } catch{ diff --git a/public/issues/Remove-IssueDirect.ps1 b/public/issues/Remove-IssueDirect.ps1 index 686527f..abaee34 100644 --- a/public/issues/Remove-IssueDirect.ps1 +++ b/public/issues/Remove-IssueDirect.ps1 @@ -7,9 +7,9 @@ function Remove-IssueDirect { param( [Parameter(Position = 0)][string]$Url ) - + $issue = Get-ProjectIssue -Url $Url - + if( ! $issue ){ throw "Issue with URL $Url not found" } diff --git a/public/items/project_item.ps1 b/public/items/project_item.ps1 index a089f0a..782b04a 100644 --- a/public/items/project_item.ps1 +++ b/public/items/project_item.ps1 @@ -23,7 +23,7 @@ function Get-ProjectItem { begin { ($Owner, $ProjectNumber) = Get-OwnerAndProjectNumber -Owner $Owner -ProjectNumber $ProjectNumber if ([string]::IsNullOrWhiteSpace($owner) -or [string]::IsNullOrWhiteSpace($ProjectNumber)) { "Owner and ProjectNumber are required" | Write-MyError; return $null } - + $db = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems if(! $db){ "Project not found for Owner [$Owner] and ProjectNumber [$ProjectNumber]" | Write-MyError; return $null} @@ -40,7 +40,7 @@ function Get-ProjectItem { return $item } - + end { if ($dirty) { "Saving dirty database" | Write-Verbose @@ -64,7 +64,7 @@ function Get-ProjectItemByUrl{ begin { ($Owner, $ProjectNumber) = Get-OwnerAndProjectNumber -Owner $Owner -ProjectNumber $ProjectNumber if ([string]::IsNullOrWhiteSpace($owner) -or [string]::IsNullOrWhiteSpace($ProjectNumber)) { return $null } - + $db = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems if(! $db){ "Project not found for Owner [$Owner] and ProjectNumber [$ProjectNumber]" | Write-MyError; return $null} @@ -77,7 +77,7 @@ function Get-ProjectItemByUrl{ $item = Get-ItemByUrl -Database $db -Url $Url # TODO: Create a Resolve-ProjectItemByUrl - Depend on function to get item from project remote by url - # Get-ItemByUrl only check cache so we need a function that will retreive item from project remote + # Get-ItemByUrl only check cache so we need a function that will retreive item from project remote # and update the project cache. # This function depends on the capacity to retreive items by filter # Project API has just been updated to allow search project items @@ -115,7 +115,7 @@ function Test-ProjectItem { process { $ret = Test-Item -Database $db -Url $Url - + return $ret } @@ -149,7 +149,7 @@ function Search-ProjectItem { ($Owner, $ProjectNumber) = Get-OwnerAndProjectNumber -Owner $Owner -ProjectNumber $ProjectNumber if ([string]::IsNullOrWhiteSpace($owner) -or [string]::IsNullOrWhiteSpace($ProjectNumber)) { "Owner and ProjectNumber are required" | Write-MyError; return $null } - + # Get items as hashtable for later queries $items = Get-ProjectItems -Owner $Owner -ProjectNumber $ProjectNumber -Force:$Force -IncludeDone:$IncludeDone -AsHashtable @@ -172,7 +172,7 @@ function Search-ProjectItem { } else { # Default to "Title as the single field to search" $FieldName = [string]::IsNullOrWhiteSpace($FieldName) ? "Title" : $FieldName - + if($Exact){ # Pick just the first value a in Exact fielname there is only one match Fieldname value $found = $items.Values | Where-Object { Test-WhereExactField -Item $_ -Fieldname $FieldName -Value $Filter[0] } @@ -291,12 +291,12 @@ function Open-ProjectItem { begin { - + ($Owner, $ProjectNumber) = Get-OwnerAndProjectNumber -Owner $Owner -ProjectNumber $ProjectNumber if ([string]::IsNullOrWhiteSpace($owner) -or [string]::IsNullOrWhiteSpace($ProjectNumber)) { throw "Owner and ProjectNumber are required on Open-ProjectItem" } - + "Project set to [$owner/$ProjectNumber]" | Write-Verbose } @@ -306,7 +306,7 @@ function Open-ProjectItem { $itemId = $Id "Opening item [$ItemId] in project [$Owner/$ProjectNumber]" | Write-Verbose - + $item = Get-ProjectItem -Owner $Owner -ProjectNumber $ProjectNumber -ItemId $ItemId if (-not $item) { throw "Item not found for Owner [$Owner], ProjectNumber [$ProjectNumber] and ItemId [$ItemId]" @@ -318,11 +318,11 @@ function Open-ProjectItem { # fall back to url if urlcontent is empty $url = $item.urlContent ?? $item.url } - + if ([string]::IsNullOrWhiteSpace($url)) { # We should never reach this point as all items has a urlpanel set in Convert-NodeItemToHash "No URL found for Item [$ItemId] type [ $($item.type) ]" | Write-Error - return + return } Open-Url -Url $url @@ -351,30 +351,30 @@ function Edit-ProjectItem { ($Owner, $ProjectNumber) = Get-OwnerAndProjectNumber -Owner $Owner -ProjectNumber $ProjectNumber if ([string]::IsNullOrWhiteSpace($owner) -or [string]::IsNullOrWhiteSpace($ProjectNumber)) { "Owner and ProjectNumber are required" | Write-MyError; return $null } - + # Force cache update # Full sync if force. Skip items if not force $db = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force:$Force -SkipItems:$(-not $Force) - + # Find the actual value of the item. Item+Staged # Ignore $dirty as we are changing the db we will always save ($item, $dirty) = Resolve-ProjectItem -Database $db -ItemId $ItemId - + # if the item is not found if($null -eq $item){ "Item [$ItemId] not found" | Write-MyError; return $null} - + # Value transformations $valueTransformed = Convertto-ItemTransformedValue -Item $item -Value $Value - + # Check if value is the same if ( AreEqual -Object1:$item.$FieldName -Object2:$valueTransformed) { "The value is the same, no need to stage it" | Write-Verbose return } - + # save the new value Save-ItemFieldValue $db $itemId $FieldName $valueTransformed - + # Commit changes to the database Save-ProjectDatabaseSafe -Database $db } @@ -394,7 +394,7 @@ function Reset-ProjectItem { ($Owner, $ProjectNumber) = Get-OwnerAndProjectNumber -Owner $Owner -ProjectNumber $ProjectNumber if ([string]::IsNullOrWhiteSpace($owner) -or [string]::IsNullOrWhiteSpace($ProjectNumber)) { "Owner and ProjectNumber are required" | Write-MyError; return $null } - + # Force cache update # Full sync if force. Skip items if not force $db = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force:$Force -SkipItems:$(-not $Force) @@ -434,7 +434,7 @@ function Add-ProjectItemDirect { begin{ ($Owner, $ProjectNumber) = Get-OwnerAndProjectNumber -Owner $Owner -ProjectNumber $ProjectNumber if ([string]::IsNullOrWhiteSpace($owner) -or [string]::IsNullOrWhiteSpace($ProjectNumber)) { "Owner and ProjectNumber are required" | Write-MyError; return $null } - + # Get project id $db = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber if ( ! $db) { @@ -498,13 +498,13 @@ function Remove-ProjectItemDirect { [Parameter()][string]$ProjectNumber, [Parameter(Mandatory, ValueFromPipelineByPropertyName,ValueFromPipeline, Position = 0)][Alias("Id")][string]$ItemId, [Parameter()][switch]$Force - + ) begin { ($Owner, $ProjectNumber) = Get-OwnerAndProjectNumber -Owner $Owner -ProjectNumber $ProjectNumber if ([string]::IsNullOrWhiteSpace($owner) -or [string]::IsNullOrWhiteSpace($ProjectNumber)) { "Owner and ProjectNumber are required" | Write-MyError; return $null } - + # Get project id $db = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber if ($db) { @@ -516,14 +516,14 @@ function Remove-ProjectItemDirect { # With no Project Id we ned to abort if( ! $projectId ){ return } - + $item = Get-Item $db $ItemId - + if (-not $item) { "Item [$ItemId] not found in project [$Owner/$ProjectNumber]" | Write-MyHost return } - + $itemId = $item.id $itemUrl = $item.url @@ -536,7 +536,7 @@ function Remove-ProjectItemDirect { # Fake execution return ItemId return $itemUrl } - + # check if FAILED if ($response.errors -or ($response.data.deleteProjectV2Item.deletedItemId -ne $ItemId)) { "Some issue removing [$ItemId] from project" | Write-MyError @@ -548,7 +548,7 @@ function Remove-ProjectItemDirect { return $itemUrl } } - + $result = $response.data.deleteProjectV2Item.deletedItemId if($result -ne $ItemId){ @@ -556,7 +556,7 @@ function Remove-ProjectItemDirect { } } catch { - throw "Error remvoving item [$ItemId] from project: $_" + throw "Error remvoving item [$ItemId] from project: $_" } # Remove item from cache @@ -578,7 +578,7 @@ function Remove-ProjectItem { [Parameter(Mandatory, ValueFromPipelineByPropertyName,ValueFromPipeline, Position = 0)][Alias("Id")][string]$ItemId, [Parameter()][switch]$DeleteIssue, [Parameter()][switch]$Force - + ) process { @@ -589,7 +589,7 @@ function Remove-ProjectItem { $itemUrl = Remove-ProjectItemDirect -Owner $Owner -ProjectNumber $ProjectNumber -ItemId $ItemId -Force:$Force return $itemUrl } - + # Find Item to remove $item = Get-ProjectItem -ItemId $ItemId @@ -599,7 +599,7 @@ function Remove-ProjectItem { } # Remove issue associated with the item - # If DraftIssue when it´s already delete when removed from project + # If DraftIssue when it´s already delete when removed from project # If PullRequest. PR can not be deleted if($item.type -ne "Issue") { "Item [$ItemId] is not an Issue, skipping issue deletion" | Write-MyHost @@ -670,7 +670,7 @@ function Test-WhereLikeAnyField { return $true } } - + return $false } } @@ -688,7 +688,7 @@ function Test-WhereExactAnyField { return $true } } - + return $false } } @@ -706,7 +706,7 @@ function Test-WhereLikeField { $itemValue = $item.$FieldName $foundCount = 0 - + foreach ($v in $Values) { if( $itemValue -like "*$v*"){ $foundCount ++ diff --git a/public/items/project_item_show.ps1 b/public/items/project_item_show.ps1 index 0e218e2..6c47e21 100644 --- a/public/items/project_item_show.ps1 +++ b/public/items/project_item_show.ps1 @@ -41,7 +41,7 @@ function Show-ProjectItem{ @(@{Name="Status"; Color = $statusColor}) ) } - + # Before all addJumpLine -message "Header Start" @@ -51,14 +51,14 @@ function Show-ProjectItem{ $item.number | write -Color Cyan -PreFix "# " addSpace $item.Title | write -Color Yellow -BetweenQuotes - + addJumpLine -message "Header End" - + # URL $item.url | write -Color White addJumpLine -message "End Url" - + # Fields by line if($FieldsToShow){ addJumpLine -message "Fields Before" @@ -69,7 +69,7 @@ function Show-ProjectItem{ } addJumpLine -message "Fields After" - + # Body "Body" | writeHeader $item.Body | write -Color Gray @@ -193,13 +193,13 @@ function writeComment1{ "Processing Comment by $($Comment.author.login)" | Write-Verbose $header = "Comment [$order/$($item.commentsTotalCount)]" - + if($order -eq $item.commentsTotalCount) {$header += " Last"} addJumpLine -message "Comment 1 Start" addJumpLine -message "Comment 1 before header" $header | write Cyan - + addSpace # $Comment.author | write -Color DarkGray -PreFix "By: " ; addSpace @@ -210,7 +210,7 @@ function writeComment1{ "------------" | write Cyan # addSpace ; addSpace - + addJumpLine -message "Comment 1 before body" $Comment.body | write -Color Gray } @@ -226,15 +226,15 @@ function writeComment2{ process { $header = "Comment [$order/$($item.commentsTotalCount)]" - + if($order -eq $item.commentsTotalCount) {$header += " Last"} addJumpLine -message "Comment 2 Start" - + writeHeader $header -Author $Comment.author -UpdatedAt $Comment.updatedAt - + addJumpLine -message "Comment 2 Body Start" - + $Comment.body | write -Color Gray addJumpLine -message "Comment 2 Body End" @@ -273,7 +273,7 @@ function write{ if($SuFix){ $text = $text + $SuFix } - + $text | writetoconsole -Color:$color -NoNewLine @@ -345,9 +345,9 @@ function Start-WriteBuffer{ } function Stop-WriteBuffer{ $buffer = $script:outputBuffer - + $script:outputBuffer = $null - + "Stopping Write Buffer [$($buffer.Count)] Lines" | Write-MyDebug -section "WriteBuffer" return $buffer diff --git a/public/items/use_order.ps1 b/public/items/use_order.ps1 index 6cacdb8..3cf3596 100644 --- a/public/items/use_order.ps1 +++ b/public/items/use_order.ps1 @@ -31,7 +31,7 @@ function Use-Order { if ($Ordinal -gt -1) { $itemId = $finallist[$Ordinal].id - + if($OpenInBrowser){ # Open $item = Get-ProjectItem -ItemId $itemId diff --git a/public/project/addprojectuser.ps1 b/public/project/addprojectuser.ps1 index 0a55810..840893b 100644 --- a/public/project/addprojectuser.ps1 +++ b/public/project/addprojectuser.ps1 @@ -16,9 +16,9 @@ function Add-ProjectUser { if ([string]::IsNullOrWhiteSpace($owner) -or [string]::IsNullOrWhiteSpace($ProjectNumber)) { throw "Owner and ProjectNumber are required on Get-Project" } - + $project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -SkipItems - + $projectId = $project.ProjectId $userIds = @() @@ -26,7 +26,7 @@ function Add-ProjectUser { } process{ - + $user = Get-User -Handle $Handle $userId = $user.Id diff --git a/public/project/findproject.ps1 b/public/project/findproject.ps1 index 3223a80..8dd40fa 100644 --- a/public/project/findproject.ps1 +++ b/public/project/findproject.ps1 @@ -38,7 +38,7 @@ function Find-Project{ if($null -eq $projects){ "Error finding projects for owner [$Owner] with pattern [$Pattern]" | Write-MyError return $null - } + } "[$($projects.Count)] projects found" | Write-MyVerbose return $projects diff --git a/public/prompt/getPrompt.ps1 b/public/prompt/getPrompt.ps1 index b889fec..e73d4ff 100644 --- a/public/prompt/getPrompt.ps1 +++ b/public/prompt/getPrompt.ps1 @@ -46,7 +46,7 @@ function Get-ProjecthelperPromptSettings { } return $global:ProjecthelperPromoptSettings -} +} function Write-ProjecthelperPrompt { [CmdletBinding()] diff --git a/release.ps1 b/release.ps1 index 1a35f1a..c014c56 100644 --- a/release.ps1 +++ b/release.ps1 @@ -6,7 +6,7 @@ Create a tag on the repo and a release to that tag on GitHub remote repo. This script works very well with GitHub Actions workflow that run on release creation. - Check the following workflow as an example: + Check the following workflow as an example: https://raw.githubusercontent.com/rulasg/DemoPsModule/main/.github/workflows/deploy_module_on_release.yml @@ -32,8 +32,8 @@ .EXAMPLE .\release.ps1 -VersionTag v10.0.01-alpha -CreateTag -Force - Create tag and create release without confirmation. - + Create tag and create release without confirmation. + .LINK https://raw.githubusercontent.com/rulasg/DemoPsModule/main/release.ps1 #> @@ -61,10 +61,9 @@ if ($CreateTag) { if ($PSCmdlet.ShouldProcess($VersionTag, "gh release create")) { if ($NotPreRelease) { - gh release create $VersionTag --generate-notes --verify-tag --title "Release $VersionTag" + gh release create $VersionTag --generate-notes --verify-tag --title "Release $VersionTag" } else { gh release create $VersionTag --generate-notes --verify-tag --title "Release $VersionTag (PreRelease)" --prerelease } } - diff --git a/test.ps1 b/test.ps1 index 2f478ff..ff29167 100644 --- a/test.ps1 +++ b/test.ps1 @@ -32,4 +32,3 @@ $TestName = [string]::IsNullOrWhiteSpace($TestName) ? $global:TestNameVar : $Tes # Call TestingHelper to run the tests Invoke-TestingHelper -TestName $TestName -ShowTestErrors:$ShowTestErrors - diff --git a/tools/Test_Helper/Test_Helper.psd1 b/tools/Test_Helper/Test_Helper.psd1 index 0ffc471..76dad7f 100644 --- a/tools/Test_Helper/Test_Helper.psd1 +++ b/tools/Test_Helper/Test_Helper.psd1 @@ -129,4 +129,3 @@ PrivateData = @{ # DefaultCommandPrefix = '' } - diff --git a/tools/Test_Helper/Test_Helper.psm1 b/tools/Test_Helper/Test_Helper.psm1 index 026beb2..2a22cac 100644 --- a/tools/Test_Helper/Test_Helper.psm1 +++ b/tools/Test_Helper/Test_Helper.psm1 @@ -24,4 +24,3 @@ Foreach($import in @($Public + $Private)) # Read in or create an initial config file and variable # Export Public functions ($Public.BaseName) for WIP modules # Set variables visible to the module and its functions only - diff --git a/tools/Test_Helper/public/Import-RequiredModule.ps1 b/tools/Test_Helper/public/Import-RequiredModule.ps1 index 370fab9..0a50302 100644 --- a/tools/Test_Helper/public/Import-RequiredModule.ps1 +++ b/tools/Test_Helper/public/Import-RequiredModule.ps1 @@ -22,7 +22,7 @@ function Import-RequiredModule{ ) process{ - # Powershell module manifest does not allow versions with prerelease tags on them. + # Powershell module manifest does not allow versions with prerelease tags on them. # Powershell modle manifest does not allow to add a arbitrary field to specify prerelease versions. # Valid value (ModuleName, ModuleVersion, RequiredVersion, GUID) # There is no way to specify a prerelease required module. diff --git a/tools/Test_Helper/public/testResults.ps1 b/tools/Test_Helper/public/testResults.ps1 index 455338a..ef5c9e3 100644 --- a/tools/Test_Helper/public/testResults.ps1 +++ b/tools/Test_Helper/public/testResults.ps1 @@ -11,18 +11,18 @@ function Test-Result{ process{ # Chek results from last run $Result = $Result ?? $Global:ResultTestingHelper - + if($SkippedNotAllowed -and $Result.Skipped -gt 0){ return $false } - + if($NotImplementedNotAllowed -and $Result.NotImplemented -gt 0){ return $false } - + # Allow Not Implemented and Skipped tests to pass $passed = $Result.Tests -eq $Result.Pass + $Result.NotImplemented + $Result.Skipped - + return $passed } } Export-ModuleMember -Function Test-Result diff --git a/tools/deploy.Helper.ps1 b/tools/deploy.Helper.ps1 index 0d5aefd..3b27ab3 100644 --- a/tools/deploy.Helper.ps1 +++ b/tools/deploy.Helper.ps1 @@ -54,11 +54,11 @@ function Invoke-DeployModuleToPSGallery{ if ($Force -and -not $Confirm){ $ConfirmPreference = 'None' } - + # Deploy the module with ShouldProcess (-whatif, -confirm) if ($PSCmdlet.ShouldProcess($psdPath, "Invoke-DeployModule")) { "Deploying {0} {1} {2} to PSGallery ..." -f $($psd1.RootModule), $($psd1.ModuleVersion), $($psd1.PrivateData.pSData.Prerelease) | Write-Information - # During testing we should use -WhatIf paarmetre when calling for deploy. + # During testing we should use -WhatIf paarmetre when calling for deploy. # Just reach this point when testing call failure Invoke-DeployModule -Name $psdPath -NuGetApiKey $NuGetApiKey -Force:$ForceDeploy } @@ -79,8 +79,8 @@ function Update-DeployModuleManifest { # if ($PSCmdlet.ShouldProcess($parameters.Path, "Update-ModuleManifest with ModuleVersion:{0} Prerelease:{1}" -f $parameters.ModuleVersion, $parameters.Prerelease)) { if ($PSCmdlet.ShouldProcess($parameters.Path, "Update-ModuleManifest with $versionTag")) { "Updating module manifest with version tag [$VersionTag] ..." | Write-Information - Update-ModuleManifest @parameters - + Update-ModuleManifest @parameters + } else { Write-Warning -Message "Update-ModuleManifest skipped. Any PSD1 deploy will not have the proper version." } @@ -92,7 +92,7 @@ function Update-DeployModuleManifest { Write-Error -Message "Failed to update module manifest with version tag [$VersionTag]" exit 1 } -} +} function script:Invoke-DeployModule { [CmdletBinding()] @@ -117,7 +117,7 @@ function script:Invoke-DeployModule { Write-Error -Message "Failed to deploy module [$Name] to PSGallery" exit 1 } -} +} function Get-DeployModuleVersion { [CmdletBinding()] @@ -125,7 +125,7 @@ function Get-DeployModuleVersion { [Parameter(Mandatory=$true)][string]$VersionTag ) - $version = $VersionTag.split('-')[0] + $version = $VersionTag.split('-')[0] #remove all leters from $version $version = $version -replace '[a-zA-Z_]' $version @@ -138,11 +138,9 @@ function Get-DeployModulePreRelease { ) $preRelease = $VersionTag.split('-')[1] - # to clear the preRelease by Update-ModuleManifest - # preRelease must be a string with a space. + # to clear the preRelease by Update-ModuleManifest + # preRelease must be a string with a space. # $null or [string]::Empty leaves the value that has. $preRelease = $preRelease ?? " " $preRelease } - - diff --git a/tools/remove-trailing-whitespace.ps1 b/tools/remove-trailing-whitespace.ps1 index 83dbd85..b4ee8ec 100644 --- a/tools/remove-trailing-whitespace.ps1 +++ b/tools/remove-trailing-whitespace.ps1 @@ -1,7 +1,7 @@ # Script to remove trailing whitespace from PowerShell files # This addresses the PSAvoidTrailingWhitespace rule in PSScriptAnalyzer -Write-Host "Removing trailing whitespace from files..." -ForegroundColor Green +Write-Host "Removing trailing whitespace and trailing empty lines from files..." -ForegroundColor Green # Get all PowerShell files recursively $files = Get-ChildItem -Path . -Include *.ps1, *.psm1, *.psd1 -Recurse @@ -11,9 +11,12 @@ $count = 0 foreach ($file in $files) { $content = Get-Content -Path $file.FullName -Raw - # Replace trailing whitespace with nothing + # Replace trailing whitespace on each line $newContent = $content -replace '[ \t]+\r?\n', "`n" + # Remove trailing empty lines at the end of the file + $newContent = $newContent -replace '(\r?\n)+$', "`n" + # Check if content changed if ($newContent -ne $content) { Set-Content -Path $file.FullName -Value $newContent -NoNewline @@ -22,4 +25,4 @@ foreach ($file in $files) { } } -Write-Host "Done! Fixed trailing whitespace in $count files." -ForegroundColor Green +Write-Host "Done! Fixed trailing whitespace and empty lines in $count files." -ForegroundColor Green diff --git a/tools/sync.Helper.ps1 b/tools/sync.Helper.ps1 index e953ac1..deb1b6c 100644 --- a/tools/sync.Helper.ps1 +++ b/tools/sync.Helper.ps1 @@ -4,7 +4,7 @@ .DESCRIPTION Helper functions Synchronize TestingHelper templates to the local repo. - TestingHelper uses templates to create a new module. + TestingHelper uses templates to create a new module. This script will update the local module with the latest templates. .LINK https://raw.githubusercontent.com/rulasg/DemoPsModule/main/sync.ps1 @@ -59,4 +59,3 @@ function Save-UrlContentToFile { Set-Content -Path $filePath -Value $fileContent Write-Information -MessageData "Saved content to [$filePath] from [$url]" } -