forked from SitecorePowerShell/Console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeploy_Functions.ps1
102 lines (86 loc) · 2.51 KB
/
Deploy_Functions.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
function Update-FromDefaultSite
{
Param($site)
$defaultSite = $deployConfig.sitesDefault.PsObject.Copy()
foreach ( $property in ($site | Get-Member -MemberType NoteProperty) )
{
$defaultSite | Add-Member -MemberType NoteProperty -Name $property.Name -Value ($site | Select-Object -ExpandProperty $property.Name) -Force
}
return $defaultSite
}
function Create-Junction{
[cmdletbinding(
DefaultParameterSetName = 'Directory',
SupportsShouldProcess=$True
)]
Param (
[string]$path,
[string]$source
)
New-Item -Path $path -Force -ItemType Directory | Out-Null
if(Test-Path "$path"){
cmd.exe /c "rmdir `"$path`" /Q /S" | Out-Null
}
if(-not $removeOnly){
cmd.exe /c "mklink /J `"$path`" `"$source`"" | Out-Null
}
}
function Test-ReparsePoint([string]$path) {
$file = Get-Item $path -Force -ea SilentlyContinue
return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
}
function Get-DeployFolder {
Param (
[string]$sourceFolder,
$deployConfig,
[string]$projectFolder
)
$deployFolderBase = Join-Path $sourceFolder $deployConfig.deployFolder
return Join-Path $deployFolderBase $projectFolder
}
function Get-ProjectFolder {
Param (
[string]$sourceFolder,
[string]$projectFolder
)
return Join-Path $sourceFolder $projectFolder
}
function Filter-ProjectsForSite {
Param (
[Parameter(ValueFromPipeline=$True)]
[Object]$deployProject,
[int]$version,
[string]$projectFilter
)
process {
# Include project only if version number matches or it is 0
if (($version -eq $deployProject.version) -or ($deployProject.version -eq 0) ) {
# If a projectFilter is set, include it only if it matches
if (!$projectFilter -or $projectFilter -eq $deployProject.project ) {
$deployProject
}
}
}
}
filter Filter-JunctionPoints {
param(
$deployProject
)
foreach ( $junctionPoint in $deployProject.junctionPoints )
{
if ($_.FullName.Contains($junctionPoint)) {
return
}
}
$_
}
function Copy-ItemWithStructure {
param (
$sourceFilePath,
$destinationFilePath
)
if (!(Test-Path $destinationFilePath )) {
New-Item -ItemType File -Path $destinationFilePath -Force | Out-Null
}
Copy-Item $sourceFilePath -destination $destinationFilePath
}