Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build:
source: .\src
output: .\output\bob
stages:
- clean
- copy
- test
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ BuildJob src dst {
TestStg
} | Select stages

Stages
------
{Clean, Copy, Test}

# YAML Config
PS> New-BuildFromYaml .\build.yaml | Select stages

Stages
------
{Clean, Copy, Test}
Expand Down
28 changes: 28 additions & 0 deletions src/New-BuildFromYaml.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function New-BuildFromYaml {
[CmdletBinding()]
param (
# Specifies a path to one or more locations.
[Parameter(Mandatory=$true,
Position=0,
ParameterSetName="ParameterSetName",
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage="Path to one or more locations.")]
[Alias("PSPath")]
[ValidateNotNullOrEmpty()]
[string[]]
$Path
)


$config = Get-Content -Path $Path -Raw | ConvertFrom-Yaml

$b = New-BuildJob -Path $config.build.source -Output $config.build.output

ForEach ($stageName in $config.build.stages) {
$stageObject = New-Object -TypeName $stageName
$b | Add-BuildStage -Stage $stageObject | Out-Null
}

Write-Output -InputObject $b
}
Binary file modified src/bob.psd1
Binary file not shown.
1 change: 1 addition & 0 deletions src/bob.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ $global:BUILDER = New-Object -TypeName Object
. $PSScriptRoot\Invoke-Builder.ps1
. $PSScriptRoot\Write-BuilderResults.ps1
. $PSScriptRoot\DSL.ps1
. $PSScriptRoot\New-BuildFromYaml.ps1

# Aliases
if (!(Get-Alias -Name :Clean -ErrorAction SilentlyContinue)) { New-Alias -Name :Clean -Value Add-StageClean }
Expand Down
34 changes: 34 additions & 0 deletions testStrategy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<#
open/close principle
be open for extension, but closed for modification
an entity can allow its behaviour to be extended without modifying its source code
#>

Import-Module .\src\bob.psd1 -Force

function testStrategy {
param($p)

$name = "Invoke-Build{0}" -f $p.gettype().name

if (!(Get-Command $name -ErrorAction SilentlyContinue)) {
return "$name not found"
}

"begin"
"call $name"
"end"
""
}

function Invoke-BuildScriptBlock {}
function Invoke-BuildString {}
function Invoke-BuildTestThis {}

class TestThis {}
class TestThis1 {}

testStrategy {}
testStrategy .\quotes.xml
testStrategy ([TestThis]::new())
testStrategy ([TestThis1]::new())