This repository has been archived by the owner on Feb 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.ps1
83 lines (72 loc) · 3 KB
/
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
[CmdletBinding()]
param (
[switch]$Clean,
[switch]$Build,
[switch]$Test,
[switch]$CI,
[switch]$Bootstrap
)
function Bootstrap {
Write-Host "`n`r--- Bootstrap ---"
& "$PSScriptRoot\requirements.ps1"
}
function Clean {
Write-Host "`n`r--- Clean ---"
if (Test-Path "$PSScriptRoot\release") {
Remove-Item "$PSScriptRoot\release" -Recurse -Force
}
}
function Build {
Write-Host "`n`r--- Build ---"
$manifestTemplate = Import-PowerShellDataFile -Path "$PSScriptRoot\src\signalfx-powershell.psd1"
New-Item -Name release -Path $PSScriptRoot -ItemType Directory | Out-Null
New-Item -Name signalfx -Path "$PSScriptRoot\release\" -ItemType Directory | Out-Null
Write-Host "`n`r--- Build Module ---"
Get-Content -Path "$PSScriptRoot\src\classes.clients.ps1" -Raw | Set-Content -Path "$PSScriptRoot\release\signalfx\signalfx.psm1" -Force
Get-ChildItem -Path "$PSScriptRoot\src\" -filter "classes*" | Where-Object Name -ne 'classes.clients.ps1' | ForEach-Object {
Get-Content -Path $_.FullName -Raw | Add-Content -Path "$PSScriptRoot\release\signalfx\signalfx.psm1"
}
Get-Item "$PSScriptRoot\release\signalfx\signalfx.psm1" | Select-Object -Property Name, Length, LastWriteTime | Out-String
Get-ChildItem -Path "$PSScriptRoot\src\" -filter "*.ps1" | Where-Object Name -notlike 'classes.*.ps1' | ForEach-Object {
Get-Content -Path $_.FullName -Raw | Add-Content -Path "$PSScriptRoot\release\signalfx\signalfx.psm1"
}
Write-Host "`n`r--- Build Manifest ---"
$moduleParams = @{
GUID = $manifestTemplate.GUID
ModuleVersion = $manifestTemplate.ModuleVersion
Author = $manifestTemplate.Author
Description = $manifestTemplate.Description
Copyright = $manifestTemplate.Copyright
CompanyName = $manifestTemplate.CompanyName
RootModule = "signalfx.psm1"
FunctionsToExport = $manifestTemplate.FunctionsToExport
CmdletsToExport = ''
VariablesToExport = ''
AliasesToExport = ''
RequireLicenseAcceptance = $manifestTemplate.PrivateData.PSData.RequireLicenseAcceptance
ProjectUri = $manifestTemplate.PrivateData.PSData.ProjectUri
LicenseUri = $manifestTemplate.PrivateData.PSData.LicenseUri
Tags = @('signalfx', 'api')
}
New-ModuleManifest -Path "$PSScriptRoot\release\signalfx\signalfx.psd1" @moduleParams
Get-Item "$PSScriptRoot\release\signalfx\signalfx.psd1" | Select-Object -Property Name, Length, LastWriteTime | Out-String
}
function Test {
param (
[switch]$EnableExit
)
Write-Host "`n`r--- Test ---"
Invoke-Pester -Path "$PSScriptRoot\tests" -Show Failed,Summary -EnableExit:$EnableExit
}
if ($Bootstrap) {
Bootstrap
}
if ($Build) {
if ($Clean) {
Clean
}
Build
}
if ($Test) {
Test -EnableExit:$CI
}