package defintion improvements
Added CmdletExists and AppExeExists conditions Cleanup of existing package description files
This commit is contained in:
parent
2b51f37cb7
commit
c9d13f5c4d
|
@ -2,11 +2,7 @@
|
||||||
"package": {
|
"package": {
|
||||||
"Condition": [
|
"Condition": [
|
||||||
{
|
{
|
||||||
"custom": "Get-Command 7z | Where-Object CommandType -eq 'Application'",
|
"AppExeExists": "7z"
|
||||||
"System": null,
|
|
||||||
"Hostname": null,
|
|
||||||
"Username": null,
|
|
||||||
"Logic": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Name": "7zip"
|
"Name": "7zip"
|
||||||
|
|
|
@ -2,11 +2,7 @@
|
||||||
"package": {
|
"package": {
|
||||||
"Condition": [
|
"Condition": [
|
||||||
{
|
{
|
||||||
"custom": "Get-Command ansible -Type Application",
|
"AppExeExists": "ansible"
|
||||||
"System": null,
|
|
||||||
"Hostname": null,
|
|
||||||
"Username": null,
|
|
||||||
"Logic": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Name": "ansible"
|
"Name": "ansible"
|
||||||
|
|
|
@ -3,13 +3,9 @@
|
||||||
"Name": "base.win",
|
"Name": "base.win",
|
||||||
"Condition": [
|
"Condition": [
|
||||||
{
|
{
|
||||||
"custom": null,
|
|
||||||
"System": [
|
"System": [
|
||||||
"Desktop"
|
"Desktop"
|
||||||
],
|
]
|
||||||
"Hostname": null,
|
|
||||||
"Username": null,
|
|
||||||
"Logic": 0
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
[ScriptBlock]$CustomCondition,
|
[ScriptBlock]$CustomCondition,
|
||||||
[string[]]$System = $null,
|
[string[]]$System = $null,
|
||||||
[string[]]$Hostname = $null,
|
[string[]]$Hostname = $null,
|
||||||
[string[]]$Username = $null
|
[string[]]$Username = $null,
|
||||||
|
[string[]]$CmdletExists = $null,
|
||||||
|
[string[]]$AppExeExists = $null
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
@ -13,7 +15,9 @@ process {
|
||||||
$newCond.custom = $CustomCondition
|
$newCond.custom = $CustomCondition
|
||||||
$newCond.System = $System
|
$newCond.System = $System
|
||||||
$newCond.Hostname = $Hostname
|
$newCond.Hostname = $Hostname
|
||||||
$newCond.Username = $null
|
$newCond.Username = $Username
|
||||||
|
$newCond.CmdletExists = $CmdletExists
|
||||||
|
$newCond.AppExeExists = $AppExeExists
|
||||||
$newCond.Logic = [szLogic]::and
|
$newCond.Logic = [szLogic]::and
|
||||||
$InputObject.Condition += $newCond
|
$InputObject.Condition += $newCond
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ class Packagesz { #: System.Management.Automation.IValidateSetValuesGenerator {
|
||||||
$local:valid = $Package.Condition[0].Logic -notin ([szLogic]::or, [szLogic]::ornot)
|
$local:valid = $Package.Condition[0].Logic -notin ([szLogic]::or, [szLogic]::ornot)
|
||||||
$local:currentSys = [SystemName]::_GetValidValues('',$true,$true);
|
$local:currentSys = [SystemName]::_GetValidValues('',$true,$true);
|
||||||
$local:hostname = $(hostname)
|
$local:hostname = $(hostname)
|
||||||
|
$local:allCmdlets = Get-Command | Select-Object -ExpandProperty Name
|
||||||
|
|
||||||
$local:username = $( if( $env:USER ) { $env:USER } else { $env:USERNAME } )
|
$local:username = $( if( $env:USER ) { $env:USER } else { $env:USERNAME } )
|
||||||
|
|
||||||
|
@ -39,6 +40,14 @@ class Packagesz { #: System.Management.Automation.IValidateSetValuesGenerator {
|
||||||
if( $v -and $c.Username ) {
|
if( $v -and $c.Username ) {
|
||||||
$v = $v -and $($c.Username | Where-Object { $username -match $_ })
|
$v = $v -and $($c.Username | Where-Object { $username -match $_ })
|
||||||
}
|
}
|
||||||
|
if( $v -and $c.CmdletExists ) {
|
||||||
|
$v = $v -and -not $($c.CmdletExists | Where-Object { $allCmdlets -notcontains $_ })
|
||||||
|
}
|
||||||
|
if( $v -and $c.AppExeExists ) {
|
||||||
|
$v = $v -and -not $($c.AppExeExists | Where-Object {
|
||||||
|
-not ( Get-Command $_ -Type Application -ErrorAction SilentlyContinue )
|
||||||
|
})
|
||||||
|
}
|
||||||
if( $v -and $c.custom ) {
|
if( $v -and $c.custom ) {
|
||||||
$v = $v -and ([bool]$(& ([ScriptBlock]::Create($c.custom))))
|
$v = $v -and ([bool]$(& ([ScriptBlock]::Create($c.custom))))
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,7 @@
|
||||||
"package": {
|
"package": {
|
||||||
"Condition": [
|
"Condition": [
|
||||||
{
|
{
|
||||||
"custom": "Get-Command docker -Type Application",
|
"AppExeExists": "docker"
|
||||||
"System": null,
|
|
||||||
"Hostname": null,
|
|
||||||
"Username": null,
|
|
||||||
"Logic": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Name": "docker"
|
"Name": "docker"
|
||||||
|
|
|
@ -2,11 +2,7 @@
|
||||||
"package": {
|
"package": {
|
||||||
"Condition": [
|
"Condition": [
|
||||||
{
|
{
|
||||||
"custom": "Get-Command git -Type Application",
|
"AppExeExists": "git"
|
||||||
"System": null,
|
|
||||||
"Hostname": null,
|
|
||||||
"Username": null,
|
|
||||||
"Logic": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Name": "git"
|
"Name": "git"
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue