Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
ClearlyDefined.ps152 linesDownload Raw Back to clearlyDefined
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3param(4    [parameter(Mandatory = $true, ParameterSetName='Harvest')]5    [switch]6    $Harvest,7    [parameter(Mandatory = $true, ParameterSetName='Test')]8    [switch]9    $Test,10    [parameter(Mandatory = $true, ParameterSetName='TestAndHarvest')]11    [switch]12    $TestAndHarvest,13    [switch]14    $ForceModuleReload15)16 17$extraParams = @{}18if ($ForceModuleReload) {19    $extraParams['Force'] = $true20}21 22Import-Module -Name "$PSScriptRoot/src/ClearlyDefined" @extraParams23 24$cgManfest = Get-Content "$PSScriptRoot/../cgmanifest/main/cgmanifest.json" | ConvertFrom-Json25$fullCgList = $cgManfest.Registrations.Component |26    ForEach-Object {27        [Pscustomobject]@{28            type = $_.Type29            Name = $_.Nuget.Name30            PackageVersion = $_.Nuget.Version31        }32    }33 34$fullList = $fullCgList | Get-ClearlyDefinedData35 36$needHarvest = $fullList | Where-Object { !$_.harvested }37 38Write-Verbose "Full List count: $($fullList.Count)" -Verbose39Write-Verbose "Need harvest: $($needHarvest.Count)" -Verbose40 41if ($Harvest -or $TestAndHarvest) {42    $needHarvest | select-object -ExpandProperty coordinates | Start-ClearlyDefinedHarvest43}44if ($Test -or $TestAndHarvest) {45    if($needHarvest.Count -gt 0) {46        $needHarvest | Format-List | Out-String -Width 9999 | Write-Verbose -Verbose47        throw "There are $($needHarvest.Count) packages that need to be harvested"48    } else {49        Write-Verbose "All packages have been harvested" -Verbose50    }51}52