-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
60 lines (50 loc) · 2.46 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
$Output = Join-Path $PSScriptRoot "yarn.crescendo"
$obj = Join-Path $PSScriptRoot "obj"
Remove-Item $Output -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item $obj -Recurse -Force -ErrorAction SilentlyContinue
New-Item $Output -ItemType Directory
New-Item (Join-Path $Output "Helpers") -ItemType Directory
New-Item $obj -ItemType Directory
$Commands = Get-ChildItem (Join-Path "$PSScriptRoot" "src/Commands") | ForEach-Object {
$Definition = & $_.FullName
$Command = New-CrescendoCommand -Verb $Definition.Verb -Noun $Definition.Noun -OriginalName $Definition.OriginalName
$Command.OriginalCommandElements = $Definition.OriginalCommandElements
$Command.Description = $Definition.Description
if ($Definition.Parameters) {
$Command.Parameters = $Definition.Parameters | ForEach-Object {
$Parameter = New-ParameterInfo -Name $_.Name -OriginalName $_.OriginalName
$Parameter.AdditionalParameterAttributes = $_.AdditionalParameterAttributes
$Parameter.Mandatory = $_.Mandatory
$Parameter.OriginalName = $_.OriginalName
$Parameter.OriginalPosition = $_.OriginalPosition
$Parameter.ParameterType = $_.ParameterType
$Parameter.Description = $_.Description
$Parameter
}
}
if ($Definition.OutputHandlers) {
$Command.OutputHandlers = $Definition.OutputHandlers | ForEach-Object {
$Handler = New-OutputHandler
$Handler.ParameterSetName = $_.ParameterSetName
$Handler.Handler = $_.Handler
$Handler.HandlerType = $_.HandlerType
$Handler.StreamOutput = $_.StreamOutput
$Handler
}
}
$Command
}
@{
'$schema' = 'https://aka.ms/PowerShell/Crescendo/Schemas/2021-11'
Commands = @($Commands)
} | ConvertTo-Json -Depth 5 | Out-File "$obj\Commands.json"
Export-CrescendoModule -ConfigurationFile (Get-ChildItem "$obj") -ModuleName (Join-Path $Output "yarn.crescendo") -Force -Verbose
Copy-Item (Join-path $PSScriptRoot "src/Helpers/*.ps1") (Join-Path $Output "Helpers") -Recurse -Verbose
$ManifestInfo = @{
ModuleVersion = "0.0"
Author = "Michael Kelley"
Description = 'PowerShell Crescendo cmdlet for yarn'
LicenseUri = 'https://github.com/kelleyma49/yarn.crescendo/blob/master/LICENSE'
ProjectUri = 'https://github.com/kelleyma49/yarn.crescendo'
}
Update-ModuleManifest -Path (Join-Path $Output "yarn.crescendo.psd1") @ManifestInfo -Verbose