Skip to content

Commit 24a0165

Browse files
Merge pull request #396 from StartAutomating/PipeScript-Updates
PipeScript 0.2.4
2 parents eac48f7 + a246df2 commit 24a0165

File tree

143 files changed

+1066
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+1066
-416
lines changed

.github/workflows/TestAndPublish.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,14 @@ jobs:
581581
id: PSSVG
582582
- name: UsePiecemeal
583583
uses: StartAutomating/Piecemeal@main
584-
- name: BuildPipeScript
584+
- name: Run PipeScript (from main)
585+
if: ${{github.ref_name == 'main'}}
585586
uses: StartAutomating/PipeScript@main
587+
id: PipeScriptMain
588+
- name: Run PipeScript (on branch)
589+
if: ${{github.ref_name != 'main'}}
590+
uses: ./
591+
id: PipeScriptBranch
586592
- name: UseEZOut
587593
uses: StartAutomating/EZOut@master
588594
- name: UseHelpOut

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
## PipeScript 0.2.4:
2+
3+
* Conditional Keywords now support throw/return (#389/#388) (also, fixed #387)
4+
* Updating action: checking for _all_ build errors before outputting (#378)
5+
* Command Updates
6+
* New-PipeScript: Fixing Typed function creation (Fixes #372)
7+
* Join-PipeScript: Fixing End Block Behavior (Fixes #383)
8+
* Templating Improvements:
9+
* New Languages Supported:
10+
* DART (#394)
11+
* SCALA (#395)
12+
* Markdown Template Transpiler now has a more terse format (#393).
13+
* Markdown Template Transpiler now supports embedding in HTML comments or CSS/JavaScript comments (#113).
14+
* JSON/JavaScript Template: Converting Output to JSON if not [string] (#382)
15+
* CSS Template Template : now Outputting Objects as CSS rules (Fixes #332)
16+
* Core Template Transpiler is Faster (#392) and ForeachObject is improved (#390)
17+
* Other Improvements
18+
* Include transpiler: Adding -Passthru (Fixes #385)
19+
* Making validation for various transpilers more careful (Fixes #381)
20+
* CommandNotFound behavior: Limiting recursion (Fixes #380)
21+
* Core Transpiler: Improving Efficiency (Fixes #379)
22+
* Requires allows clobbering and forces loads (Fixes #386)
23+
24+
---
25+
126
## PipeScript 0.2.3:
227

328
### New Features:

Github/Actions/PipeScriptAction.ps1

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $CommitMessage,
3131

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

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

59+
# Set -ErrorActionPreference to continue.
60+
$global:ErrorActionPreference = 'continue'
61+
5962
#region -InstallModule
6063
if ($InstallModule) {
6164
"::group::Installing Modules" | Out-Host
@@ -66,7 +69,7 @@ if ($InstallModule) {
6669
$(Get-Content $_.FullName -Raw) -match 'ModuleVersion'
6770
}
6871
if (-not $moduleInWorkspace) {
69-
Install-Module $moduleToInstall -Scope CurrentUser -Force
72+
Install-Module $moduleToInstall -Scope CurrentUser -Force -AllowClobber
7073
Import-Module $moduleToInstall -Force -PassThru | Out-Host
7174
}
7275
}
@@ -155,21 +158,35 @@ if ($PipeScript) {
155158
}
156159

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

160163
$BuildPipeScriptStart = [DateTime]::Now
161164
if (-not $SkipBuild) {
162-
$buildOutputFiles = @(Build-Pipescript -InputPath $env:GITHUB_WORKSPACE)
163-
$buildOutputFiles |
164-
. $processScriptOutput |
165-
Out-Host
165+
$pipeScriptBuildErrors = $null
166+
$buildOutputFiles = @(Build-Pipescript -InputPath $env:GITHUB_WORKSPACE -ErrorVariable pipeScriptBuildErrors)
167+
if ($pipeScriptBuildErrors) {
168+
$pipeScriptBuildErrors
169+
exit 1
170+
} else {
171+
$buildOutputFiles |
172+
. $processScriptOutput |
173+
Out-Host
174+
}
166175
}
167176

177+
178+
168179
$BuildPipeScriptEnd = [DateTime]::Now
169180
$BuildPipeScriptTook = $BuildPipeScriptEnd - $BuildPipeScriptStart
170-
"::notice title=PipeScriptFilesBuiltCount::$($buildOutputFiles.Length)" | Out-Host
171-
"::notice title=PipeScriptFilesBuilt::$($buildOutputFiles -join ';')" | Out-Host
172-
"::notice title=PipeScriptBuildRuntime::$($BuildPipeScriptTook.TotalMilliseconds)" | Out-Host
181+
"::notice:: Build-PipeScript ran in $($BuildPipeScriptTook.TotalSeconds) seconds" | Out-Host
182+
"::group::$($buildOutputFiles.Length) files built in $($BuildPipeScriptTook.TotalSeconds) seconds" |
183+
Out-Host
184+
185+
@(
186+
$buildOutputFiles | Select-Object -ExpandProperty Fullname
187+
) -join [Environment]::newLine | Out-Host
188+
189+
"::endgroup::" | Out-Host
173190
if ($CommitMessage -or $anyFilesChanged) {
174191
if ($CommitMessage) {
175192
Get-ChildItem $env:GITHUB_WORKSPACE -Recurse |

Join-PipeScript.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ function Join-PipeScript
406406
$blocks = @($AllScriptBlocks.Ast.EndBlock)
407407
if ($blocks -ne $null) {
408408
$blockOpen = $false # see if there was anything in them.
409-
409+
$unnamedBlocks = @($blocks.Unnamed)
410410
foreach ($block in $blocks) {
411411
if (-not $block) { continue }
412412
# Empty(ish) scripts may have an end bock that is an empty param block
@@ -424,11 +424,12 @@ function Join-PipeScript
424424
$blockOpen = $true
425425
} elseif ($block.Statements.Count) {
426426
# where as if it is a series of statements, it doesn't necessarily need to be.
427-
# Unless it's the first block and it's unnamed.
428-
if ($block.Unnamed -and -not $blockOpen) {
427+
# Unless it's the first block and it's unnamed, and other blocks are named.
428+
if ($block.Unnamed -and -not $blockOpen -and
429+
$unnamedBlocks.Length -ne $blocks.Length) {
429430
' ' * ($block | MeasureIndent) + 'end {'
430431
$blockOpen = $true
431-
$closeEndBlock = $true
432+
$closeEndBlock = $false
432433
}
433434
if ($StatementsToAdd) {
434435
$StatementsToAdd -join [Environment]::NewLine

ListOfTranspilers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ These are all of the transpilers currently included in PipeScript:
2222
|[CPlusPlus.Template](Transpilers/Templates/CPlusPlus.Template.psx.ps1) |C/C++ Template Transpiler. |
2323
|[CSharp.Template](Transpilers/Templates/CSharp.Template.psx.ps1) |C# Template Transpiler. |
2424
|[CSS.Template](Transpilers/Templates/CSS.Template.psx.ps1) |CSS Template Transpiler. |
25+
|[Dart.Template](Transpilers/Templates/Dart.Template.psx.ps1) |Dart Template Transpiler. |
2526
|[Decorate](Transpilers/Decorate.psx.ps1) |decorate transpiler |
2627
|[Define](Transpilers/Define.psx.ps1) |Defines a variable |
2728
|[Dot](Transpilers/Syntax/Dot.psx.ps1) |Dot Notation |
@@ -78,6 +79,7 @@ These are all of the transpilers currently included in PipeScript:
7879
|[RSS.Template](Transpilers/Templates/RSS.Template.psx.ps1) |RSS Template Transpiler. |
7980
|[Ruby.Template](Transpilers/Templates/Ruby.Template.psx.ps1) |Ruby Template Transpiler. |
8081
|[Rust.Template](Transpilers/Templates/Rust.Template.psx.ps1) |Rust Template Transpiler. |
82+
|[Scala.Template](Transpilers/Templates/Scala.Template.psx.ps1) |Scala Template Transpiler. |
8183
|[SQL.Template](Transpilers/Templates/SQL.Template.psx.ps1) |SQL Template Transpiler. |
8284
|[TCL.Template](Transpilers/Templates/TCL.Template.psx.ps1) |TCL/TK Template Transpiler. |
8385
|[TOML.Template](Transpilers/Templates/TOML.Template.psx.ps1) |TOML Template Transpiler. |

New-PipeScript.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
505505
"$functionType $FunctionName {"
506506
} elseif ($FunctionName) {
507507
# Otherwise, we declare it as a command namespace
508-
"$functionName function $functionName {"
508+
"$functionType function $functionName {"
509509
# (which means we have to transpile).
510510
$NoTranspile = $false
511511
}

New-PipeScript.ps1.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
487487
"$functionType $FunctionName {"
488488
} elseif ($FunctionName) {
489489
# Otherwise, we declare it as a command namespace
490-
"$functionName function $functionName {"
490+
"$functionType function $functionName {"
491491
# (which means we have to transpile).
492492
$NoTranspile = $false
493493
}

PipeScript.ps.psd1

Lines changed: 22 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.2.3'
2+
ModuleVersion = '0.2.4'
33
Description = 'An Extensible Transpiler for PowerShell (and anything else)'
44
RootModule = 'PipeScript.psm1'
55
PowerShellVersion = '4.0'
@@ -43,72 +43,28 @@ PipeScript files.
4343
BuildModule = @('EZOut','Piecemeal','PipeScript','HelpOut', 'PSDevOps')
4444
Tags = 'PipeScript','PowerShell', 'Transpilation', 'Compiler'
4545
ReleaseNotes = @'
46-
## PipeScript 0.2.3:
46+
## PipeScript 0.2.4:
4747
48-
### New Features:
49-
50-
* Added Import-PipeScript (Fixes #366)
51-
* Generating 'PipeScript.Imported' event on Import (#371)
52-
* Functions and Aliases can now be created in namespaces (#329 and #334)
53-
* Functions are imported as they are defined (#360)
54-
* Transpilers can be defined in the PipeScript.Transpiler namespace
55-
* _You can now declare a transpiler and use it in the next line!_
56-
* Partial Functions (#369)
57-
* Conditional Keywords (#374) ( You can now `break if ($false)` / `continue if ($false)`)
58-
59-
### Extended Type Improvements
60-
61-
* Vastly Extending [CommandInfo] (Making PowerShell commands much more capable)
62-
* Properties
63-
* .BlockComments (Fixes #343)
64-
* .Category (Fixes #344)
65-
* .CommandNamespace (Fixes #335)
66-
* .CommandMetadata (#351)
67-
* .Description (#346)
68-
* .FullyQualifiedName (#339)
69-
* .Examples (#348)
70-
* .Links (#349)
71-
* .Metadata (#341)
72-
* .Rank/Order (Fixes #345)
73-
* .Synopsis (#347)
74-
* .Separator (get/set) (#337, #338)
75-
* Methods
76-
* .CouldPipe() (#356)
77-
* .CouldPipeType() (#359)
78-
* .CouldRun (#357)
79-
* .GetHelpField (Fixes #342)
80-
* .IsParameterValid() (#358)
81-
* .Validate() (#355)
82-
* Application/ExternalScriptInfo: get/set.Root (#340)
83-
* .Namespace alias for non-Cmdlet CommandInfo (Fixes #335)
84-
85-
### Templating Improvements
86-
87-
* SQL Transpiler: Allowing Multiline Comments (Fixes #367)
88-
* Adding Arduino Template (Fixes #308)
89-
* Allowing Markdown Transpiler to Template Text (Fixes #352)
90-
91-
### Command Changes
92-
93-
* New-PipeScript
94-
* Aliasing -FunctionType to -Function/CommandNamespace (Fixes #372)
95-
* Transpiling content unless -NoTranspile is passed (Fixes #370)
96-
* Allowing -Parameter dictionaries to contain dictionaries (Fixes #311)
97-
* Join-PipeScript
98-
* Adding -Indent (Fixes #365)
99-
* Improving Unnamed end block behavior (Fixes #363)
100-
* Invoke-PipeScript:
101-
* Adding -OutputPath (Fixes #375)
102-
103-
### Action Improvements
104-
105-
* GitHub Action Now supports -InstallModule (Fixes #353)
106-
* Using notices instead of set-output
107-
108-
### Minor Changes
109-
110-
* Allowing alias inheritance (Fixes #364)
111-
* PipeScript.FunctionDefinition: Supporting Inline Parameters (Fixes #354)
48+
* Conditional Keywords now support throw/return (#389/#388) (also, fixed #387)
49+
* Updating action: checking for _all_ build errors before outputting (#378)
50+
* Command Updates
51+
* New-PipeScript: Fixing Typed function creation (Fixes #372)
52+
* Join-PipeScript: Fixing End Block Behavior (Fixes #383)
53+
* Templating Improvements:
54+
* New Languages Supported:
55+
* DART (#394)
56+
* SCALA (#395)
57+
* Markdown Template Transpiler now has a more terse format (#393).
58+
* Markdown Template Transpiler now supports embedding in HTML comments or CSS/JavaScript comments (#113).
59+
* JSON/JavaScript Template: Converting Output to JSON if not [string] (#382)
60+
* CSS Template Template : now Outputting Objects as CSS rules (Fixes #332)
61+
* Core Template Transpiler is Faster (#392) and ForeachObject is improved (#390)
62+
* Other Improvements
63+
* Include transpiler: Adding -Passthru (Fixes #385)
64+
* Making validation for various transpilers more careful (Fixes #381)
65+
* CommandNotFound behavior: Limiting recursion (Fixes #380)
66+
* Core Transpiler: Improving Efficiency (Fixes #379)
67+
* Requires allows clobbering and forces loads (Fixes #386)
11268
11369
---
11470

PipeScript.ps1.psm1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,22 @@ $global:ExecutionContext.SessionState.InvokeCommand.CommandNotFoundAction = {
3131
# Rather than be the only thing that can handle command not found, we start by broadcasting an event.
3232
New-Event -SourceIdentifier "PowerShell.CommandNotFound" -MessageData $notFoundArgs -Sender $global:ExecutionContext -EventArguments $notFoundArgs
3333

34+
# Then we determine our own script block.
35+
$myScriptBlock = $MyInvocation.MyCommand.ScriptBlock
3436
# Then, we do a bit of callstack peeking
3537
$callstack = @(Get-PSCallStack)
38+
$myCallCount = 0
39+
foreach ($call in $callstack) {
40+
if ($call.InvocationInfo.MyCommand.ScriptBlock -eq $myScriptBlock) {
41+
$myCallCount++
42+
}
43+
}
44+
45+
# If we're being called more than once
46+
if ($myCallCount -gt 1) {
47+
return # we're done.
48+
}
49+
3650
$callstackPeek = $callstack[-1]
3751
# When peeking in on a dynamic script block, the offsets may lie.
3852
$column = [Math]::Max($callstackPeek.InvocationInfo.OffsetInLine, 1)

0 commit comments

Comments
 (0)