Skip to content

Commit

Permalink
Merge pull request #421 from StartAutomating/PipeScript-Phases
Browse files Browse the repository at this point in the history
PipeScript 0.2.5
  • Loading branch information
StartAutomating authored Apr 27, 2023
2 parents f791e7a + 7295125 commit 80fa002
Show file tree
Hide file tree
Showing 88 changed files with 3,131 additions and 210 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/TestAndPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: GitLogger
uses: GitLogging/GitLoggerAction@main
id: GitLogger
- name: Use PSSVG Action
uses: StartAutomating/PSSVG@main
id: PSSVG
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#requires -Module PSDevOps
#requires -Module PipeScript
Import-BuildStep -ModuleName PipeScript
Push-Location $PSScriptRoot
Push-Location ($PSScriptRoot | Split-Path)
New-GitHubAction -Name "BuildPipeScript" -Description @'
Builds code using PipeScript
'@ -Action PipeScriptAction -Icon code -OutputPath .\action.yml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#requires -Module PSDevOps
Import-BuildStep -ModuleName PipeScript
Push-Location $PSScriptRoot
Push-Location ($PSScriptRoot | Split-Path)
New-GitHubWorkflow -Name "Analyze, Test, Tag, and Publish" -On Push, PullRequest, Demand -Job PowerShellStaticAnalysis, TestPowerShellOnLinux, TagReleaseAndPublish, BuildPipeScript -Environment @{
NoCoverage = $true
} -OutputPath .\.github\workflows\TestAndPublish.yml
Expand Down
2 changes: 1 addition & 1 deletion PipeScript.HelpOut.ps1 → Build/PipeScript.HelpOut.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#require -Module HelpOut
Push-Location $PSScriptRoot
Push-Location ($PSScriptRoot | Split-Path)

$PipeScriptLoaded = Get-Module PipeScript
if (-not $PipeScriptLoaded) {
Expand Down
2 changes: 1 addition & 1 deletion PipeScript.PSSVG.ps1 → Build/PipeScript.PSSVG.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ svg -ViewBox 1920,1080 @(
svg.animateTransform -AttributeName transform -From "360 $circleMid" -To "0 $circleMid" -dur "$($RotateEvery.TotalSeconds)s" -RepeatCount 'indefinite' -AttributeType 'XML' -Type 'rotate'
)
) -OutputPath (
Join-Path $PSScriptRoot Assets | Join-Path -ChildPath "PipeScript.svg"
Join-Path ($PSScriptRoot | Split-Path) Assets | Join-Path -ChildPath "PipeScript.svg"
)
14 changes: 9 additions & 5 deletions PipeScript.Piecemeal.ps1 → Build/PipeScript.Piecemeal.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#require -Module Piecemeal

# Push to this directory
Push-Location $PSScriptRoot
Push-Location ($PSScriptRoot | Split-Path)

$commandsPath = Join-Path $PWD Commands

# Get-Transpiler is generated with Piecemeal
Install-Piecemeal -ExtensionNoun 'Transpiler' -ExtensionPattern '\.psx\.ps1$','^PipeScript\p{P}Transpiler\p{P}(?!(?>format|types|tests)\p{P})','^psx\p{P}' -ExtensionTypeName 'PipeScript.Transpiler' -OutputPath '.\Get-Transpiler.ps1' |
Add-Member Noteproperty CommitMessage "Get-Transpiler: Updating Piecemeal@[$((Get-Module Piecemeal).Version)]" -Force -PassThru
Install-Piecemeal -ExtensionNoun 'Transpiler' -ExtensionPattern '\.psx\.ps1$','^PipeScript\p{P}Transpiler\p{P}(?!(?>format|types|tests)\p{P})','^psx\p{P}' -ExtensionTypeName 'PipeScript.Transpiler' -OutputPath (
Join-Path $commandsPath Get-Transpiler.ps1
)

# So is Get-PipeScript
Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$','^PipeScript.' -ExtensionTypeName 'PipeScript' -OutputPath '.\Get-PipeScript.ps1' |
Add-Member Noteproperty CommitMessage "Get-PipeScript: Updating Piecemeal@[$((Get-Module Piecemeal).Version)]" -Force -PassThru
Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$','^PipeScript.' -ExtensionTypeName 'PipeScript' -OutputPath (
Join-Path $commandsPath Get-PipeScript.ps1
)

# Pop back to wherever we were
Pop-Location
2 changes: 1 addition & 1 deletion PipeScript.ezout.ps1 → Build/PipeScript.ezout.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Install-Module EZOut or https://github.com/StartAutomating/EZOut
$myFile = $MyInvocation.MyCommand.ScriptBlock.File
$myModuleName = 'PipeScript'
$myRoot = $myFile | Split-Path
$myRoot = $myFile | Split-Path | Split-Path
Push-Location $myRoot
$formatting = @(
# Add your own Write-FormatView here,
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## PipeScript 0.2.5:

* Added Support for Aspects (#401)
* Support for Pre/Post commands in Core Transpiler
* Commands Named PipeScript.PreProcess / PipeScript.Analyzer will run before transpilation of a ScriptBlock
* Commands Named PipeScript.PostProcess / PipeScript.Optimizer will run after transpilation of a ScriptBlock
* Adding PipeScript.Optimizer.ConsolidateAspects (Fixes #413)
* Conditional Keywords Fixes (Fixes #402)
* New-PipeScript: Improving Pipelining (Fixes #400)
* Update-PipeScript:
* Tracing Events (#407)
* Support for Insertions (#405, #406, #407)
* Template Improvements
* Templates can now be either singleline or multiline (Fixes #398)
* New Language Support
* Eiffel (#404)
* PS1XML (#414)
* SVG (#411)
* XAML (#414)
* XML Transpilers support inline xml output (Fixes #412)
* Added initial demo file (Fixes #420)

---

## PipeScript 0.2.4:

* Conditional Keywords now support throw/return (#389/#388) (also, fixed #387)
Expand Down
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

20 changes: 15 additions & 5 deletions Export-PipeScript.ps1 → Commands/Export-PipeScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,29 @@ function Export-Pipescript {

$buildFileTemplate = $buildFile.Template
if ($buildFileTemplate -and $buildFile.PipeScriptType -ne 'Template') {
Invoke-PipeScript $buildFileTemplate.Source
try {
Invoke-PipeScript $buildFileTemplate.Source
} catch {
$ex = $_
Write-Error -ErrorRecord $ex
}
$alreadyBuilt[$buildFileTemplate.Source] = $true
}

$EventsFromThisBuild = Get-Event |
$EventsFromThisBuild = Get-Event |
Where-Object TimeGenerated -gt $ThisBuildStartedAt |
Where-Object SourceIdentifier -Like 'PipeScript.*'
Where-Object SourceIdentifier -Like '*PipeScript*'

Invoke-PipeScript $buildFile.Source
try {
Invoke-PipeScript $buildFile.Source
} catch {
$ex = $_
Write-Error -ErrorRecord $ex
}

$alreadyBuilt[$buildFile.Source] = $true
}


$BuildTime = [DateTime]::Now - $buildStarted
Write-Progress "Building PipeScripts [$FilesToBuildCount / $filesToBuildTotal]" "Finished In $($BuildTime) " -Completed -id $filesToBuildID
}
Expand Down
2 changes: 1 addition & 1 deletion Get-PipeScript.ps1 → Commands/Get-PipeScript.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#region Piecemeal [ 0.3.10 ] : Easy Extensible Plugins for PowerShell
# Install-Module Piecemeal -Scope CurrentUser
# Import-Module Piecemeal -Force
# Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$','^PipeScript.' -ExtensionTypeName 'PipeScript' -OutputPath '.\Get-PipeScript.ps1'
# Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$','^PipeScript.' -ExtensionTypeName 'PipeScript' -OutputPath '/home/runner/work/PipeScript/PipeScript/Commands/Get-PipeScript.ps1'
function Get-PipeScript
{
<#
Expand Down
2 changes: 1 addition & 1 deletion Get-Transpiler.ps1 → Commands/Get-Transpiler.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#region Piecemeal [ 0.3.10 ] : Easy Extensible Plugins for PowerShell
# Install-Module Piecemeal -Scope CurrentUser
# Import-Module Piecemeal -Force
# Install-Piecemeal -ExtensionNoun 'Transpiler' -ExtensionPattern '\.psx\.ps1$','^PipeScript\p{P}Transpiler\p{P}(?!(?>format|types|tests)\p{P})','^psx\p{P}' -ExtensionTypeName 'PipeScript.Transpiler' -OutputPath '.\Get-Transpiler.ps1'
# Install-Piecemeal -ExtensionNoun 'Transpiler' -ExtensionPattern '\.psx\.ps1$','^PipeScript\p{P}Transpiler\p{P}(?!(?>format|types|tests)\p{P})','^psx\p{P}' -ExtensionTypeName 'PipeScript.Transpiler' -OutputPath '/home/runner/work/PipeScript/PipeScript/Commands/Get-Transpiler.ps1'
function Get-Transpiler
{
<#
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 31 additions & 22 deletions New-PipeScript.ps1 → Commands/New-PipeScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,8 @@ HTTP Accept indicates what content types the web request will accept as a respon
[ScriptBlock]
$Begin,
# The process block.
[Parameter(ValueFromPipelineByPropertyName)]
[ValidateScript({
if ($_ -isnot [ScriptBlock]) { return $true }
if ($_.Ast.DynamicParamBlock -or $_.Ast.BeginBlock -or $_.Ast.ProcessBlock) {
throw "ScriptBlock should not have any named blocks"
}
return $true
})]
[ValidateScript({
if ($_ -isnot [ScriptBlock]) { return $true }
if ($_.Ast.ParamBlock.Parameters.Count) {
throw "ScriptBlock should not have parameters"
}
return $true
})]
[Alias('ProcessBlock')]
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)]
[Alias('ProcessBlock','ScriptBlock')]
[ScriptBlock]
$Process,
# The end block.
Expand Down Expand Up @@ -198,6 +184,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
$allEndBlocks = @()
$allProcessBlocks = @()
$allHeaders = @()
${?<EmptyParameterBlock>} = '^[\s\r\n]{0,}param\(' -replace '\)[\s\r\n]{0,}$'
filter embedParameterHelp {
if ($_ -notmatch '^\s\<\#' -and $_ -notmatch '^\s\#') {
$commentLines = @($_ -split '(?>\r\n|\n)')
Expand Down Expand Up @@ -282,13 +269,13 @@ HTTP Accept indicates what content types the web request will accept as a respon
if ($EachParameter.Value.Ast.ParamBlock) {
# embed the parameter block (except for the param keyword)
$EachParameter.Value.Ast.ParamBlock.Extent.ToString() -replace
'^[\s\r\n]{0,}param\(' -replace '\)[\s\r\n]{0,}$'
${?<EmptyParameterBlock>}
} else {
# Otherwise
'[Parameter(ValueFromPipelineByPropertyName)]' + (
$EachParameter.Value.ToString() -replace
"\`$$($eachParameter.Key)[\s\r\n]$" -replace # Replace any trailing variables
'param\(\)[\s\r\n]{0,}$' # then replace any empty param blocks.
${?<EmptyParameterBlock>} # then replace any empty param blocks.
)
}
}
Expand Down Expand Up @@ -449,7 +436,28 @@ HTTP Accept indicates what content types the web request will accept as a respon
}
# process,
if ($process) {
$allProcessBlocks += $process
if ($process.BeginBlock -or
$process.ProcessBlock -or
$process.DynamicParameterBlock -or
$Process.ParamBlock) {
if ($process.DynamicParameterBlock) {
$allDynamicParameters += $process.DynamicParameterBlock
}
if ($process.ParamBlock) {
$parameterScriptBlocks += $Process
}
if ($Process.BeginBlock) {
$allBeginBlocks += $Process.BeginBlock -replace ${?<EmptyParameterBlock>}
}
if ($process.ProcessBlock) {
$allProcessBlocks += $process.ProcessBlock
}
if ($process.EndBlock) {
$allEndBlocks += $Process.EndBlock -replace ${?<EmptyParameterBlock>}
}
} else {
$allProcessBlocks += $process -replace ${?<EmptyParameterBlock>}
}
}
# or end blocks.
if ($end) {
Expand Down Expand Up @@ -494,7 +502,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
if ($parameterScriptBlocks) {
$parameterScriptBlocks += [ScriptBlock]::Create($newParamBlock)
# join them with the new parameter block.
$newParamBlock = $parameterScriptBlocks | Join-PipeScript
$newParamBlock = $parameterScriptBlocks | Join-PipeScript -IncludeBlockType param
}

# If we provided a -FunctionName, we'll be declaring a function.
Expand All @@ -510,7 +518,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
$NoTranspile = $false
}
# Create the script block by combining together the provided parts.
$createdScriptBlock = [scriptblock]::Create("$(if ($functionDeclaration) { "$functionDeclaration"})
$ScriptToBe = "$(if ($functionDeclaration) { "$functionDeclaration"})
$($allHeaders -join [Environment]::Newline)
$newParamBlock
$(if ($allDynamicParameters) {
Expand All @@ -528,7 +536,8 @@ $(if ($allEndBlocks -and -not $allBeginBlocks -and -not $allProcessBlocks) {
@(@("end {") + $allEndBlocks + '}') -join [Environment]::Newline
})
$(if ($functionDeclaration) { '}'})
")
"
$createdScriptBlock = [scriptblock]::Create($ScriptToBe)
# If -NoTranspile was passed,
if ($createdScriptBlock -and $NoTranspile) {
$createdScriptBlock # output the script as-is
Expand Down
42 changes: 33 additions & 9 deletions New-PipeScript.ps1.ps1 → Commands/New-PipeScript.ps1.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ HTTP Accept indicates what content types the web request will accept as a respon
$Begin,

# The process block.
[Parameter(ValueFromPipelineByPropertyName)]
[ValidateScriptBlock(NoBlocks, NoParameters)]
[Alias('ProcessBlock')]
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)]
[Alias('ProcessBlock','ScriptBlock')]
[ScriptBlock]
$Process,

Expand Down Expand Up @@ -153,6 +152,8 @@ HTTP Accept indicates what content types the web request will accept as a respon
$allProcessBlocks = @()
$allHeaders = @()

${?<EmptyParameterBlock>} = '^[\s\r\n]{0,}param\(' -replace '\)[\s\r\n]{0,}$'

filter embedParameterHelp {
if ($_ -notmatch '^\s\<\#' -and $_ -notmatch '^\s\#') {
$commentLines = @($_ -split '(?>\r\n|\n)')
Expand Down Expand Up @@ -245,13 +246,13 @@ HTTP Accept indicates what content types the web request will accept as a respon
if ($EachParameter.Value.Ast.ParamBlock) {
# embed the parameter block (except for the param keyword)
$EachParameter.Value.Ast.ParamBlock.Extent.ToString() -replace
'^[\s\r\n]{0,}param\(' -replace '\)[\s\r\n]{0,}$'
${?<EmptyParameterBlock>}
} else {
# Otherwise
'[Parameter(ValueFromPipelineByPropertyName)]' + (
$EachParameter.Value.ToString() -replace
"\`$$($eachParameter.Key)[\s\r\n]$" -replace # Replace any trailing variables
'param\(\)[\s\r\n]{0,}$' # then replace any empty param blocks.
${?<EmptyParameterBlock>} # then replace any empty param blocks.
)
}
}
Expand Down Expand Up @@ -427,7 +428,28 @@ HTTP Accept indicates what content types the web request will accept as a respon

# process,
if ($process) {
$allProcessBlocks += $process
if ($process.BeginBlock -or
$process.ProcessBlock -or
$process.DynamicParameterBlock -or
$Process.ParamBlock) {
if ($process.DynamicParameterBlock) {
$allDynamicParameters += $process.DynamicParameterBlock
}
if ($process.ParamBlock) {
$parameterScriptBlocks += $Process
}
if ($Process.BeginBlock) {
$allBeginBlocks += $Process.BeginBlock -replace ${?<EmptyParameterBlock>}
}
if ($process.ProcessBlock) {
$allProcessBlocks += $process.ProcessBlock
}
if ($process.EndBlock) {
$allEndBlocks += $Process.EndBlock -replace ${?<EmptyParameterBlock>}
}
} else {
$allProcessBlocks += $process -replace ${?<EmptyParameterBlock>}
}
}

# or end blocks.
Expand Down Expand Up @@ -476,7 +498,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
if ($parameterScriptBlocks) {
$parameterScriptBlocks += [ScriptBlock]::Create($newParamBlock)
# join them with the new parameter block.
$newParamBlock = $parameterScriptBlocks | Join-PipeScript
$newParamBlock = $parameterScriptBlocks | Join-PipeScript -IncludeBlockType param
}

# If we provided a -FunctionName, we'll be declaring a function.
Expand All @@ -493,7 +515,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
}

# Create the script block by combining together the provided parts.
$createdScriptBlock = [scriptblock]::Create("$(if ($functionDeclaration) { "$functionDeclaration"})
$ScriptToBe = "$(if ($functionDeclaration) { "$functionDeclaration"})
$($allHeaders -join [Environment]::Newline)
$newParamBlock
$(if ($allDynamicParameters) {
Expand All @@ -511,7 +533,9 @@ $(if ($allEndBlocks -and -not $allBeginBlocks -and -not $allProcessBlocks) {
@(@("end {") + $allEndBlocks + '}') -join [Environment]::Newline
})
$(if ($functionDeclaration) { '}'})
")
"

$createdScriptBlock = [scriptblock]::Create($ScriptToBe)

# If -NoTranspile was passed,
if ($createdScriptBlock -and $NoTranspile) {
Expand Down
Loading

0 comments on commit 80fa002

Please sign in to comment.