Skip to content

Commit

Permalink
Merge pull request #396 from StartAutomating/PipeScript-Updates
Browse files Browse the repository at this point in the history
PipeScript 0.2.4
  • Loading branch information
StartAutomating authored Mar 31, 2023
2 parents eac48f7 + a246df2 commit 24a0165
Show file tree
Hide file tree
Showing 143 changed files with 1,066 additions and 416 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/TestAndPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,14 @@ jobs:
id: PSSVG
- name: UsePiecemeal
uses: StartAutomating/Piecemeal@main
- name: BuildPipeScript
- name: Run PipeScript (from main)
if: ${{github.ref_name == 'main'}}
uses: StartAutomating/PipeScript@main
id: PipeScriptMain
- name: Run PipeScript (on branch)
if: ${{github.ref_name != 'main'}}
uses: ./
id: PipeScriptBranch
- name: UseEZOut
uses: StartAutomating/EZOut@master
- name: UseHelpOut
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
## PipeScript 0.2.4:

* Conditional Keywords now support throw/return (#389/#388) (also, fixed #387)
* Updating action: checking for _all_ build errors before outputting (#378)
* Command Updates
* New-PipeScript: Fixing Typed function creation (Fixes #372)
* Join-PipeScript: Fixing End Block Behavior (Fixes #383)
* Templating Improvements:
* New Languages Supported:
* DART (#394)
* SCALA (#395)
* Markdown Template Transpiler now has a more terse format (#393).
* Markdown Template Transpiler now supports embedding in HTML comments or CSS/JavaScript comments (#113).
* JSON/JavaScript Template: Converting Output to JSON if not [string] (#382)
* CSS Template Template : now Outputting Objects as CSS rules (Fixes #332)
* Core Template Transpiler is Faster (#392) and ForeachObject is improved (#390)
* Other Improvements
* Include transpiler: Adding -Passthru (Fixes #385)
* Making validation for various transpilers more careful (Fixes #381)
* CommandNotFound behavior: Limiting recursion (Fixes #380)
* Core Transpiler: Improving Efficiency (Fixes #379)
* Requires allows clobbering and forces loads (Fixes #386)

---

## PipeScript 0.2.3:

### New Features:
Expand Down
37 changes: 27 additions & 10 deletions Github/Actions/PipeScriptAction.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $CommitMessage,

# A list of modules to be installed from the PowerShell gallery before scripts run.
[string[]]
$InstallModule,
$InstallModule = 'ugit',

# The user email associated with a git commit.
[string]
Expand All @@ -56,6 +56,9 @@ $($gitHubEvent | ConvertTo-Json -Depth 100)
::endgroup::
"@ | Out-Host

# Set -ErrorActionPreference to continue.
$global:ErrorActionPreference = 'continue'

#region -InstallModule
if ($InstallModule) {
"::group::Installing Modules" | Out-Host
Expand All @@ -66,7 +69,7 @@ if ($InstallModule) {
$(Get-Content $_.FullName -Raw) -match 'ModuleVersion'
}
if (-not $moduleInWorkspace) {
Install-Module $moduleToInstall -Scope CurrentUser -Force
Install-Module $moduleToInstall -Scope CurrentUser -Force -AllowClobber
Import-Module $moduleToInstall -Force -PassThru | Out-Host
}
}
Expand Down Expand Up @@ -155,21 +158,35 @@ if ($PipeScript) {
}

$PipeScriptTook = [Datetime]::Now - $PipeScriptStart
"::notice title=PipeScriptRuntime::$($PipeScriptScriptTook.TotalMilliseconds)" | Out-Host
"::notice:: .PipeScript ran in $($PipeScriptTook.TotalMilliseconds) ms" | Out-Host

$BuildPipeScriptStart = [DateTime]::Now
if (-not $SkipBuild) {
$buildOutputFiles = @(Build-Pipescript -InputPath $env:GITHUB_WORKSPACE)
$buildOutputFiles |
. $processScriptOutput |
Out-Host
$pipeScriptBuildErrors = $null
$buildOutputFiles = @(Build-Pipescript -InputPath $env:GITHUB_WORKSPACE -ErrorVariable pipeScriptBuildErrors)
if ($pipeScriptBuildErrors) {
$pipeScriptBuildErrors
exit 1
} else {
$buildOutputFiles |
. $processScriptOutput |
Out-Host
}
}



$BuildPipeScriptEnd = [DateTime]::Now
$BuildPipeScriptTook = $BuildPipeScriptEnd - $BuildPipeScriptStart
"::notice title=PipeScriptFilesBuiltCount::$($buildOutputFiles.Length)" | Out-Host
"::notice title=PipeScriptFilesBuilt::$($buildOutputFiles -join ';')" | Out-Host
"::notice title=PipeScriptBuildRuntime::$($BuildPipeScriptTook.TotalMilliseconds)" | Out-Host
"::notice:: Build-PipeScript ran in $($BuildPipeScriptTook.TotalSeconds) seconds" | Out-Host
"::group::$($buildOutputFiles.Length) files built in $($BuildPipeScriptTook.TotalSeconds) seconds" |
Out-Host

@(
$buildOutputFiles | Select-Object -ExpandProperty Fullname
) -join [Environment]::newLine | Out-Host

"::endgroup::" | Out-Host
if ($CommitMessage -or $anyFilesChanged) {
if ($CommitMessage) {
Get-ChildItem $env:GITHUB_WORKSPACE -Recurse |
Expand Down
9 changes: 5 additions & 4 deletions Join-PipeScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ function Join-PipeScript
$blocks = @($AllScriptBlocks.Ast.EndBlock)
if ($blocks -ne $null) {
$blockOpen = $false # see if there was anything in them.

$unnamedBlocks = @($blocks.Unnamed)
foreach ($block in $blocks) {
if (-not $block) { continue }
# Empty(ish) scripts may have an end bock that is an empty param block
Expand All @@ -424,11 +424,12 @@ function Join-PipeScript
$blockOpen = $true
} elseif ($block.Statements.Count) {
# where as if it is a series of statements, it doesn't necessarily need to be.
# Unless it's the first block and it's unnamed.
if ($block.Unnamed -and -not $blockOpen) {
# Unless it's the first block and it's unnamed, and other blocks are named.
if ($block.Unnamed -and -not $blockOpen -and
$unnamedBlocks.Length -ne $blocks.Length) {
' ' * ($block | MeasureIndent) + 'end {'
$blockOpen = $true
$closeEndBlock = $true
$closeEndBlock = $false
}
if ($StatementsToAdd) {
$StatementsToAdd -join [Environment]::NewLine
Expand Down
2 changes: 2 additions & 0 deletions ListOfTranspilers.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ These are all of the transpilers currently included in PipeScript:
|[CPlusPlus.Template](Transpilers/Templates/CPlusPlus.Template.psx.ps1) |C/C++ Template Transpiler. |
|[CSharp.Template](Transpilers/Templates/CSharp.Template.psx.ps1) |C# Template Transpiler. |
|[CSS.Template](Transpilers/Templates/CSS.Template.psx.ps1) |CSS Template Transpiler. |
|[Dart.Template](Transpilers/Templates/Dart.Template.psx.ps1) |Dart Template Transpiler. |
|[Decorate](Transpilers/Decorate.psx.ps1) |decorate transpiler |
|[Define](Transpilers/Define.psx.ps1) |Defines a variable |
|[Dot](Transpilers/Syntax/Dot.psx.ps1) |Dot Notation |
Expand Down Expand Up @@ -78,6 +79,7 @@ These are all of the transpilers currently included in PipeScript:
|[RSS.Template](Transpilers/Templates/RSS.Template.psx.ps1) |RSS Template Transpiler. |
|[Ruby.Template](Transpilers/Templates/Ruby.Template.psx.ps1) |Ruby Template Transpiler. |
|[Rust.Template](Transpilers/Templates/Rust.Template.psx.ps1) |Rust Template Transpiler. |
|[Scala.Template](Transpilers/Templates/Scala.Template.psx.ps1) |Scala Template Transpiler. |
|[SQL.Template](Transpilers/Templates/SQL.Template.psx.ps1) |SQL Template Transpiler. |
|[TCL.Template](Transpilers/Templates/TCL.Template.psx.ps1) |TCL/TK Template Transpiler. |
|[TOML.Template](Transpilers/Templates/TOML.Template.psx.ps1) |TOML Template Transpiler. |
Expand Down
2 changes: 1 addition & 1 deletion New-PipeScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
"$functionType $FunctionName {"
} elseif ($FunctionName) {
# Otherwise, we declare it as a command namespace
"$functionName function $functionName {"
"$functionType function $functionName {"
# (which means we have to transpile).
$NoTranspile = $false
}
Expand Down
2 changes: 1 addition & 1 deletion New-PipeScript.ps1.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
"$functionType $FunctionName {"
} elseif ($FunctionName) {
# Otherwise, we declare it as a command namespace
"$functionName function $functionName {"
"$functionType function $functionName {"
# (which means we have to transpile).
$NoTranspile = $false
}
Expand Down
88 changes: 22 additions & 66 deletions PipeScript.ps.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '0.2.3'
ModuleVersion = '0.2.4'
Description = 'An Extensible Transpiler for PowerShell (and anything else)'
RootModule = 'PipeScript.psm1'
PowerShellVersion = '4.0'
Expand Down Expand Up @@ -43,72 +43,28 @@ PipeScript files.
BuildModule = @('EZOut','Piecemeal','PipeScript','HelpOut', 'PSDevOps')
Tags = 'PipeScript','PowerShell', 'Transpilation', 'Compiler'
ReleaseNotes = @'
## PipeScript 0.2.3:
## PipeScript 0.2.4:
### New Features:
* Added Import-PipeScript (Fixes #366)
* Generating 'PipeScript.Imported' event on Import (#371)
* Functions and Aliases can now be created in namespaces (#329 and #334)
* Functions are imported as they are defined (#360)
* Transpilers can be defined in the PipeScript.Transpiler namespace
* _You can now declare a transpiler and use it in the next line!_
* Partial Functions (#369)
* Conditional Keywords (#374) ( You can now `break if ($false)` / `continue if ($false)`)
### Extended Type Improvements
* Vastly Extending [CommandInfo] (Making PowerShell commands much more capable)
* Properties
* .BlockComments (Fixes #343)
* .Category (Fixes #344)
* .CommandNamespace (Fixes #335)
* .CommandMetadata (#351)
* .Description (#346)
* .FullyQualifiedName (#339)
* .Examples (#348)
* .Links (#349)
* .Metadata (#341)
* .Rank/Order (Fixes #345)
* .Synopsis (#347)
* .Separator (get/set) (#337, #338)
* Methods
* .CouldPipe() (#356)
* .CouldPipeType() (#359)
* .CouldRun (#357)
* .GetHelpField (Fixes #342)
* .IsParameterValid() (#358)
* .Validate() (#355)
* Application/ExternalScriptInfo: get/set.Root (#340)
* .Namespace alias for non-Cmdlet CommandInfo (Fixes #335)
### Templating Improvements
* SQL Transpiler: Allowing Multiline Comments (Fixes #367)
* Adding Arduino Template (Fixes #308)
* Allowing Markdown Transpiler to Template Text (Fixes #352)
### Command Changes
* New-PipeScript
* Aliasing -FunctionType to -Function/CommandNamespace (Fixes #372)
* Transpiling content unless -NoTranspile is passed (Fixes #370)
* Allowing -Parameter dictionaries to contain dictionaries (Fixes #311)
* Join-PipeScript
* Adding -Indent (Fixes #365)
* Improving Unnamed end block behavior (Fixes #363)
* Invoke-PipeScript:
* Adding -OutputPath (Fixes #375)
### Action Improvements
* GitHub Action Now supports -InstallModule (Fixes #353)
* Using notices instead of set-output
### Minor Changes
* Allowing alias inheritance (Fixes #364)
* PipeScript.FunctionDefinition: Supporting Inline Parameters (Fixes #354)
* Conditional Keywords now support throw/return (#389/#388) (also, fixed #387)
* Updating action: checking for _all_ build errors before outputting (#378)
* Command Updates
* New-PipeScript: Fixing Typed function creation (Fixes #372)
* Join-PipeScript: Fixing End Block Behavior (Fixes #383)
* Templating Improvements:
* New Languages Supported:
* DART (#394)
* SCALA (#395)
* Markdown Template Transpiler now has a more terse format (#393).
* Markdown Template Transpiler now supports embedding in HTML comments or CSS/JavaScript comments (#113).
* JSON/JavaScript Template: Converting Output to JSON if not [string] (#382)
* CSS Template Template : now Outputting Objects as CSS rules (Fixes #332)
* Core Template Transpiler is Faster (#392) and ForeachObject is improved (#390)
* Other Improvements
* Include transpiler: Adding -Passthru (Fixes #385)
* Making validation for various transpilers more careful (Fixes #381)
* CommandNotFound behavior: Limiting recursion (Fixes #380)
* Core Transpiler: Improving Efficiency (Fixes #379)
* Requires allows clobbering and forces loads (Fixes #386)
---
Expand Down
14 changes: 14 additions & 0 deletions PipeScript.ps1.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,22 @@ $global:ExecutionContext.SessionState.InvokeCommand.CommandNotFoundAction = {
# Rather than be the only thing that can handle command not found, we start by broadcasting an event.
New-Event -SourceIdentifier "PowerShell.CommandNotFound" -MessageData $notFoundArgs -Sender $global:ExecutionContext -EventArguments $notFoundArgs

# Then we determine our own script block.
$myScriptBlock = $MyInvocation.MyCommand.ScriptBlock
# Then, we do a bit of callstack peeking
$callstack = @(Get-PSCallStack)
$myCallCount = 0
foreach ($call in $callstack) {
if ($call.InvocationInfo.MyCommand.ScriptBlock -eq $myScriptBlock) {
$myCallCount++
}
}

# If we're being called more than once
if ($myCallCount -gt 1) {
return # we're done.
}

$callstackPeek = $callstack[-1]
# When peeking in on a dynamic script block, the offsets may lie.
$column = [Math]::Max($callstackPeek.InvocationInfo.OffsetInLine, 1)
Expand Down
Loading

0 comments on commit 24a0165

Please sign in to comment.