Skip to content

Commit 084b180

Browse files
Merge pull request #319 from StartAutomating/PipeScriptUpdates
PipeScript 0.2.2
2 parents 0109beb + 343a02f commit 084b180

39 files changed

+1320
-204
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
## PipeScript 0.2.2:
2+
3+
* Build-PipeScript is now Export-PipeScript (aliases remain) (Fixes #312)
4+
* Export-PipeScript: Running BuildScripts first (Fixes #316)
5+
* Join-PipeScript
6+
* Ensuring end blocks remain unnamed if they can be (Fixes #317)
7+
* Trmming empty param blocks from end (Fixes #302)
8+
* Update-PipeScript:
9+
* Adding -InsertBefore/After (Fixes #309). Improving aliasing (Fixes #310)
10+
* Aliasing RenameVariable to RenameParameter (Fixes #303). Improving inner docs
11+
* requires transpiler: Caching Find-Module results (Fixes #318)
12+
* Extending Types:
13+
* Adding PipeScript.Template (Fixes #315)
14+
* Adding 'ExtensionScript' to PipeScript.PipeScriptType (Fixes #313)
15+
* Greatly extending ParameterAst (Fixes #305)
16+
* Extending ParamBlockAst (Fixes #304)
17+
18+
---
19+
120
## 0.2.1:
221

322
* Adding preliminary 'define' transpiler (Fixes #299)

Build-PipeScript.ps1 renamed to Export-PipeScript.ps1

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
function Build-Pipescript {
1+
function Export-Pipescript {
22
<#
33
.Synopsis
4-
Builds PipeScript Files
4+
Builds and Exports using PipeScript
55
.Description
6-
Builds PipeScript Files.
6+
Builds and Exports a path, using PipeScript.
77
88
Any Source Generator Files Discovered by PipeScript will be run, which will convert them into source code.
9+
.EXAMPLE
10+
Export-PipeScript
11+
.EXAMPLE
12+
Build-PipeScript
913
#>
10-
[Alias('bps')]
14+
[Alias('Build-PipeScript','bps','eps')]
1115
param(
1216
# One or more input paths. If no -InputPath is provided, will build all scripts beneath the current directory.
1317
[Parameter(ValueFromPipelineByPropertyName)]
@@ -20,29 +24,42 @@ function Build-Pipescript {
2024
$filesToBuild =
2125
@(if (-not $InputPath) {
2226
Get-PipeScript -PipeScriptPath $pwd |
23-
Where-Object PipeScriptType -In SourceGenerator
27+
Where-Object PipeScriptType -In Template, BuildScript |
28+
Sort-Object PipeScriptType, Source
2429
} else {
2530
foreach ($inPath in $InputPath) {
2631
Get-PipeScript -PipeScriptPath $inPath |
27-
Where-Object PipeScriptType -In SourceGenerator
32+
Where-Object PipeScriptType -In Template, BuildScript |
33+
Sort-Object PipeScriptType, Source
2834
}
2935
})
3036

31-
3237
$buildStarted = [DateTime]::Now
38+
$alreadyBuilt = [Ordered]@{}
3339
$filesToBuildCount, $filesToBuildTotal, $filesToBuildID = 0, $filesToBuild.Length, $(Get-Random)
3440
foreach ($buildFile in $filesToBuild) {
35-
$ThisBuildStartedAt = [DateTime]::Now
41+
42+
$ThisBuildStartedAt = [DateTime]::Now
43+
3644
Write-Progress "Building PipeScripts [$FilesToBuildCount / $filesToBuildTotal]" "$($buildFile.Source) " -PercentComplete $(
3745
$FilesToBuildCount++
3846
$FilesToBuildCount * 100 / $filesToBuildTotal
3947
) -id $filesToBuildID
4048

49+
if ($alreadyBuilt[$buildFile.Source]) { continue }
50+
51+
$buildFileTemplate = $buildFile.Template
52+
if ($buildFileTemplate -and $buildFile.PipeScriptType -ne 'Template') {
53+
Invoke-PipeScript $buildFileTemplate.Source
54+
$alreadyBuilt[$buildFileTemplate.Source] = $true
55+
}
56+
4157
$EventsFromThisBuild = Get-Event |
4258
Where-Object TimeGenerated -gt $ThisBuildStartedAt |
4359
Where-Object SourceIdentifier -Like 'PipeScript.*'
4460

4561
Invoke-PipeScript $buildFile.Source
62+
$alreadyBuilt[$buildFile.Source] = $true
4663
}
4764

4865

Get-PipeScript.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region Piecemeal [ 0.3.6 ] : Easy Extensible Plugins for PowerShell
1+
#region Piecemeal [ 0.3.7 ] : Easy Extensible Plugins for PowerShell
22
# Install-Module Piecemeal -Scope CurrentUser
33
# Import-Module Piecemeal -Force
44
# Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$' -ExtensionTypeName 'PipeScript' -OutputPath '.\Get-PipeScript.ps1'
@@ -418,7 +418,7 @@ function Get-PipeScript
418418
}
419419
}
420420
elseif ($attr -is [Management.Automation.ValidatePatternAttribute]) {
421-
$matched = [Regex]::new($attr.RegexPattern, $attr.Options, [Timespan]::FromSeconds(1)).Match($ValidateInput)
421+
$matched = [Regex]::new($attr.RegexPattern, $attr.Options, [Timespan]::FromSeconds(1)).Match("$ValidateInput")
422422
if (-not $matched.Success) {
423423
if ($allValid) {
424424
if ($ErrorActionPreference -eq 'ignore') {
@@ -934,5 +934,5 @@ function Get-PipeScript
934934
}
935935
}
936936
}
937-
#endregion Piecemeal [ 0.3.6 ] : Easy Extensible Plugins for PowerShell
937+
#endregion Piecemeal [ 0.3.7 ] : Easy Extensible Plugins for PowerShell
938938

Get-Transpiler.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region Piecemeal [ 0.3.6 ] : Easy Extensible Plugins for PowerShell
1+
#region Piecemeal [ 0.3.7 ] : Easy Extensible Plugins for PowerShell
22
# Install-Module Piecemeal -Scope CurrentUser
33
# Import-Module Piecemeal -Force
44
# Install-Piecemeal -ExtensionNoun 'Transpiler' -ExtensionPattern '\.psx\.ps1$' -ExtensionTypeName 'PipeScript.Transpiler' -OutputPath '.\Get-Transpiler.ps1'
@@ -418,7 +418,7 @@ function Get-Transpiler
418418
}
419419
}
420420
elseif ($attr -is [Management.Automation.ValidatePatternAttribute]) {
421-
$matched = [Regex]::new($attr.RegexPattern, $attr.Options, [Timespan]::FromSeconds(1)).Match($ValidateInput)
421+
$matched = [Regex]::new($attr.RegexPattern, $attr.Options, [Timespan]::FromSeconds(1)).Match("$ValidateInput")
422422
if (-not $matched.Success) {
423423
if ($allValid) {
424424
if ($ErrorActionPreference -eq 'ignore') {
@@ -934,5 +934,5 @@ function Get-Transpiler
934934
}
935935
}
936936
}
937-
#endregion Piecemeal [ 0.3.6 ] : Easy Extensible Plugins for PowerShell
937+
#endregion Piecemeal [ 0.3.7 ] : Easy Extensible Plugins for PowerShell
938938

Join-PipeScript.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ function Join-PipeScript
294294
# (don't forget to trim leading whitespace)
295295
} else {
296296
# for every other parameter it is the content between parameters.
297-
$lastParameter = $parameter.Parent.Parameters[$parameterIndex - 1]
297+
$lastParameter = $parameter.Parent.Parameters[$parameterIndex - 1]
298298
$relativeOffset = $lastParameter.Extent.EndOffset + 1 - $parameter.Parent.Extent.StartOffset
299299
$distance = $parameter.Extent.StartOffset - $lastParameter.Extent.EndOffset - 1
300300
# (don't forget to trim leading whitespace and commas)
@@ -395,7 +395,7 @@ function Join-PipeScript
395395
$StatementsToAdd = $null
396396
}
397397
if ($block.Unnamed) {
398-
$block.Extent.ToString()
398+
$block.Extent.ToString() -replace '^param\(\)[\s\r\n]{0,}'
399399
} else {
400400
$block.Extent.ToString() -replace '^end\s{0,}\{' -replace '\}$' -replace '^param\(\)[\s\r\n]{0,}'
401401
}
@@ -427,6 +427,13 @@ function Join-PipeScript
427427
#endregion Joining the Scripts
428428

429429
$combinedScriptBlock = [scriptblock]::Create($joinedScript)
430+
if ((-not $combinedScriptBlock.Ast.EndBlock.Unnamed) -and -not (
431+
$combinedScriptBlock.Ast.ProcessBlock -or
432+
$combinedScriptBlock.Ast.BeginBlock -or
433+
$combinedScriptBlock.Ast.DynamicParameterBlock
434+
)) {
435+
$combinedScriptBlock = [ScriptBlock]::Create($combinedScriptBlock.Ast.EndBlock.ToString() -replace '^end\s{0,}\{' -replace '\}$')
436+
}
430437
if ($combinedScriptBlock -and $Transpile) {
431438
$combinedScriptBlock | .>Pipescript
432439
} elseif ($combinedScriptBlock) {

PipeScript.Piecemeal.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
#require -Module Piecemeal
2-
Push-Location $PSScriptRoot
32

3+
# Push to this directory
4+
Push-Location $PSScriptRoot
5+
# Get-Transpiler is generated with Piecemeal
46
Install-Piecemeal -ExtensionNoun 'Transpiler' -ExtensionPattern '\.psx\.ps1$' -ExtensionTypeName 'PipeScript.Transpiler' -OutputPath '.\Get-Transpiler.ps1' |
5-
Add-Member Noteproperty CommitMessage "Get-Transpiler: Updating Piecemeal Version" -Force -PassThru
7+
Add-Member Noteproperty CommitMessage "Get-Transpiler: Updating Piecemeal Version" -Force -PassThru
8+
9+
# So is Get-PipeScript
610
Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$' -ExtensionTypeName 'PipeScript' -OutputPath '.\Get-PipeScript.ps1' |
711
Add-Member Noteproperty CommitMessage "Get-PipeScript: Updating Piecemeal Version" -Force -PassThru
812

9-
13+
# Pop back to wherever we were
1014
Pop-Location

0 commit comments

Comments
 (0)