Skip to content

Commit ace7a57

Browse files
Merge pull request #300 from StartAutomating/PipeScriptFixesAndFun
PipeScript 0.2.1
2 parents cfc479d + 249a430 commit ace7a57

File tree

101 files changed

+867
-3719
lines changed

Some content is hidden

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

101 files changed

+867
-3719
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 0.2.1:
2+
3+
* Adding preliminary 'define' transpiler (Fixes #299)
4+
* Improving interactive templates (now supported for all languages) (Fixes #285)
5+
* Fixing sequence dotting within non-statements (Fixes #298)
6+
* Allow multiple transpiler outputs to update nearby context (Fixes #297)
7+
* No longer expanding Regex Literals in attributes (Fixes #290)
8+
9+
---
10+
111
## 0.2:
212

313
* Massive Improvements in Templating

Get-PipeScript.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region Piecemeal [ 0.3.5 ] : Easy Extensible Plugins for PowerShell
1+
#region Piecemeal [ 0.3.6 ] : 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'
@@ -602,11 +602,20 @@ function Get-PipeScript
602602
$params = @{}
603603
$mappedParams = [Ordered]@{} # Create a collection of mapped parameters
604604
# Walk thru each parameter of this command
605-
foreach ($myParam in $paramSet.Parameters) {
605+
:nextParameter foreach ($myParam in $paramSet.Parameters) {
606606
# If the parameter is ValueFromPipeline
607607
if ($myParam.ValueFromPipeline) {
608+
$potentialPSTypeNames = @($myParam.Attributes.PSTypeName) -ne ''
609+
if ($potentialPSTypeNames) {
610+
foreach ($potentialTypeName in $potentialPSTypeNames) {
611+
if ($potentialTypeName -and $InputObject.pstypenames -contains $potentialTypeName) {
612+
$mappedParams[$myParam.Name] = $params[$myParam.Name] = $InputObject
613+
continue nextParameter
614+
}
615+
}
616+
}
608617
# and we have an input object
609-
if ($null -ne $inputObject -and
618+
elseif ($null -ne $inputObject -and
610619
(
611620
# of the exact type
612621
$myParam.ParameterType -eq $inputObject.GetType() -or
@@ -925,5 +934,5 @@ function Get-PipeScript
925934
}
926935
}
927936
}
928-
#endregion Piecemeal [ 0.3.5 ] : Easy Extensible Plugins for PowerShell
937+
#endregion Piecemeal [ 0.3.6 ] : Easy Extensible Plugins for PowerShell
929938

Get-Transpiler.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region Piecemeal [ 0.3.5 ] : Easy Extensible Plugins for PowerShell
1+
#region Piecemeal [ 0.3.6 ] : 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'
@@ -602,11 +602,20 @@ function Get-Transpiler
602602
$params = @{}
603603
$mappedParams = [Ordered]@{} # Create a collection of mapped parameters
604604
# Walk thru each parameter of this command
605-
foreach ($myParam in $paramSet.Parameters) {
605+
:nextParameter foreach ($myParam in $paramSet.Parameters) {
606606
# If the parameter is ValueFromPipeline
607607
if ($myParam.ValueFromPipeline) {
608+
$potentialPSTypeNames = @($myParam.Attributes.PSTypeName) -ne ''
609+
if ($potentialPSTypeNames) {
610+
foreach ($potentialTypeName in $potentialPSTypeNames) {
611+
if ($potentialTypeName -and $InputObject.pstypenames -contains $potentialTypeName) {
612+
$mappedParams[$myParam.Name] = $params[$myParam.Name] = $InputObject
613+
continue nextParameter
614+
}
615+
}
616+
}
608617
# and we have an input object
609-
if ($null -ne $inputObject -and
618+
elseif ($null -ne $inputObject -and
610619
(
611620
# of the exact type
612621
$myParam.ParameterType -eq $inputObject.GetType() -or
@@ -925,5 +934,5 @@ function Get-Transpiler
925934
}
926935
}
927936
}
928-
#endregion Piecemeal [ 0.3.5 ] : Easy Extensible Plugins for PowerShell
937+
#endregion Piecemeal [ 0.3.6 ] : Easy Extensible Plugins for PowerShell
929938

ListOfTranspilers.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ These are all of the transpilers currently included in PipeScript:
2121
|[CSharp.Template](Transpilers/Templates/CSharp.Template.psx.ps1) |C# Template Transpiler. |
2222
|[CSS.Template](Transpilers/Templates/CSS.Template.psx.ps1) |CSS Template Transpiler. |
2323
|[Decorate](Transpilers/Decorate.psx.ps1) |decorate transpiler |
24+
|[Define](Transpilers/Define.psx.ps1) |Defines a variable |
2425
|[Dot](Transpilers/Syntax/Dot.psx.ps1) |Dot Notation |
2526
|[EqualityComparison](Transpilers/Syntax/EqualityComparison.psx.ps1) |Allows equality comparison. |
2627
|[EqualityTypeComparison](Transpilers/Syntax/EqualityTypeComparison.psx.ps1) |Allows equality type comparison. |

PipeScript.Piecemeal.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#require -Module Piecemeal
22
Push-Location $PSScriptRoot
33

4-
Install-Piecemeal -ExtensionNoun 'Transpiler' -ExtensionPattern '\.psx\.ps1$' -ExtensionTypeName 'PipeScript.Transpiler' -OutputPath '.\Get-Transpiler.ps1'
5-
Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$' -ExtensionTypeName 'PipeScript' -OutputPath '.\Get-PipeScript.ps1'
4+
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
6+
Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$' -ExtensionTypeName 'PipeScript' -OutputPath '.\Get-PipeScript.ps1' |
7+
Add-Member Noteproperty CommitMessage "Get-PipeScript: Updating Piecemeal Version" -Force -PassThru
68

79

810
Pop-Location

PipeScript.ps.psd1

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.2'
2+
ModuleVersion = '0.2.1'
33
Description = 'An Extensible Transpiler for PowerShell (and anything else)'
44
RootModule = 'PipeScript.psm1'
55
PowerShellVersion = '4.0'
@@ -25,19 +25,13 @@
2525
BuildModule = @('EZOut','Piecemeal','PipeScript','HelpOut', 'PSDevOps')
2626
Tags = 'PipeScript','PowerShell', 'Transpilation', 'Compiler'
2727
ReleaseNotes = @'
28-
## 0.2:
28+
## 0.2.1:
2929
30-
* Massive Improvements in Templating
31-
* Templates can be used interactively (Fixes #285)
32-
* Renaming all Inline Transpilers to Template Transpilers
33-
* Natural Parsing Improvements
34-
* ArrayLiterals are expanded (Fixes #291)
35-
* AsSentence now only allows one value into a singleton (Fixes #279)
36-
* Not expanding expandable strings (Fixes #286)
37-
* Transpilers can change nearby context (Fixes #292)
38-
* Allowing dot syntax to extend across multiple statements (Fixes #273)
39-
* Adding requires keyword (Fixes #293)
40-
* PipeScript modifies its own manifest (Fixes #294)
30+
* Adding preliminary 'define' transpiler (Fixes #299)
31+
* Improving interactive templates (now supported for all languages) (Fixes #285)
32+
* Fixing sequence dotting within non-statements (Fixes #298)
33+
* Allow multiple transpiler outputs to update nearby context (Fixes #297)
34+
* No longer expanding Regex Literals in attributes (Fixes #290)
4135
4236
---
4337

PipeScript.psd1

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.2'
2+
ModuleVersion = '0.2.1'
33
Description = 'An Extensible Transpiler for PowerShell (and anything else)'
44
RootModule = 'PipeScript.psm1'
55
PowerShellVersion = '4.0'
@@ -20,19 +20,13 @@
2020
BuildModule = @('EZOut','Piecemeal','PipeScript','HelpOut', 'PSDevOps')
2121
Tags = 'PipeScript','PowerShell', 'Transpilation', 'Compiler'
2222
ReleaseNotes = @'
23-
## 0.2:
23+
## 0.2.1:
2424
25-
* Massive Improvements in Templating
26-
* Templates can be used interactively (Fixes #285)
27-
* Renaming all Inline Transpilers to Template Transpilers
28-
* Natural Parsing Improvements
29-
* ArrayLiterals are expanded (Fixes #291)
30-
* AsSentence now only allows one value into a singleton (Fixes #279)
31-
* Not expanding expandable strings (Fixes #286)
32-
* Transpilers can change nearby context (Fixes #292)
33-
* Allowing dot syntax to extend across multiple statements (Fixes #273)
34-
* Adding requires keyword (Fixes #293)
35-
* PipeScript modifies its own manifest (Fixes #294)
25+
* Adding preliminary 'define' transpiler (Fixes #299)
26+
* Improving interactive templates (now supported for all languages) (Fixes #285)
27+
* Fixing sequence dotting within non-statements (Fixes #298)
28+
* Allow multiple transpiler outputs to update nearby context (Fixes #297)
29+
* No longer expanding Regex Literals in attributes (Fixes #290)
3630
3731
---
3832

Transpilers/Core/PipeScript.Template.psx.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ process {
419419
}
420420

421421
if (-not (Test-Path $Name)) {
422-
$null = New-Item -ItemType $file -Path $name -Force
422+
$null = New-Item -ItemType File -Path $name -Force
423423
}
424424
$evaluated | Set-Content -Path $name
425425
Get-Item -Path $name

Transpilers/Core/Pipescript.psx.ps1

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -268,60 +268,63 @@ process {
268268
$start = $scriptText.IndexOf($item.Extent.Text, $myOffset)
269269
$end = $start + $item.Extent.Text.Length
270270
$skipUntil = $end # set SkipUntil
271-
$AstReplacements[$item] = $pso # and store the replacement.
271+
$AstReplacements[$item] = $pso # and store the replacement.
272+
}
273+
274+
#region Special Properties
272275

273-
#region Special Properties
274-
# Because PowerShell can attach properties to any object,
275-
# we can use the presence of attached properties to change context around the replacement.
276+
# Because PowerShell can attach properties to any object,
277+
# we can use the presence of attached properties to change context around the replacement.
278+
# This happens regardless of if there is already a replacement for the current item.
276279

277-
# .SkipUntil or .IgnoreUntil can specify a new index or AST end point
278-
foreach ($toSkipAlias in 'SkipUntil', 'IgnoreUntil') {
279-
foreach ($toSkipUntil in $pso.$toSkipAlias) {
280-
if ($toSkipUntil -is [int] -and $toSkipUntil -gt $end) {
281-
$skipUntil = $toSkipUntil
282-
} elseif ($toSkipUntil -is [Management.Automation.Language.Ast]) {
283-
$newSkipStart = $scriptText.IndexOf($toSkipUntil.Extent.Text, $myOffset)
284-
if ($newSkipStart -ne -1) {
285-
$end = $newSkipStart + $toSkipUntil.Extent.Text.Length
286-
if ($end -gt $skipUntil) {
287-
$skipUntil = $end
288-
}
289-
if ($toSkipUntil -ne $item) {
290-
$AstReplacements[$toSkipUntil] = ''
291-
}
280+
# .SkipUntil or .IgnoreUntil can specify a new index or AST end point
281+
foreach ($toSkipAlias in 'SkipUntil', 'IgnoreUntil') {
282+
foreach ($toSkipUntil in $pso.$toSkipAlias) {
283+
if ($toSkipUntil -is [int] -and $toSkipUntil -gt $end) {
284+
$skipUntil = $toSkipUntil
285+
} elseif ($toSkipUntil -is [Management.Automation.Language.Ast]) {
286+
$newSkipStart = $scriptText.IndexOf($toSkipUntil.Extent.Text, $myOffset)
287+
if ($newSkipStart -ne -1) {
288+
$end = $newSkipStart + $toSkipUntil.Extent.Text.Length
289+
if ($end -gt $skipUntil) {
290+
$skipUntil = $end
291+
}
292+
if ($toSkipUntil -ne $item) {
293+
$AstReplacements[$toSkipUntil] = ''
292294
}
293295
}
294296
}
295297
}
298+
}
296299

297-
#.ToRemove,.RemoveAST, or .RemoveElement will remove AST elements or ranges
298-
foreach ($toRemoveAlias in 'ToRemove','RemoveAST','RemoveElement') {
299-
foreach ($toRemove in $pso.$toRemoveAlias) {
300-
if ($toRemove -is [Management.Automation.Language.Ast]) {
301-
$AstReplacements[$toRemove] = ''
302-
} elseif ($toRemove -match '^\d+,\d+$') {
303-
$Replacements[$toRemove] = ''
304-
}
300+
#.ToRemove,.RemoveAST, or .RemoveElement will remove AST elements or ranges
301+
foreach ($toRemoveAlias in 'ToRemove','RemoveAST','RemoveElement') {
302+
foreach ($toRemove in $pso.$toRemoveAlias) {
303+
if ($toRemove -is [Management.Automation.Language.Ast]) {
304+
$AstReplacements[$toRemove] = ''
305+
} elseif ($toRemove -match '^\d+,\d+$') {
306+
$Replacements[$toRemove] = ''
305307
}
306308
}
309+
}
307310

308-
#.ToReplace,.ReplaceAST or .ReplaceElement will replace elements or ranges.
309-
foreach ($toReplaceAlias in 'ToReplace','ReplaceAST','ReplaceElement') {
310-
foreach ($toReplace in $pso.$toReplaceAlias) {
311-
if ($toReplace -isnot [Collections.IDictionary]) {
312-
continue
313-
}
314-
foreach ($tr in $toReplace.GetEnumerator()) {
315-
if ($tr.Key -is [Management.Automaton.Language.Ast]) {
316-
$AstReplacements[$tr.Key] = $tr.Value
317-
} elseif ($tr.Key -match '^\d+,\d+$') {
318-
$textReplacements["$($tr.Key)"] = $tr.Value
319-
}
311+
#.ToReplace,.ReplaceAST or .ReplaceElement will replace elements or ranges.
312+
foreach ($toReplaceAlias in 'ToReplace','ReplaceAST','ReplaceElement') {
313+
foreach ($toReplace in $pso.$toReplaceAlias) {
314+
if ($toReplace -isnot [Collections.IDictionary]) {
315+
continue
316+
}
317+
foreach ($tr in $toReplace.GetEnumerator()) {
318+
if ($tr.Key -is [Management.Automaton.Language.Ast]) {
319+
$AstReplacements[$tr.Key] = $tr.Value
320+
} elseif ($tr.Key -match '^\d+,\d+$') {
321+
$textReplacements["$($tr.Key)"] = $tr.Value
320322
}
321323
}
322324
}
323-
#endregion Special Properties
324325
}
326+
#endregion Special Properties
327+
325328
}
326329
# If the transpiler had output, do not process any more transpilers.
327330
if ($pipeScriptOutput) { break }

0 commit comments

Comments
 (0)