-
Notifications
You must be signed in to change notification settings - Fork 14
/
Add-Deployment.ps1
128 lines (100 loc) · 9.12 KB
/
Add-Deployment.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
function Add-Deployment
{
<#
.Synopsis
Adds a Pipeworks deployment
.Description
Adds a PowerShell Pipeworks deployment to the list of deployed modules
.Example
Add-Deployment Pipeworks
.Link
Get-Deployment
.Link
Remove-Deployment
#>
[OutputType([Nullable])]
param(
# The name of the module
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string]
$Name,
# The deployment group.
# Certain groups will be automatically created from the Pipeworks manifest.
# * If AllowDownload=$true is set, the module will be added to the deployment group "Downloads"
# * If Win8 is set, the module will be added to the deployment group "Win8Apps"
# * If Bots are provided, the module will be added to the deployment group "Bots"
# * If any command can be run online, the module will be added to the deployment group "SoftwareServices"
# * If any command includes a price, the module will be added to the deployment group "CommercialServices"
# * If the module includes AdSense or PubCenter publishing, the module will be added to the deployment group "AdSupported"
# * If the module contains a UserTable or UserDB, the module will be added to the deployment group "UserSystems"
# * If the module contains analytics trackers, the module will be added to the deployment group "Analyzed"
# * If the module contains securesettings, the module will be added to the deployment group "UsesCredential"
[Parameter(ValueFromPipelineByPropertyName=$true)]
[string[]]
$Group
)
begin {
$deploymentInfoList = New-Object Collections.ArrayList
}
process {
$deploymentInfo = @{} + $PSBoundParameters
$realModule = Get-Module -Name $Name
if (-not $realModule) { return }
$moduleDir = $realModule | Split-Path
$manifest = $realModule | Get-PipeworksManifest
if (-not $DeploymentInfo.Group) {
$DeploymentInfo.Group = @()
}
$deploymentInfo["Path"] = $moduleDir
if ($manifest.AllowDownload) {
$deploymentInfo.Group += "Downloads"
$deploymentInfo.Group = @($deploymentInfo.Group | Select-Object -Unique)
}
if ($manifest.Bot) {
$deploymentInfo.Group += "Bots"
$deploymentInfo.Group = @($deploymentInfo.Group | Select-Object -Unique)
}
if ($manifest.Win8) {
$deploymentInfo.Group += "Win8Apps"
$deploymentInfo.Group = @($deploymentInfo.Group | Select-Object -Unique)
}
if ($manifest.WebCommand) {
$deploymentInfo.Group += "SoftwareServices"
$deploymentInfo.Group = @($deploymentInfo.Group | Select-Object -Unique)
if ($manifest.WebCommand.Values | Where-Object { $_.Price -or $_.Cost }) {
$deploymentInfo.Group += "CommercialServices"
$deploymentInfo.Group = @($deploymentInfo.Group | Select-Object -Unique)
}
}
if ($manifest.AdSenseId -or $manifest.PubCenter) {
$deploymentInfo.Group += "AdSupported"
$deploymentInfo.Group = @($deploymentInfo.Group | Select-Object -Unique)
}
if ($manifest.UserTable -or $manifest.UserDB) {
$deploymentInfo.Group += "UserSystems"
$deploymentInfo.Group = @($deploymentInfo.Group | Select-Object -Unique)
}
if ($manifest.AnalyticsID) {
$deploymentInfo.Group += "Analyzed"
$deploymentInfo.Group = @($deploymentInfo.Group | Select-Object -Unique)
}
if ($manifest.SecureSetting -or $manifest.SecureSettings) {
$deploymentInfo.Group += "UsesCredential"
$deploymentInfo.Group = @($deploymentInfo.Group | Select-Object -Unique)
}
if (-not $existingDeployments) {
$existingDeployments = @{}
}
$null = $deploymentInfoList.add($deploymentInfo)
}
end {
$existingDeployments = Get-SecureSetting -Name "PipeworksDeployments" -ValueOnly
if (-not $existingDeployments) {
$existingDeployments = @{}
}
foreach ($dl in $deploymentInfoList) {
$existingDeployments.($dl.Name) = $dl
}
Add-SecureSetting -Name PipeworksDeployments -Hashtable $existingDeployments
}
}