Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c42830e
Updating until transpiler (supporting #153)
Jul 30, 2022
1820472
Updating until transpiler (supporting #153)
Jul 30, 2022
e31c40d
Updating until transpiler (supporting #153)
Jul 30, 2022
377fa10
Updating until transpiler (supporting #153)
Jul 30, 2022
a2c51f5
Updating until transpiler (supporting #153)
Jul 30, 2022
0e60907
Adding CommandAst.ResolvedCommand (#157)
Jul 30, 2022
e0f0b50
Adding VariableExpressionAst.GetAssignments() (#155)
Jul 30, 2022
ae450c8
Adding VariableExpressionAst.GetVariableType() (#156)
Jul 30, 2022
593a910
Adding VariableExpressionAst.GetVariableType() (#156)
Jul 30, 2022
ed1b745
Adding VariableExpressionAst.GetVariableType() (#156)
Jul 30, 2022
a1e9e58
Updating action (improving email determination) (#152)
Jul 30, 2022
2dbc6a8
Updating action (not running when there is not a current branch) (#158)
Jul 30, 2022
65c8847
Adding RemoveParameter transpiler (#159)
Jul 30, 2022
127d786
Adding RenameVariable Transpiler (#160)
Jul 31, 2022
f5fe735
Invoke-PipeScript: Fixing Typo related to generic arguments on typeco…
Jul 31, 2022
119a15c
Invoke-PipeScript: Terminating Transpiler Errors (#161)
Jul 31, 2022
7ca84fa
Adding AttributeAST get_ResolvedCommand (#162)
Jul 31, 2022
33750f7
Adding TypeConstraintAST get_ResolvedCommand (#162)
Jul 31, 2022
ec7463c
Adding TypeConstraintAST get_ResolvedCommand (#162)
Jul 31, 2022
6438897
Updating action (pulling just before push) (#163)
Jul 31, 2022
8f26a99
Updating action (pulling just before push) (#163)
Jul 31, 2022
b7c476b
Updating action (pulling just before push) (#163)
Jul 31, 2022
3c0054f
Updating action (pulling just before push) (#163)
Jul 31, 2022
3edc943
Updating action (pulling just before push) (#163)
Jul 31, 2022
504eb1a
Updating action (pulling just before push) (#163)
Jul 31, 2022
c1e6999
Merge branch 'PipeScriptEnhancements' of https://github.com/StartAuto…
Jul 31, 2022
e3b70ed
Updating 'new': Supporting Extended Types (#164)
Jul 31, 2022
2df46e3
Updating 'new': Supporting Extended Types (#164)
Jul 31, 2022
5f70bb2
Updating Module Version [0.0.14] and CHANGELOG
Jul 31, 2022
e60378b
Updating Module Version [0.0.14] and CHANGELOG
Jul 31, 2022
822a592
Updating Module Version [0.0.14] and CHANGELOG
Jul 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 0.0.14:
* New Transpilers:
* [RemoveParameter] (#159)
* [RenameVariable] (#160)
* Keyword Updates:
* new now supports extended type creation (#164)
* until now supports a TimeSpan, DateTime, or EventName string (#153)
* AST Extended Type Enhancements:
* [TypeConstraintAst] and [AttributeAst] now have .ResolvedCommand (#162)
* Action Updates
* Pulling just before push (#163)
* Not running when there is not a current branch (#158)
* Improving email determination (#156)
* Invoke-PipeScript terminates transpiler errors when run interactively (#161)
---

## 0.0.13:
* New / Improved Keywords
* assert keyword (Support for pipelines) (#143)
Expand Down
27 changes: 24 additions & 3 deletions Github/Actions/PipeScriptAction.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,30 @@ $processScriptOutput = { process {


if (-not $UserName) { $UserName = $env:GITHUB_ACTOR }
if (-not $UserEmail) { $UserEmail = "$UserName@github.com" }
if (-not $UserEmail) {
$GitHubUserEmail =
if ($env:GITHUB_TOKEN) {
Invoke-RestMethod -uri "https://api.github.com/user/emails" -Headers @{
Authorization = "token $env:GITHUB_TOKEN"
} |
Select-Object -First 1 -ExpandProperty email
} else {''}
$UserEmail =
if ($GitHubUserEmail) {
$GitHubUserEmail
} else {
"$UserName@github.com"
}
}
git config --global user.email $UserEmail
git config --global user.name $UserName

if (-not $env:GITHUB_WORKSPACE) { throw "No GitHub workspace" }

git pull | Out-Host
$branchName = git rev-parse --abrev-ref HEAD
if (-not $branchName) {
return
}

$PipeScriptStart = [DateTime]::Now
if ($PipeScript) {
Expand Down Expand Up @@ -143,11 +160,15 @@ if ($CommitMessage -or $anyFilesChanged) {

git commit -m $ExecutionContext.SessionState.InvokeCommand.ExpandString($CommitMessage)
}



$checkDetached = git symbolic-ref -q HEAD
if (-not $LASTEXITCODE) {
"::notice::Pulling Changes" | Out-Host
git pull | Out-Host
"::notice::Pushing Changes" | Out-Host
git push
git push | Out-Host
"Git Push Output: $($gitPushed | Out-String)"
} else {
"::notice::Not pushing changes (on detached head)" | Out-Host
Expand Down
26 changes: 23 additions & 3 deletions Invoke-PipeScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
if ($TypeName.IsGeneric) {
$TypeNameParams[$typeName.Name] =
$typeName.GenericArguments |
UnpackTypeConstraintArgs
TypeConstraintToArguments
} elseif (-not $TypeName.IsArray) {
$TypeNameArgs += $TypeName.Name
}
Expand Down Expand Up @@ -127,7 +127,7 @@


# If the command is a ```[ScriptBlock]```
if ($Command -is [scriptblock])
if ($Command -is [scriptblock])
{
# Attempt to transpile it.
$TranspiledScriptBlock = $Command | .>Pipescript @ErrorsAndWarnings
Expand All @@ -142,8 +142,28 @@
})
return
}

if ($TranspilerErrors) {
$failedMessage = @(
"$($command.Source): " + "$($TranspilerErrors.Count) error(s)"
if ($transpilerWarnings) {
"$($TranspilerWarnings.Count) warning(s)"
}
) -join ','
Write-Error $failedMessage -ErrorId Build.Failed -TargetObject (
[PSCustomObject][ordered]@{
Output = $pipescriptOutput
Errors = $TranspilerErrors
Warnings = $TranspilerWarnings
Command = $Command
Parameters = $InvokePipeScriptParameters
}
)
}

# If it could not be transpiled into a [ScriptBlock] or [ScriptBlock[]]
if ($transpiledScriptBlock -isnot [ScriptBlock] -and -not ($TranspiledScriptBlock -as [scriptblock[]])) {
if ($TranspilerErrors -or
($transpiledScriptBlock -isnot [ScriptBlock] -and -not ($TranspiledScriptBlock -as [scriptblock[]]))) {
# error out.
Write-Error "Command {$command} could not be transpiled into [ScriptBlock]s"
return
Expand Down
29 changes: 28 additions & 1 deletion New-PipeScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,16 @@ function New-PipeScript {
# The script header.
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$Header
$Header,
# If provided, will automatically create parameters.
# Parameters will be automatically created for any unassigned variables.
[Alias('AutoParameterize','AutoParameters')]
[switch]
$AutoParameter,
# The type used for automatically generated parameters.
# By default, ```[PSObject]```.
[type]
$AutoParameterType = [PSObject]
)
begin {
$ParametersToCreate = [Ordered]@{}
Expand Down Expand Up @@ -228,6 +237,24 @@ function New-PipeScript {
# accumulate them.
$allEndBlocks += $end
}
if ($AutoParameter) {
$variableDefinitions = $Begin, $Process, $End |
Where-Object { $_ } |
Search-PipeScript -AstType VariableExpressionAST |
Select-Object -ExpandProperty Result
foreach ($var in $variableDefinitions) {
$assigned = $var.GetAssignments()
if ($assigned) { continue }
$varName = $var.VariablePath.userPath.ToString()
$ParametersToCreate[$varName] = @(
@(
"[Parameter(ValueFromPipelineByPropertyName)]"
"[$($AutoParameterType.FullName -replace '^System\.')]"
"$var"
) -join [Environment]::NewLine
)
}
}
}
end {
# Take all of the accumulated parameters and create a parameter block
Expand Down
31 changes: 30 additions & 1 deletion New-PipeScript.ps1.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@
# The script header.
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$Header
$Header,

# If provided, will automatically create parameters.
# Parameters will be automatically created for any unassigned variables.
[Alias('AutoParameterize','AutoParameters')]
[switch]
$AutoParameter,

# The type used for automatically generated parameters.
# By default, ```[PSObject]```.
[type]
$AutoParameterType = [PSObject]
)

begin {
Expand Down Expand Up @@ -164,6 +175,24 @@
$allEndBlocks += $end
}

if ($AutoParameter) {
$variableDefinitions = $Begin, $Process, $End |
Where-Object { $_ } |
Search-PipeScript -AstType VariableExpressionAST |
Select-Object -ExpandProperty Result
foreach ($var in $variableDefinitions) {
$assigned = $var.GetAssignments()
if ($assigned) { continue }
$varName = $var.VariablePath.userPath.ToString()
$ParametersToCreate[$varName] = @(
@(
"[Parameter(ValueFromPipelineByPropertyName)]"
"[$($AutoParameterType.FullName -replace '^System\.')]"
"$var"
) -join [Environment]::NewLine
)
}
}
}

end {
Expand Down
2 changes: 1 addition & 1 deletion PipeScript.format.ps1xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-16"?>
<!-- Generated with EZOut 1.8.7: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
<!-- Generated with EZOut 1.8.8: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
<Configuration>
<ViewDefinitions>
<View>
Expand Down
18 changes: 17 additions & 1 deletion PipeScript.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '0.0.13'
ModuleVersion = '0.0.14'
Description = 'An Extensible Transpiler for PowerShell (and anything else)'
RootModule = 'PipeScript.psm1'
PowerShellVersion = '4.0'
Expand All @@ -19,6 +19,22 @@
BuildModule = @('EZOut','Piecemeal','PipeScript','HelpOut', 'PSDevOps')
Tags = 'PipeScript','PowerShell', 'Transpilation', 'Compiler'
ReleaseNotes = @'
## 0.0.14:
* New Transpilers:
* [RemoveParameter] (#159)
* [RenameVariable] (#160)
* Keyword Updates:
* new now supports extended type creation (#164)
* until now supports a TimeSpan, DateTime, or EventName string (#153)
* AST Extended Type Enhancements:
* [TypeConstraintAst] and [AttributeAst] now have .ResolvedCommand (#162)
* Action Updates
* Pulling just before push (#163)
* Not running when there is not a current branch (#158)
* Improving email determination (#156)
* Invoke-PipeScript terminates transpiler errors when run interactively (#161)
---

## 0.0.13:
* New / Improved Keywords
* assert keyword (Support for pipelines) (#143)
Expand Down
Loading