mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
52 lines
1.5 KiB
PowerShell
52 lines
1.5 KiB
PowerShell
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
param(
|
|
[parameter(Mandatory = $true, ParameterSetName='Harvest')]
|
|
[switch]
|
|
$Harvest,
|
|
[parameter(Mandatory = $true, ParameterSetName='Test')]
|
|
[switch]
|
|
$Test,
|
|
[parameter(Mandatory = $true, ParameterSetName='TestAndHarvest')]
|
|
[switch]
|
|
$TestAndHarvest,
|
|
[switch]
|
|
$ForceModuleReload
|
|
)
|
|
|
|
$extraParams = @{}
|
|
if ($ForceModuleReload) {
|
|
$extraParams['Force'] = $true
|
|
}
|
|
|
|
Import-Module -Name "$PSScriptRoot/src/ClearlyDefined" @extraParams
|
|
|
|
$cgManfest = Get-Content "$PSScriptRoot/../cgmanifest/main/cgmanifest.json" | ConvertFrom-Json
|
|
$fullCgList = $cgManfest.Registrations.Component |
|
|
ForEach-Object {
|
|
[Pscustomobject]@{
|
|
type = $_.Type
|
|
Name = $_.Nuget.Name
|
|
PackageVersion = $_.Nuget.Version
|
|
}
|
|
}
|
|
|
|
$fullList = $fullCgList | Get-ClearlyDefinedData
|
|
|
|
$needHarvest = $fullList | Where-Object { !$_.harvested }
|
|
|
|
Write-Verbose "Full List count: $($fullList.Count)" -Verbose
|
|
Write-Verbose "Need harvest: $($needHarvest.Count)" -Verbose
|
|
|
|
if ($Harvest -or $TestAndHarvest) {
|
|
$needHarvest | select-object -ExpandProperty coordinates | Start-ClearlyDefinedHarvest
|
|
}
|
|
if ($Test -or $TestAndHarvest) {
|
|
if($needHarvest.Count -gt 0) {
|
|
$needHarvest | Format-List | Out-String -Width 9999 | Write-Verbose -Verbose
|
|
throw "There are $($needHarvest.Count) packages that need to be harvested"
|
|
} else {
|
|
Write-Verbose "All packages have been harvested" -Verbose
|
|
}
|
|
}
|