forked from SeeminglyScience/EditorServicesProcess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditorServicesProcess.build.ps1
61 lines (49 loc) · 2.28 KB
/
EditorServicesProcess.build.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
#requires -Module InvokeBuild, PSScriptAnalyzer, Pester, PlatyPS, PSStringTemplate -Version 5.1
[CmdletBinding()]
param()
$script:ProjectRoot = $PSScriptRoot
$script:ProjectName = $script:ProjectRoot | Split-Path -Leaf
$script:Manifest = Test-ModuleManifest -Path $script:ProjectRoot\module\$script:ProjectName.psd1 -ErrorAction 0 -WarningAction 0
$script:Version = $script:Manifest.Version
$script:ReleaseFolder = "$script:ProjectRoot\Release\$script:ProjectName\$script:Version"
$script:ManifestPath = "$script:ReleaseFolder\$script:ProjectName.psd1"
$script:Locale = $PSCulture
$script:PesterCCPath = "$script:ReleaseFolder\*.psm1", "$script:ReleaseFolder\Public\*.ps1", "$script:ReleaseFolder\Private\*.ps1"
task Clean -Before BuildDocs {
if (Test-Path $script:ProjectRoot\Release) {
Remove-Item $script:ProjectRoot\Release -Recurse
}
$null = New-Item $script:ReleaseFolder -ItemType Directory
}
task BuildDocs -Before Build {
$null = New-ExternalHelp -Path $script:ProjectRoot\docs\$script:Locale `
-OutputPath "$script:ReleaseFolder\$script:Locale"
}
task Build -Before Test, Analyze {
Copy-Item $script:ProjectRoot\module\* -Destination $script:ReleaseFolder -Recurse -Force
}
task Analyze -Before Install {
Invoke-ScriptAnalyzer -Path $script:ReleaseFolder `
-Settings $script:ProjectRoot\ScriptAnalyzerSettings.psd1 `
-Recurse
}
task Test -If {$false} -Before Install {
Invoke-Pester -CodeCoverage $script:PesterCCPath -PesterOption @{ IncludeVSCodeMarker = $true }
}
task Install {
$installBase = $Home
if ($profile) { $installBase = $profile | Split-Path }
$installPath = Join-Path $installBase -ChildPath 'Modules'
if (-not (Test-Path $installPath)) {
$null = New-Item $installPath -ItemType Directory
}
Copy-Item $script:ProjectRoot\Release\* -Destination $installPath -Force -Recurse
}
task Publish {
if (-not (Test-Path $env:USERPROFILE\.PSGallery\apikey.xml)) {
throw 'Could not find PSGallery API key!'
}
$apiKey = (Import-Clixml $env:USERPROFILE\.PSGallery\apikey.xml).GetNetworkCredential().Password
Publish-Module -Name $script:ReleaseFolder -NuGetApiKey $apiKey -Confirm
}
task . Build