microsoft/hve-core
Publicmirrored from https://github.com/microsoft/hve-coreAvailable
.github/skills/installer/hve-core-installer/scripts/eject.ps1
34lines · modecode
| 1 | # Copyright (c) Microsoft Corporation. |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | <# |
| 4 | .SYNOPSIS |
| 5 | Ejects a tracked file from HVE-Core upgrade management. |
| 6 | .DESCRIPTION |
| 7 | Marks a file as 'ejected' in .hve-tracking.json so future upgrades |
| 8 | skip it. The file remains on disk but is owned by the user. |
| 9 | .PARAMETER FilePath |
| 10 | The relative path to the file to eject (e.g., .github/agents/task-implementor.agent.md). |
| 11 | .EXAMPLE |
| 12 | ./scripts/eject.ps1 -FilePath '.github/agents/task-implementor.agent.md' |
| 13 | #> |
| 14 | [CmdletBinding()] |
| 15 | param( |
| 16 | [Parameter(Mandatory)] |
| 17 | [ValidateNotNullOrEmpty()] |
| 18 | [string]$FilePath |
| 19 | ) |
| 20 | |
| 21 | $ErrorActionPreference = 'Stop' |
| 22 | |
| 23 | $manifest = Get-Content ".hve-tracking.json" | ConvertFrom-Json -AsHashtable |
| 24 | |
| 25 | if ($manifest.files.ContainsKey($FilePath)) { |
| 26 | $manifest.files[$FilePath].status = "ejected" |
| 27 | $manifest.files[$FilePath].ejectedAt = (Get-Date -Format "o") |
| 28 | |
| 29 | $manifest | ConvertTo-Json -Depth 10 | Set-Content ".hve-tracking.json" |
| 30 | Write-Host "✅ Ejected: $FilePath" |
| 31 | Write-Host " This file will never be updated by HVE-Core." |
| 32 | } else { |
| 33 | Write-Host "❌ File not found in tracking manifest: $FilePath" |
| 34 | } |