From 87ed1e31fd357d75921a5cb52559f3c5292de4d0 Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Sat, 5 May 2018 11:07:45 -0400 Subject: [PATCH 1/4] Add YAML build definition support Remove extra white space --- build.yaml | 7 +++++++ readme.md | 7 +++++++ src/New-BuildFromYaml.ps1 | 28 ++++++++++++++++++++++++++++ src/bob.psd1 | Bin 8156 -> 8196 bytes src/bob.psm1 | 1 + 5 files changed, 43 insertions(+) create mode 100644 build.yaml create mode 100644 src/New-BuildFromYaml.ps1 diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..40b7a88 --- /dev/null +++ b/build.yaml @@ -0,0 +1,7 @@ +build: + source: .\src + output: .\output\bob + stages: + - clean + - copy + - test diff --git a/readme.md b/readme.md index 6dd1ba8..6f5805d 100644 --- a/readme.md +++ b/readme.md @@ -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} diff --git a/src/New-BuildFromYaml.ps1 b/src/New-BuildFromYaml.ps1 new file mode 100644 index 0000000..8fcc65c --- /dev/null +++ b/src/New-BuildFromYaml.ps1 @@ -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 +} \ No newline at end of file diff --git a/src/bob.psd1 b/src/bob.psd1 index 649bc2e9a970362e6a5d76087e8e27a119009f8f..f082985284d9cbc8b79382f55bf1c6c894a98157 100644 GIT binary patch delta 34 ocmca(-{P=AOqfw;@ Date: Sat, 5 May 2018 11:14:58 -0400 Subject: [PATCH 2/4] Increment version --- src/bob.psd1 | Bin 8196 -> 8196 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/bob.psd1 b/src/bob.psd1 index f082985284d9cbc8b79382f55bf1c6c894a98157..d0b6d58bbc6a11e5c232cae39ffaaf94ea9038de 100644 GIT binary patch delta 14 VcmZp1XmQxU#KdU4nVE@E4geow14sY> delta 14 VcmZp1XmQxU#KdT{nVE@E4geoq14jS= From 2daf670abc9c69d8b371900df3dd33be36a8532c Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Sat, 5 May 2018 11:22:17 -0400 Subject: [PATCH 3/4] Add powershell-yaml dependency --- src/bob.psd1 | Bin 8196 -> 8226 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/bob.psd1 b/src/bob.psd1 index d0b6d58bbc6a11e5c232cae39ffaaf94ea9038de..48e6017369f54ef982cdfcbdbd48cf964aec6cfa 100644 GIT binary patch delta 50 zcmZp1SmdyQhi9??kA|W;LjXfQLpeh#LlHwULk5t}0YY7dN`^#+Tp&w*vpLUMVE`_L B3y=T+ delta 28 kcmZ4F(BiOxhi7tuILqW`JOYztcqAtC@bPU<;n^n)0EU?eqyPW_ From 756db92d7fed619ebf10101871b6dbfbc7962c29 Mon Sep 17 00:00:00 2001 From: dfinke Date: Sat, 5 May 2018 13:18:49 -0400 Subject: [PATCH 4/4] Playing with this idea for strategy --- testStrategy.ps1 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 testStrategy.ps1 diff --git a/testStrategy.ps1 b/testStrategy.ps1 new file mode 100644 index 0000000..acb9feb --- /dev/null +++ b/testStrategy.ps1 @@ -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()) \ No newline at end of file