Private/Invoke-CCWorkflowSync.ps1
|
function Invoke-CCWorkflowSync { <# .SYNOPSIS Shared implementation for Install/Update-CCReleaseWorkflow. Syncs (or, with -Adopt, enrols) workflow files via CodeCompass.Core and projects the outcomes as PSCustomObjects. Honours -WhatIf via the caller's $PSCmdlet.ShouldProcess. #> param( [Parameter(Mandatory)][string]$Path, [switch]$Force, [switch]$Adopt, [Parameter(Mandatory)][System.Management.Automation.PSCmdlet]$Cmdlet ) $full = (Resolve-Path -LiteralPath $Path).Path $service = [CodeCompass.Core.Workflows.WorkflowService]::new() if ($Adopt) { $dryRun = -not $Cmdlet.ShouldProcess($full, 'Enrol existing workflows as CodeCompass-adopted') $outcomes = $service.Adopt($full, 'CodeCompass.Release', $dryRun) } else { $dryRun = -not $Cmdlet.ShouldProcess($full, 'Sync CodeCompass workflow files') $outcomes = $service.Sync($full, 'CodeCompass.Release', [bool]$Force, $dryRun) } foreach ($outcome in $outcomes) { [pscustomobject]@{ Path = $outcome.RelativePath Action = $outcome.Action.ToString() Message = $outcome.Message } } } |