Downloads:
2,788
Downloads of v 0.0.88:
1,102
Last Update:
04 Apr 2015
Package Maintainer(s):
Software Author(s):
- Chris Dostert
Tags:
powershell appease taskrunner ci continuousintegration build deployment admin- Software Specific:
- Software Site
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
appease.client.powershell
- 1
- 2
- 3
0.0.88 | Updated: 04 Apr 2015
- Software Specific:
- Software Site
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
2,788
Downloads of v 0.0.88:
1,102
Maintainer(s):
Software Author(s):
- Chris Dostert
appease.client.powershell 0.0.88
Legal Disclaimer: Neither this package nor Chocolatey Software, Inc. are affiliated with or endorsed by Chris Dostert. The inclusion of Chris Dostert trademark(s), if any, upon this webpage is solely to identify Chris Dostert goods or services and not for commercial purposes.
- 1
- 2
- 3
Some Checks Have Failed or Are Not Yet Complete
Not All Tests Have Passed
Validation Testing Unknown
Verification Testing Unknown
Scan Testing Resulted in Investigate
Deployment Method: Individual Install, Upgrade, & Uninstall
To install appease.client.powershell, run the following command from the command line or from PowerShell:
To upgrade appease.client.powershell, run the following command from the command line or from PowerShell:
To uninstall appease.client.powershell, run the following command from the command line or from PowerShell:
Deployment Method:
This applies to both open source and commercial editions of Chocolatey.
1. Enter Your Internal Repository Url
(this should look similar to https://community.chocolatey.org/api/v2/)
2. Setup Your Environment
1. Ensure you are set for organizational deployment
Please see the organizational deployment guide
2. Get the package into your environment
Option 1: Cached Package (Unreliable, Requires Internet - Same As Community)-
Open Source or Commercial:
- Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
- You can also just download the package and push it to a repository Download
-
Open Source
-
Download the package:
Download - Follow manual internalization instructions
-
-
Package Internalizer (C4B)
-
Run: (additional options)
choco download appease.client.powershell --internalize --source=https://community.chocolatey.org/api/v2/
-
For package and dependencies run:
choco push --source="'INTERNAL REPO URL'"
- Automate package internalization
-
Run: (additional options)
3. Copy Your Script
choco upgrade appease.client.powershell -y --source="'INTERNAL REPO URL'" [other options]
See options you can pass to upgrade.
See best practices for scripting.
Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.
If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:
choco upgrade appease.client.powershell -y --source="'INTERNAL REPO URL'"
$exitCode = $LASTEXITCODE
Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
- name: Install appease.client.powershell
win_chocolatey:
name: appease.client.powershell
version: '0.0.88'
source: INTERNAL REPO URL
state: present
See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.
chocolatey_package 'appease.client.powershell' do
action :install
source 'INTERNAL REPO URL'
version '0.0.88'
end
See docs at https://docs.chef.io/resource_chocolatey_package.html.
cChocoPackageInstaller appease.client.powershell
{
Name = "appease.client.powershell"
Version = "0.0.88"
Source = "INTERNAL REPO URL"
}
Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.
package { 'appease.client.powershell':
ensure => '0.0.88',
provider => 'chocolatey',
source => 'INTERNAL REPO URL',
}
Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.
4. If applicable - Chocolatey configuration/installation
See infrastructure management matrix for Chocolatey configuration elements and examples.
This package was approved by moderator ferventcoder on 24 Apr 2015.
The Appease client for Windows PowerShell
Installation notes:
- installs to: C:\ProgramFiles\Appease\PowerShell\Appease.Client
- appends C:\ProgramFiles\Appease\PowerShell to PSModulePath environment variable
Import-Module "$PSScriptRoot\TemplateManagement"
Import-Module "$PSScriptRoot\DevOpStorage"
Import-Module "$PSScriptRoot\HashtableExtensions"
function Invoke-AppeaseDevOp(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$Name,
[Hashtable]
[Parameter(
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
$Parameters,
[string[]]
[ValidateCount( 1, [Int]::MaxValue)]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$TemplateSource = $DefaultTemplateSources,
[String]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath='.'){
$DevOp = DevOpStorage\Get-AppeaseDevOp -Name $Name -ProjectRootDirPath $ProjectRootDirPath
foreach($Task in $DevOp.Tasks){
if($Parameters.($Task.Name)){
if($Task.Parameters){
Write-Debug "Adding union of passed parameters and archived parameters to pipeline. Passed parameters will override archived parameters"
$TaskParameters = HashtableExtensions\Get-UnionOfHashtables -Source1 $Parameters.($Task.Name) -Source2 $Task.Parameters
}
else{
Write-Debug "Adding passed parameters to pipeline"
$TaskParameters = $Parameters.($Task.Name)
}
}
elseif($Task.Parameters){
Write-Debug "Adding archived parameters to pipeline"
$TaskParameters = $Task.Parameters
}
else{
$TaskParameters = @{}
}
Write-Debug "Adding automatic parameters to pipeline"
$TaskParameters.AppeaseProjectRootDirPath = (Resolve-Path $ProjectRootDirPath)
$TaskParameters.AppeaseTaskName = $Task.Name
Write-Debug "Ensuring task template installed"
TemplateManagement\Install-AppeaseTaskTemplate -Id $Task.TemplateId -Version $Task.TemplateVersion -Source $TemplateSource
$TaskTemplateInstallDirPath = TemplateManagement\Get-AppeaseTaskTemplateInstallDirPath -Id $Task.TemplateId -Version $Task.TemplateVersion -ProjectRootDirPath $ProjectRootDirPath
$ModuleDirPath = "$TaskTemplateInstallDirPath\bin\$($Task.TemplateId)"
Write-Debug "Importing module located at: $ModuleDirPath"
Import-Module $ModuleDirPath -Force
Write-Debug `
@"
Invoking Task $($Task.Name) with parameters:
$($TaskParameters|Out-String)
"@
# Parameters must be PSCustomObject so [Parameter(ValueFromPipelineByPropertyName = $true)] works
[PSCustomObject]$TaskParameters.Clone() | & "$($Task.TemplateId)\Invoke"
Remove-Module $Task.TemplateId
}
}
function New-AppeaseDevOp(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Name,
[switch]
$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
$DevOp = @{Name=$Name;Tasks={@()}.Invoke()}
DevOpStorage\Add-AppeaseDevOp `
-Value $DevOp `
-Force:$Force `
-ProjectRootDirPath $ProjectRootDirPath
}
function Remove-AppeaseDevOp(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$Name,
[switch]$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
$ConfirmationPromptQuery = "Are you sure you want to delete the DevOp `"$Name`"`?"
$ConfirmationPromptCaption = 'Confirm Task removal'
if($Force.IsPresent -or $PSCmdlet.ShouldContinue($ConfirmationPromptQuery,$ConfirmationPromptCaption)){
DevOpStorage\Remove-AppeaseDevOp `
-Name $Name `
-ProjectRootDirPath $ProjectRootDirPath
}
}
function Rename-AppeaseDevOp(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$OldName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$NewName,
[switch]
$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
DevOpStorage\Rename-AppeaseDevOp `
-OldName $OldName `
-NewName $NewName `
-Force:$Force `
-ProjectRootDirPath $ProjectRootDirPath
}
function Get-AppeaseDevOp(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$Name,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
DevOpStorage\Get-AppeaseDevOp -Name $Name -ProjectRootDirPath $ProjectRootDirPath | Write-Output
}
function Add-AppeaseTask(
[CmdletBinding(
DefaultParameterSetName="Add-AppeaseTaskLast")]
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$DevOpName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$Name,
[string]
[Parameter(
Mandatory=$true)]
$TemplateId,
[string]
$TemplateVersion,
[switch]
[Parameter(
Mandatory=$true,
ParameterSetName='Add-AppeaseTaskFirst')]
$First,
[switch]
[Parameter(
ParameterSetName='Add-AppeaseTaskLast')]
$Last,
[string]
[Parameter(
Mandatory=$true,
ParameterSetName='Add-AppeaseTaskAfter')]
$After,
[string]
[Parameter(
Mandatory=$true,
ParameterSetName='Add-AppeaseTaskBefore')]
$Before,
[switch]
$Force,
[string[]]
[ValidateNotNullOrEmpty()]
$TemplateSource= $DefaultTemplateSources,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
<#
.SYNOPSIS
Adds a new Task to a DevOp
.EXAMPLE
Add-AppeaseTask -DevOpName "Deploy To Azure" -Name "LastTask" -TemplateId "DeployNupkgToAzureWebsites" -TemplateVersion "0.0.3"
Description:
This command adds Task "LastTask" after all existing Tasks in DevOp "Deploy To Azure"
.EXAMPLE
Add-AppeaseTask -DevOpName "Deploy To Azure" -Name "FirstTask" -TemplateId "DeployNupkgToAzureWebsites" -First
Description:
This command adds Task "FirstTask" before all existing Tasks in DevOp "Deploy To Azure"
.EXAMPLE
Add-AppeaseTask -DevOpName "Deploy To Azure" -Name "AfterSecondTask" -TemplateId "DeployNupkgToAzureWebsites" -After "SecondTask"
Description:
This command adds Task "AfterSecondTask" after the existing Task "SecondTask" in DevOp "Deploy To Azure"
.EXAMPLE
Add-AppeaseTask -DevOpName "Deploy To Azure" -Name "BeforeSecondTask" -TemplateId "DeployNupkgToAzureWebsites" -Before "SecondTask"
Description:
This command adds Task "BeforeSecondTask" before the existing Task "SecondTask" in DevOp "Deploy To Azure"
#>
if([string]::IsNullOrWhiteSpace($TemplateVersion)){
$TemplateVersion = TemplateManagement\Get-AppeaseTaskTemplateLatestVersion -Source $TemplateSource -Id $TemplateId
Write-Debug "using greatest available template version : $TemplateVersion"
}
if($First.IsPresent){
$TaskIndex = 0
}
elseif('Add-AppeaseTaskAfter' -eq $PSCmdlet.ParameterSetName){
$DevOp = DevOpStorage\Get-AppeaseDevOp -Name $DevOpName -ProjectRootDirPath $ProjectRootDirPath
$indexOfAfter = $DevOp.Tasks.IndexOf(($DevOp.Tasks|?{$_.Name -eq $After}|Select -First 1))
# ensure Task with key $After exists
if($indexOfAfter -lt 0){
throw "A task with name $After could not be found."
}
$TaskIndex = $indexOfAfter + 1
}
elseif('Add-AppeaseTaskBefore' -eq $PSCmdlet.ParameterSetName){
$DevOp = DevOpStorage\Get-AppeaseDevOp -Name $DevOpName -ProjectRootDirPath $ProjectRootDirPath
$indexOfBefore = $DevOp.Tasks.IndexOf(($DevOp.Tasks|?{$_.Name -eq $Before}|Select -First 1))
# ensure Task with key $Before exists
if($indexOfBefore -lt 0){
throw "A Task with name $Before could not be found."
}
$TaskIndex = $indexOfBefore
}
else{
$DevOp = DevOpStorage\Get-AppeaseDevOp -Name $DevOpName -ProjectRootDirPath $ProjectRootDirPath
$TaskIndex = $DevOp.Tasks.Count
}
DevOpStorage\Add-AppeaseTask `
-DevOpName $DevOpName `
-Name $Name `
-TemplateId $TemplateId `
-TemplateVersion $TemplateVersion `
-Index $TaskIndex `
-Force:$Force `
-ProjectRootDirPath $ProjectRootDirPath
}
function Remove-AppeaseTask(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$DevOpName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$Name,
[switch]$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
$ConfirmationPromptQuery = "Are you sure you want to remove the Task with name $Name`?"
$ConfirmationPromptCaption = 'Confirm Task removal'
if($Force.IsPresent -or $PSCmdlet.ShouldContinue($ConfirmationPromptQuery,$ConfirmationPromptCaption)){
DevOpStorage\Remove-AppeaseTask `
-DevOpName $DevOpName `
-Name $Name `
-ProjectRootDirPath $ProjectRootDirPath
}
}
function Rename-AppeaseTask(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$DevOpName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$OldName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$NewName,
[switch]$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
DevOpStorage\Rename-AppeaseTask `
-DevOpName $DevOpName `
-OldName $OldName `
-NewName $NewName `
-Force:$Force `
-ProjectRootDirPath $ProjectRootDirPath
}
function Set-AppeaseTaskParameter(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$DevOpName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$TaskName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$Name,
[object]
[Parameter(
Mandatory=$true)]
$Value,
[switch]
$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
<#
.SYNOPSIS
Sets configurable parameters of a Task
.EXAMPLE
Set-AppeaseTaskParameter -DevOpName Build -TaskName GitClone -Name GitParameters -Value Status -Force
Description:
This command sets the parameter "GitParameters" to "Status" for a Task "GitClone" in DevOp "Build"
#>
DevOpStorage\Set-AppeaseTaskParameter `
-DevOpName $DevOpName `
-TaskName $TaskName `
-Name $Name `
-Value $Value `
-Force:$Force
}
function Update-AppeaseTaskTemplate(
[CmdletBinding(
DefaultParameterSetName="Update-All")]
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$DevOpName,
[string[]]
[ValidateCount( 1, [Int]::MaxValue)]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
ParameterSetName="Update-Single")]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
ParameterSetName="Update-Multiple")]
$Id,
[string]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
ParameterSetName="Update-Single")]
$Version,
[switch]
[Parameter(
ParameterSetName="Update-All")]
$All,
[string[]]
[ValidateCount( 1, [Int]::MaxValue)]
[ValidateNotNullOrEmpty()]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$Source = $DefaultTemplateSources,
[String]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath='.'){
$DevOp = DevOpStorage\Get-AppeaseDevOp -Name $DevOpName -ProjectRootDirPath $ProjectRootDirPath
# build up list of template updates
$templateUpdates = @{}
If('Update-Multiple' -eq $PSCmdlet.ParameterSetName){
foreach($templateId in $Id){
$templateUpdates.Add($templateId,(TemplateManagement\Get-AppeaseTaskTemplateLatestVersion -Source $Source -Id $templateId))
}
}
ElseIf('Update-Single' -eq $PSCmdlet.ParameterSetName){
if($Id.Length -ne 1){
throw "Updating to an explicit template version is only allowed when updating a single template"
}
$templateUpdates.Add($Id,$Version)
}
Else{
foreach($Task in $DevOp.Tasks){
$templateUpdates.Add($Task.TemplateId,(TemplateManagement\Get-AppeaseTaskTemplateLatestVersion -Source $Source -Id $Task.TemplateId))
}
}
foreach($Task in $DevOp.Tasks){
$updatedTemplateVersion = $templateUpdates.($Task.TemplateId)
if($null -ne $updatedTemplateVersion){
TemplateManagement\Uninstall-AppeaseTaskTemplate -Id $Task.TemplateId -Version $Task.TemplateVersion -ProjectRootDirPath $ProjectRootDirPath
Write-Debug `
@"
Updating task template '$($Task.TemplateId)'
from version '$($Task.TemplateVersion)'
to version '$($updatedTemplateVersion)'
for task '$($Task.Name)'
"@
DevOpStorage\Set-AppeaseTaskTemplateVersion `
-DevOpName $DevOpName `
-TaskName $Task.Name `
-TemplateVersion $updatedTemplateVersion `
-ProjectRootDirPath $ProjectRootDirPath
}
}
}
Export-ModuleMember -Function @(
# DevOp API
'Invoke-AppeaseDevOp',
'New-AppeaseDevOp',
'Remove-AppeaseDevOp',
'Rename-AppeaseDevOp',
'Get-AppeaseDevOp',
# Task API
'Add-AppeaseTask',
'Remove-AppeaseTask',
'Rename-AppeaseTask',
'Set-AppeaseTaskParameter',
# Task Template API
'Update-AppeaseTaskTemplate',
'Publish-AppeaseTaskTemplate')
function Save-AppeaseDevOpToFile(
[object]
$Value,
[switch]
$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
$DevOpFilePath = "$ProjectRootDirPath\.Appease\$($Value.Name).json"
if(!$Force.IsPresent -and (Test-Path $DevOpFilePath)){
throw `
@"
dev op "$($Value.Name)" already exists
for project "$(Resolve-Path $ProjectRootDirPath)".
dev op names must be unique.
If you want to overwrite the existing dev op use the -Force parameter
"@
}
if(!(Test-Path -Path $DevOpFilePath)){
New-Item -ItemType File -Path $DevOpFilePath -Force
}
Set-Content $DevOpFilePath -Value (ConvertTo-Json -InputObject $Value -Depth 12) -Force
}
Set-Alias -Name 'Add-AppeaseDevOp' -Value 'Save-AppeaseDevOpToFile'
function Get-AppeaseDevOpFromFile(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Name,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
<#
.SYNOPSIS
an internal utility function that retrieves a DevOp from storage
#>
$DevOpFilePath = Resolve-Path "$ProjectRootDirPath\.Appease\$Name.json"
$DevOp = Get-Content $DevOpFilePath | Out-String | ConvertFrom-Json
# convert tasks from Array to Collection
$DevOp.Tasks = {$DevOp.Tasks}.Invoke()
# convert task parameters from PSCustomObject to Hashtable
# see : http://stackoverflow.com/questions/22002748/hashtables-from-convertfrom-json-have-different-type-from-powershells-built-in-h
for($i = 0; $i -lt $DevOp.Tasks.Count; $i++)
{
if($DevOp.Tasks[$i].Parameters){
$ParametersHashtable = @{}
$DevOp.Tasks[$i].Parameters.PSObject.Properties | %{$ParametersHashtable[$_.Name] = $_.Value}
$DevOp.Tasks[$i].Parameters = $ParametersHashtable
}
}
Write-Output $DevOp
}
Set-Alias -Name 'Get-AppeaseDevOp' -Value 'Get-AppeaseDevOpFromFile'
function Rename-AppeaseDevOp(
[string]
[ValidateNotNullOrEmpty()]
$OldName,
[string]
[ValidateNotNullOrEmpty()]
$NewName,
[switch]
$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
<#
.SYNOPSIS
an internal utility function that updates the name of a DevOp in storage
#>
# fetch DevOp
$DevOp = Get-AppeaseDevOpFromFile -Name $OldName -ProjectRootDirPath $ProjectRootDirPath
# update name
$DevOp.Name = $NewName
# save to file with updated name
Save-AppeaseDevOpToFile -Value $DevOp -Force:$Force -ProjectRootDirPath $ProjectRootDirPath
#remove file with old name
Remove-Item -Path "$ProjectRootDirPath\.Appease\$OldName.json" -Force
}
function Remove-AppeaseDevOp(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Name,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
<#
.SYNOPSIS
an internal utility function that removes a DevOp from storage
#>
$DevOpFilePath = Resolve-Path "$ProjectRootDirPath\.Appease\$Name.json"
Remove-Item -Path $DevOpFilePath -Force
}
function Add-AppeaseTask(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$DevOpName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Name,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$TemplateId,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$TemplateVersion,
[int]
[ValidateScript({$_ -gt -1})]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Index,
[switch]
$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
<#
.SYNOPSIS
an internal utility function that adds a task to a DevOp in storage
#>
# fetch DevOp
$DevOp = Get-AppeaseDevOpFromFile -Name $DevOpName -ProjectRootDirPath $ProjectRootDirPath
# guard against unintentionally overwriting existing tasks
if(!$Force.IsPresent -and ($DevOp.Tasks|?{$_.Name -eq $Name}|Select -First 1)){
throw `
@"
Task '$Name' already exists in DevOp '$DevOpName'
for project '$(Resolve-Path $ProjectRootDirPath)'.
Task names must be unique.
If you want to overwrite the existing task use the -Force parameter
"@
}
# construct task object
$Task = @{Name=$Name;TemplateId=$TemplateId;TemplateVersion=$TemplateVersion}
# add task to dev op
$DevOp.Tasks.Insert($Index,$Task)
# save
Save-AppeaseDevOpToFile -Value $DevOp -Force -ProjectRootDirPath $ProjectRootDirPath
}
function Remove-AppeaseTask(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$DevOpName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Name,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
# fetch DevOp
$DevOp = Get-AppeaseDevOpFromFile -Name $DevOpName -ProjectRootDirPath $ProjectRootDirPath
# remove task
$DevOp.Tasks.Remove(($DevOp.Tasks|?{$_.Name -eq $Name}|Select -First 1))
# save
Save-AppeaseDevOpToFile -Value $DevOp -Force -ProjectRootDirPath $ProjectRootDirPath
}
function Rename-AppeaseTask(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$DevOpName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$OldName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$NewName,
[switch]
$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
# fetch DevOp
$DevOp = Get-AppeaseDevOpFromFile -Name $DevOpName -ProjectRootDirPath $ProjectRootDirPath
# fetch task
$Task = $DevOp.Tasks|?{$_.Name -eq $OldName}|Select -First 1
# handle task not found
if(!$Task){
throw `
@"
Task '$TaskName' not found in dev op '$DevOpName'
for project '$(Resolve-Path $ProjectRootDirPath)'.
"@
}
# guard against unintentionally overwriting existing task
if(!$Force.IsPresent -and ($DevOp.Tasks|?{$_.Name -eq $NewName}|Select -First 1)){
throw `
@"
Task '$NewName' already exists in dev op '$DevOpName'
for project '$(Resolve-Path $ProjectRootDirPath)'.
Task names must be unique.
If you want to overwrite the existing task use the -Force parameter
"@
}
# update name
$Task.Name = $NewName
# save
Save-AppeaseDevOpToFile -Value $DevOp -Force -ProjectRootDirPath $ProjectRootDirPath
}
function Set-AppeaseTaskParameter(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$DevOpName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$TaskName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$Name,
[object]
[Parameter(
Mandatory=$true)]
$Value,
[switch]
$Force,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
# fetch DevOp
$DevOp = Get-AppeaseDevOpFromFile -Name $DevOpName -ProjectRootDirPath $ProjectRootDirPath
# fetch task
$Task = $DevOp.Tasks|?{$_.Name -eq $TaskName}|Select -First 1
# handle task not found
if(!$Task){
throw `
@"
Task '$TaskName' not found in DevOp '$DevOpName'
for project '$(Resolve-Path $ProjectRootDirPath)'.
"@
}
# handle the case where this is the first parameter set
If(!$Task.Parameters){
$Task | Add-Member -Type NoteProperty -Name Parameters -Value @{$Name=$Value}
}
# guard against unintentionally overwriting existing parameter value
ElseIf(!$Force.IsPresent -and ($Task.Parameters.$Name)){
throw `
@"
A value of '$($Task.Parameters.$Name)' has already been set for parameter '$Name' of task '$TaskName' in DevOp '$DevOpName'
for project '$(Resolve-Path $ProjectRootDirPath)'.
If you want to overwrite the existing parameter value use the -Force parameter
"@
}
Else{
$Task.Parameters.$Name = $Value
}
# save
Save-AppeaseDevOpToFile -Value $DevOp -Force -ProjectRootDirPath $ProjectRootDirPath
}
function Set-AppeaseTaskTemplateVersion(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$DevOpName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$TaskName,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$TemplateVersion,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
# get from file
$DevOp = Get-AppeaseDevOpFromFile -Name $DevOpName -ProjectRootDirPath $ProjectRootDirPath
# fetch task
$Task = $DevOp.Tasks|?{$_.Name -eq $TaskName}|Select -First 1
# handle task not found
if(!$Task){
throw `
@"
Task '$TaskName' not found in DevOp '$DevOpName'
for project '$(Resolve-Path $ProjectRootDirPath)'.
"@
}
# update task version
$Task.TemplateVersion = $TemplateVersion
# save to file
Save-AppeaseDevOpToFile -Value $DevOp -Force -ProjectRootDirPath $ProjectRootDirPath
}
Export-ModuleMember -Alias @(
'Add-AppeaseDevOp',
'Get-AppeaseDevOp')
Export-ModuleMember -Function @(
# DevOp API
'Save-AppeaseDevOpToFile',
'Get-AppeaseDevOpFromFile',
'Add-AppeaseDevOp',
'Rename-AppeaseDevOp',
'Remove-AppeaseDevOp',
# Task API
'Add-AppeaseTask',
'Remove-AppeaseTask',
'Rename-AppeaseTask',
'Set-AppeaseTaskParameter',
'Set-AppeaseTaskTemplateVersion')
function Get-UnionOfHashtables(
[Hashtable]
[ValidateNotNull()]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$Source1,
[Hashtable]
[ValidateNotNull()]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$Source2){
$destination = $Source1.Clone()
Write-Debug "After adding `$Source1, destination is $($destination|Out-String)"
$Source2.GetEnumerator() | ?{!$destination.ContainsKey($_.Key)} |%{$destination[$_.Key] = $_.Value}
Write-Debug "After adding `$Source2, destination is $($destination|Out-String)"
Write-Output $destination
}
Export-ModuleMember -Function Get-UnionOfHashtables
# installer based on guidelines provided by Microsoft
# for installing shared/3rd party powershell modules
# (see: https://msdn.microsoft.com/en-us/library/dd878350%28v=vs.85%29.aspx )
$ModuleName = (gi $PSScriptRoot).Name
if($PSVersionTable.PSVersion.Major -lt 3) {
Write-Warning "$ModuleName requires PowerShell 3.0 or better; you have version $($Host.Version)."
return
}
# prepare install dir
$RootInstallationDirPath = "$env:ProgramFiles\Appease"
$RootPowerShellModuleInstallationDirPath = "$RootInstallationDirPath\PowerShell"
$ModuleInstallationDirPath = "$RootPowerShellModuleInstallationDirPath\$ModuleName"
# handle upgrade scenario
if(Test-Path $ModuleInstallationDirPath){
Write-Debug "removing previous $ModuleName installation"
. "$PSScriptRoot\Uninstall.ps1"
}
if(!(Test-Path $RootPowerShellModuleInstallationDirPath)){
New-Item $RootPowerShellModuleInstallationDirPath -ItemType Directory -Force | Out-Null
}
Copy-Item -Path $PSScriptRoot -Destination $RootPowerShellModuleInstallationDirPath -Recurse
$PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath','Machine')
# if $RootPowerShellModuleInstallationDirPath is not already in path then add it.
if(!($PSModulePath.Split(';').Contains($RootPowerShellModuleInstallationDirPath))){
Write-Debug "adding $RootPowerShellModuleInstallationDirPath to '$env:PSModulePath'"
# trim trailing semicolon if exists
$PSModulePath = $PSModulePath.TrimEnd(';');
# append path to Appease installation
$PSModulePath += ";$RootPowerShellModuleInstallationDirPath"
# save
[Environment]::SetEnvironmentVariable('PSModulePath',$PSModulePath,'Machine')
# make effective in current session
$env:PSModulePath = $env:PSModulePath + ";$RootPowerShellModuleInstallationDirPath"
}
Import-Module "$PSScriptRoot\Versioning"
$DefaultTemplateSources = @('https://www.myget.org/F/appease')
$NuGetCommand = "nuget"
$ChocolateyCommand = "chocolatey"
function Get-AppeaseTaskTemplateLatestVersion(
[string[]]
[Parameter(
Mandatory=$true)]
$Source = $DefaultTemplateSources,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$Id){
$versions = @()
foreach($templateSource in $Source){
$uri = "$templateSource/api/v2/package-versions/$Id"
Write-Debug "Attempting to fetch template versions:` uri: $uri "
$versions = $versions + (Invoke-RestMethod -Uri $uri)
Write-Debug "response from $uri was: ` $versions"
}
if(!$versions -or ($versions.Count -lt 1)){
throw "no versions of $Id could be located.` searched: $Source"
}
Write-Output ([Array](Get-SortedSemanticVersions -InputArray $versions -Descending))[0]
}
function New-NuGetPackage(
[string]
$NuspecFilePath){
$NugetParameters = @('pack',$NuspecFilePath)
Write-Debug `
@"
Invoking nuget:
& $NuGetCommand $($NugetParameters|Out-String)
"@
& $NuGetCommand $NuGetParameters
# handle errors
if ($LastExitCode -ne 0) {
throw $Error
}
}
function Publish-NuGetPackage(
[string]
$NupkgFilePath,
[string]
[string]
$SourcePathOrUrl,
$ApiKey){
$NuGetParameters = @('push',$NupkgFilePath,'-Source',$SourcePathOrUrl)
if($ApiKey){
$NuGetParameters = $NuGetParameters + @('-ApiKey',$ApiKey)
}
Write-Debug `
@"
Invoking nuget:
$NuGetCommand $($NuGetParameters|Out-String)
"@
& $NuGetCommand $NuGetParameters
# handle errors
if ($LastExitCode -ne 0) {
throw $Error
}
}
function Publish-AppeaseTaskTemplate(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName = $true)]
$Id,
[string]
[Parameter(
ValueFromPipelineByPropertyName = $true)]
$Description,
[string]
[ValidateScript({
if($_ | Test-SemanticVersion){
$true
}
else{
throw "'$_' is not a valid Semantic Version"
}
})]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName = $true)]
$Version,
[PSCustomObject[]]
[Parameter(
ValueFromPipelineByPropertyName = $true)]
$Contributor,
[PSCustomObject[]]
[ValidateCount(1,[int]::MaxValue)]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName = $true
)]
$File,
[PSCustomObject]
[Parameter(
ValueFromPipelineByPropertyName = $true)]
$Dependencies,
[System.Uri]
[Parameter(
ValueFromPipelineByPropertyName = $true)]
$IconUrl,
[System.Uri]
[Parameter(
ValueFromPipelineByPropertyName = $true)]
$ProjectUrl,
[string[]]
[Parameter(
ValueFromPipelineByPropertyName = $true)]
$Tags,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
ValueFromPipelineByPropertyName = $true)]
$DestinationPathOrUrl = $DefaultTemplateSources[0],
[string]
[Parameter(
ValueFromPipelineByPropertyName = $true)]
$ApiKey,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
$TaskTemplateMetadataFileName = "$([Guid]::NewGuid()).json"
# generate nuspec xml
$nuspecXmlString =
@"
<?xml version="1.0"?>
<package>
<metadata>
<id>$Id</id>
<version>$Version</version>
<authors>$([string]::Join(',',($Contributor|%{$_.Name})))</authors>
<projectUrl>$ProjectUrl</projectUrl>
<iconUrl>$([string]$IconUrl)</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$Description</description>
<tags>$(if($Tags){[string]::Join(" ",$Tags)})</tags>
</metadata>
<files>
<file src="$TaskTemplateMetadataFileName" target="metadata.json"/>
$([string]::Join([System.Environment]::NewLine,($File|%{"<file src=`"$([string]::Join(';',($_.Include)))`" target=`"bin\$($_.Destination)`" exclude=`"$([string]::Join(';',($TaskTemplateMetadataFileName + $_.Exclude)))`" />"})))
</files>
</package>
"@
$NuspecXml = [xml]($nuspecXmlString)
Try
{
# generate a nuspec file
$NuspecFilePath = Join-Path -Path $ProjectRootDirPath -ChildPath "$([Guid]::NewGuid()).nuspec"
New-Item -ItemType File -Path $NuspecFilePath -Force
$NuspecXml.Save($(Resolve-Path $NuspecFilePath))
# generate a metadata file
$TaskTemplateMetadataFilePath = Join-Path -Path $ProjectRootDirPath -ChildPath $TaskTemplateMetadataFileName
New-Item -ItemType File -Path $TaskTemplateMetadataFilePath -Force
$TaskTemplateMetadata = @{}
if($Dependencies){
$TaskTemplateMetadata.Dependencies = $Dependencies
}
$TaskTemplateMetadata | ConvertTo-Json -Depth 12 | sc -Path $TaskTemplateMetadataFilePath -Force
# build a nupkg file
New-NuGetPackage -NuspecFilePath $NuspecFilePath
$NuPkgFilePath = Join-Path -Path $ProjectRootDirPath -ChildPath "$Id.$Version.nupkg"
# publish nupkg file
Publish-NuGetPackage -NupkgFilePath $NuPkgFilePath -SourcePathOrUrl $DestinationPathOrUrl -ApiKey $ApiKey
}
Finally{
Remove-Item $NuspecFilePath -Force
Remove-Item $TaskTemplateMetadataFilePath -Force
Remove-Item $NuPkgFilePath -Force
}
}
function Get-AppeaseTaskTemplateInstallDirPath(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Id,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Version,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
Resolve-Path "$ProjectRootDirPath\.Appease\Templates\$Id.$Version" | Write-Output
}
function Get-AppeaseTaskTemplateMetadata(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Id,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Version,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
<#
.SYNOPSIS
Parses a dependencies.json file
#>
$TemplateInstallDirPath = Get-AppeaseTaskTemplateInstallDirPath -Id $Id -Version $Version -ProjectRootDirPath $ProjectRootDirPath
$TemplateDependenciesFilePath = Join-Path -Path $TemplateInstallDirPath -ChildPath "\metadata.json"
Get-Content $TemplateDependenciesFilePath | Out-String | ConvertFrom-Json | Write-Output
}
function Install-NuGetPackage(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Id,
[string]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$Version,
[string[]]
[ValidateCount( 1, [Int]::MaxValue)]
[ValidateNotNullOrEmpty()]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$Source,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$OutputDirPath
){
$InitialOFS = $OFS
Try{
$OFS = ';'
$NugetParameters = @('install',$Id,'-Source',($Source|Out-String),'-OutputDirectory',$OutputDirPath,'-Version',$Version,'-NonInteractive')
Write-Debug `
@"
Invoking nuget:
& $NuGetCommand $($NugetParameters|Out-String)
"@
& $NuGetCommand $NugetParameters
# handle errors
if ($LastExitCode -ne 0) {
throw $Error
}
}
Finally{
$OFS = $InitialOFS
}
}
function Install-ChocolateyPackage(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Id,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$Source,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$Version,
[string]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$InstallArguments,
[switch]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$OverrideArguments,
[string]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$PackageParameters,
[switch]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$AllowMultipleVersions,
[switch]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$IgnoreDependencies
){
$ChocolateyParameters = @('install',$Id,'--confirm')
if($Source){
$ChocolateyParameters += @('--source',$Source)
}
if($Version){
$ChocolateyParameters += @('--version',$Version)
}
if($InstallArguments){
$ChocolateyParameters += @('--install-arguments',$InstallArguments)
}
if($OverrideArguments.IsPresent){
$ChocolateyParameters += @('--override-arguments')
}
if($PackageParameters){
$ChocolateyParameters += @('--package-parameters',$PackageParameters)
}
if($AllowMultipleVersions.IsPresent){
$ChocolateyParameters += @('--allow-multiple-versions')
}
if($IgnoreDependencies.IsPresent){
$IgnoreDependencies += @('--ignore-dependencies')
}
Write-Debug `
@"
Invoking chocolatey:
& $ChocolateyCommand $($ChocolateyParameters|Out-String)
"@
& $ChocolateyCommand $ChocolateyParameters
# handle errors
if ($LastExitCode -ne 0) {
throw $Error
}
}
function Install-AppeaseTaskTemplate(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Id,
[string]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$Version,
[string[]]
[ValidateCount( 1, [Int]::MaxValue)]
[ValidateNotNullOrEmpty()]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$Source,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath='.'){
<#
.SYNOPSIS
Installs a task template to an environment if it's not already installed
#>
if([string]::IsNullOrWhiteSpace($Version)){
$Version = Get-LatestTemplateVersion -Source $Source -Id $Id
Write-Debug "using greatest available template version : $Version"
}
# install NuGet package containing task template
Install-NuGetPackage -Id $Id -Version $Version -Source $Source -OutputDirPath "$ProjectRootDirPath\.Appease\Templates"
$AppeaseTaskTemplateMetadata = Get-AppeaseTaskTemplateMetadata -Id $Id -Version $Version -ProjectRootDirPath $ProjectRootDirPath
# install Chocolatey dependencies
$AppeaseTaskTemplateMetadata.Dependencies.Chocolatey | %{if($_){$_ | Install-ChocolateyPackage}}
}
function Uninstall-AppeaseTaskTemplate(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Id,
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipelineByPropertyName=$true)]
$Version,
[string]
[ValidateScript({Test-Path $_ -PathType Container})]
[Parameter(
ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath='.'){
<#
.SYNOPSIS
Uninstalls a task template from an environment if it's installed
#>
$TaskTemplateInstallationDir = Get-AppeaseTaskTemplateInstallDirPath -Id $Id -Version $Version -ProjectRootDirPath $ProjectRootDirPath
If(Test-Path $TaskTemplateInstallationDir){
Write-Debug `
@"
Removing template at:
$TaskTemplateInstallationDir
"@
Remove-Item $TaskTemplateInstallationDir -Recurse -Force
}
Else{
Write-Debug `
@"
No template to remove at:
$TaskTemplateInstallationDir
"@
}
#TODO: UNINSTALL DEPENDENCIES ?
}
Export-ModuleMember -Variable 'DefaultTemplateSources'
Export-ModuleMember -Function @(
'Get-AppeaseTaskTemplateLatestVersion',
'Get-AppeaseTaskTemplateInstallDirPath'
'Publish-AppeaseTaskTemplate',
'Install-AppeaseTaskTemplate',
'Uninstall-AppeaseTaskTemplate')
$SemanticVersionRegex = "(?<Major>\d+)\.(?<Minor>\d+)\.(?<Patch>\d+)(?:-(?<PreRelease>[0-9A-Za-z-.]*))?(?:\+(?<Build>[0-9A-Za-z-.]*))?"
function Test-SemanticVersion(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true,
ValueFromPipeline=$true)]
$SemanticVersionString){
$SemanticVersionString -match $SemanticVersionRegex
}
function ConvertTo-SemanticVersionObject(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
Mandatory=$true)]
$SemanticVersionString){
<#
.SYNOPSIS
creates an object representing a v1.0 & v2.0 semantic version (see: http://semver.org/)
#>
$SemanticVersionString -match $SemanticVersionRegex |Out-Null
$Matches.Remove(0)
$Matches.Major = [int]$Matches.Major
$Matches.Minor = [int]$Matches.Minor
$Matches.Patch = [int]$Matches.Patch
If($Matches.PreRelease){
$preReleaseIdentifiers = $Matches.PreRelease.Split('.')|%{if($_ -as [long]){[long]$_}else{[string]$_}}
$Matches.PreRelease = @{Identifiers=[object[]]$preReleaseIdentifiers}
}
$Matches.Clone() | Write-Output
}
function Compare-SemanticVersions(
<#
.SYNOPSIS
compares v1.0 & v2.0 semantic versions (see: http://semver.org/)
#>
[string]
$XSemVerString,
[string]
$YSemVerString){
$XSemVer = ConvertTo-SemanticVersionObject -SemanticVersionString $XSemVerString
$YSemVer = ConvertTo-SemanticVersionObject -SemanticVersionString $YSemVerString
If($XSemVer.Major -ne $YSemVer.Major){
return $XSemVer.Major - $YSemVer.Major
}
ElseIf($XSemVer.Minor -ne $YSemVer.Minor){
return $XSemVer.Minor - $YSemVer.Minor
}
ElseIf($XSemVer.Patch -ne $YSemVer.Patch){
return $XSemVer.Patch - $YSemVer.Patch
}
# per spec: "When major, minor, and patch are equal, a pre-release version has lower precedence than a normal version"
If(!$XSemVer.PreRelease -and $YSemVer.PreRelease){
return 1
}
ElseIf(!$XSemVer.PreRelease -and !$YSemVer.PreRelease){
return 0
}
ElseIf($XSemVer.PreRelease -and !$YSemVer.PreRelease){
return -1
}
For($i = 0;$i -lt [Math]::Min($XSemVer.PreRelease.Identifiers.Count,$YSemVer.PreRelease.Identifiers.Count);$i++){
$XIdentifier = $XSemVer.PreRelease.Identifiers[$i]
$YIdentifier = $YSemVer.PreRelease.Identifiers[$i]
#if x and y numeric
If(($XIdentifier -is [long]) -and ($YIdentifier -is [long])){
#per spec: "identifiers consisting of only digits are compared numerically"
$xIdentifierMinusYIdentifier = $XIdentifier - $YIdentifier
If($xIdentifierMinusYIdentifier -ne 0){
return $xIdentifierMinusYIdentifier
}
}
#if x or[exclusive] y is numeric
ElseIf(($XIdentifier -is [long]) -xor ($YIdentifier -is [long])){
#per spec: "Numeric identifiers always have lower precedence than non-numeric identifiers"
If($XIdentifier -isnot [long]){
return 1
}
Else{
return -1
}
}
#if x and y both textual
Else{
#per spec: "identifiers with letters or hyphens are compared lexically in ASCII sort order"
If($XIdentifier -gt $YIdentifier){
return 1
}
ElseIf($XIdentifier -lt $YIdentifier){
return -1
}
}
}
#per spec: "A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal"
return $XSemVer.PreRelease.Identifiers.Count - $YSemVer.PreRelease.Identifiers.Count
}
function Get-SortedSemanticVersions(
[string[]]
$InputArray,
[switch]
$Descending){
<#
.SYNOPSIS
sorts v1.0 & v2.0 semantic versions (see: http://semver.org/)
#>
$counter = 0
$compareResultFactor = 1
if($Descending.IsPresent){
$compareResultFactor = -1
}
# $unsorted is the first index of the unsorted region
for ($unsorted = 1; $unsorted -lt $InputArray.Count; $unsorted++)
{
# Next item in the unsorted region
$nextItem = $InputArray[$unsorted]
# Index of insertion in the sorted region
$location = $unsorted
while (($location -gt 0) -and `
(($compareResultFactor *(Compare-SemanticVersions -X $InputArray[$location - 1] -Y $nextItem)) -gt 0))
{
$counter++
# Shift to the right
$InputArray[$location] = $InputArray[$location - 1]
$location--
}
# Insert $nextItem into the sorted region
$InputArray[$location] = $nextItem
}
Write-Output $InputArray
}
Export-ModuleMember -Function @(
'Get-SortedSemanticVersions',
'Test-SemanticVersion')
$ModuleName = (gi $PSScriptRoot).Name
$RootInstallationDirPath = "C:\Program Files\Appease"
$RootPowerShellModuleInstallationDirPath = "$RootInstallationDirPath\PowerShell"
$ModuleInstallationDirPath = "$RootPowerShellModuleInstallationDirPath\$ModuleName"
# make idempotent
if(Test-Path $ModuleInstallationDirPath){
Remove-Item -Path $ModuleInstallationDirPath -Recurse -Force
}
# make idempotent
if($RootInstallationDirPath -and !(gci $RootPowerShellModuleInstallationDirPath)){
# remove $ModuleInstallationDirPath
Remove-Item $RootPowerShellModuleInstallationDirPath -Force
# remove $PSModulePath modification
$PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath','Machine')
$NewPSModulePathParts = @();
$IsPSModulePathModified = $false
foreach($part in $PSModulePath.Split(';')){
if($part -eq $RootPowerShellModuleInstallationDirPath){
$IsPSModulePathModified = $true
}
else{
$NewPSModulePathParts += $part;
}
}
$PSModulePath = $NewPSModulePathParts -join ';'
if($IsPSModulePathModified){
Write-Debug "updating '$env:PSModulePath' to $PSModulePath"
# save
[Environment]::SetEnvironmentVariable('PSModulePath',$PSModulePath,'Machine')
}
}
if(!(gci $RootInstallationDirPath)){
Remove-Item $RootInstallationDirPath -Force
}
try {
. "$PSScriptRoot\Appease.Client\Uninstall.ps1"
} catch {
Write-ChocolateyFailure 'appease.client.powershell' $_.Exception.Message
throw
}
Log in or click on link to see number of positives.
In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).
Chocolatey Pro provides runtime protection from possible malware.
Add to Builder | Version | Downloads | Last Updated | Status |
---|---|---|---|---|
appease.client.powershell 0.0.88 | 1102 | Saturday, April 4, 2015 | Approved | |
appease.client.powershell 0.0.87 | 472 | Thursday, April 2, 2015 | Approved | |
appease.client.powershell 0.0.77 | 479 | Monday, April 13, 2015 | Approved | |
appease.client.powershell 0.0.74 | 435 | Monday, March 30, 2015 | Approved |
-
- chocolatey (≥ 0.9.9.4)
- nuget.commandline (≥ 2.8.3)
Ground Rules:
- This discussion is only about appease.client.powershell and the appease.client.powershell package. If you have feedback for Chocolatey, please contact the Google Group.
- This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
- The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
- Tell us what you love about the package or appease.client.powershell, or tell us what needs improvement.
- Share your experiences with the package, or extra configuration or gotchas that you've found.
- If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.