
Major Overhaul with Breaking Changes split into packaged, default behavior moved into 'base' package each package has a json package description file with criteria for loading Modified Setup-Profile to refer to 'base' package path for auto loading moved Linux aliases and command to 'base.linux' package created 'docker' package to address docker supported systems modified Get-MyScripts, Edit-MyScripts and Reload-MyScripts accordingly. Dropped -System and sys.*, package json conditions will take care of it. Supplied command to create/edit package json files: - New-MyPackage - Add-PackageCondition - Set-MyPackage
38 lines
1.2 KiB
PowerShell
38 lines
1.2 KiB
PowerShell
[CmdletBinding(SupportsShouldProcess)]param(
|
|
[Parameter(mandatory=$true, ValueFromPipeline=$true)]
|
|
[szPackage]$InputObject,
|
|
[switch]$Force,
|
|
[switch]$PassThru,
|
|
[switch]$DryRun
|
|
)
|
|
|
|
process {
|
|
$local:outObj = @{ package = @{ Name = $InputObject.Name; Condition = @() } }
|
|
foreach( $local:c in $InputObject.Condition ) {
|
|
$local:newC = [ordered]@{}
|
|
foreach( $local:p in $c.PSObject.Properties ) {
|
|
if( $p.TypeNameOfValue -match 'ScriptBlock' -and $p.Value ) {
|
|
$newC[$p.Name] = $p.Value.ToString().Trim()
|
|
} else {
|
|
$newC[$p.Name] = $p.Value
|
|
}
|
|
}
|
|
$outObj.package.Condition += $newC;
|
|
}
|
|
$local:jsonOut = $outObj | ConvertTo-Json -Depth 4
|
|
|
|
if( -not $DryRun ) {
|
|
$local:jsonPath = Join-Path $MyPSScriptRoot $_.name
|
|
if( -not (Test-Path $jsonPath) ) { $null = New-Item -Type Directory $jsonPath -Force:$Force }
|
|
$jsonPath = Join-Path $jsonPath '_.package.json'
|
|
if( $Force -or -not (Test-Path $jsonPath) ) {
|
|
$jsonOut | Out-File $jsonPath -Force:$Force
|
|
} elseif ( Test-Path $jsonPath ) {
|
|
throw 'Package already exists!'
|
|
}
|
|
}
|
|
|
|
if( $PassThru ) {
|
|
$jsonOut
|
|
}
|
|
}
|