From 542770185f8d239c471b30db1178277b3c5b6aba Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Wed, 27 Nov 2024 22:59:18 -0800 Subject: [PATCH 01/60] feat: Get-WebSocket -TimeOut ( Fixes #23 ) --- Commands/Get-WebSocket.ps1 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Commands/Get-WebSocket.ps1 b/Commands/Get-WebSocket.ps1 index 3723f81..6b8b195 100644 --- a/Commands/Get-WebSocket.ps1 +++ b/Commands/Get-WebSocket.ps1 @@ -23,10 +23,22 @@ function Get-WebSocket { websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | Foreach-Object { $in = $_ + $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7)) if ($in.commit.record.text -match "(?>(?:$emojiPattern|\#\w+)") { - Write-Host $matches.0 -NoNewline + $match = $matches.0 + Write-Host $spacing,$match,$spacing -NoNewline } } + .EXAMPLE + websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | + Where-Object { + $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external' + } | + Foreach-Object { + $_.commit.record.embed.external.uri + } + .EXAMPLE + #> [CmdletBinding(PositionalBinding=$false)] param( @@ -77,6 +89,10 @@ function Get-WebSocket { [switch] $Watch, + # The timeout for the WebSocket connection. If this is provided, after the timeout elapsed, the WebSocket will be closed. + [TimeSpan] + $TimeOut, + # The maximum time to wait for a connection to be established. # By default, this is 7 seconds. [TimeSpan] @@ -123,11 +139,16 @@ function Get-WebSocket { $ws = $WebSocket } + $webSocketStartTime = $Variable.WebSocketStartTime = [DateTime]::Now $Variable.WebSocket = $ws while ($true) { if ($ws.State -ne 'Open') {break } + if ($TimeOut -and ([DateTime]::Now - $webSocketStartTime) -gt $TimeOut) { + $ws.CloseAsync([Net.WebSockets.WebSocketCloseStatus]::NormalClosure, 'Timeout', $CT).Wait() + break + } $Buf = [byte[]]::new($BufferSize) $Seg = [ArraySegment[byte]]::new($Buf) $null = $ws.ReceiveAsync($Seg, $CT).Wait() From f79d0585a1e73b4118cb475ea86bd5a69322e7bd Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Thu, 28 Nov 2024 07:01:35 +0000 Subject: [PATCH 02/60] feat: Get-WebSocket -TimeOut ( Fixes #23 ) --- docs/Get-WebSocket.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/Get-WebSocket.md b/docs/Get-WebSocket.md index a867234..eecf987 100644 --- a/docs/Get-WebSocket.md +++ b/docs/Get-WebSocket.md @@ -41,11 +41,25 @@ $emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | Foreach-Object { $in = $_ + $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7)) if ($in.commit.record.text -match "(?>(?:$emojiPattern|\#\w+)") { - Write-Host $matches.0 -NoNewline + $match = $matches.0 + Write-Host $spacing,$match,$spacing -NoNewline } } ``` +> EXAMPLE 5 + +```PowerShell +websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | + Where-Object { + $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external' + } | + Foreach-Object { + $_.commit.record.embed.external.uri + } +``` +> EXAMPLE 6 --- @@ -128,6 +142,13 @@ If set, will watch the output of the WebSocket job, outputting results continuou |----------|--------|--------|-------------|-------| |`[Switch]`|false |named |false |Tail | +#### **TimeOut** +The timeout for the WebSocket connection. If this is provided, after the timeout elapsed, the WebSocket will be closed. + +|Type |Required|Position|PipelineInput| +|------------|--------|--------|-------------| +|`[TimeSpan]`|false |named |false | + #### **ConnectionTimeout** The maximum time to wait for a connection to be established. By default, this is 7 seconds. @@ -156,5 +177,5 @@ RunspacePools allow you to limit the scope of the handler to a pool of runspaces ### Syntax ```PowerShell -Get-WebSocket [[-WebSocketUri] ] [-Handler ] [-Variable ] [-Name ] [-InitializationScript ] [-BufferSize ] [-OnConnect ] [-OnError ] [-OnOutput ] [-OnWarning ] [-Watch] [-ConnectionTimeout ] [-Runspace ] [-RunspacePool ] [] +Get-WebSocket [[-WebSocketUri] ] [-Handler ] [-Variable ] [-Name ] [-InitializationScript ] [-BufferSize ] [-OnConnect ] [-OnError ] [-OnOutput ] [-OnWarning ] [-Watch] [-TimeOut ] [-ConnectionTimeout ] [-Runspace ] [-RunspacePool ] [] ``` From 7ceadfa328437b86f7c46060f7d5cc8d29bab4c4 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Thu, 28 Nov 2024 07:01:35 +0000 Subject: [PATCH 03/60] feat: Get-WebSocket -TimeOut ( Fixes #23 ) --- docs/_data/Help/Get-WebSocket.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/_data/Help/Get-WebSocket.json b/docs/_data/Help/Get-WebSocket.json index 1d24148..fb114fd 100644 --- a/docs/_data/Help/Get-WebSocket.json +++ b/docs/_data/Help/Get-WebSocket.json @@ -48,7 +48,17 @@ { "Title": "EXAMPLE 4", "Markdown": "", - "Code": "$emojiPattern = '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}\\p{IsVariationSelectors}\\p{IsCombiningHalfMarks}]+)'\nwebsocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n if ($in.commit.record.text -match \"(?>(?:$emojiPattern|\\#\\w+)\") {\n Write-Host $matches.0 -NoNewline\n }\n }" + "Code": "$emojiPattern = '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}\\p{IsVariationSelectors}\\p{IsCombiningHalfMarks}]+)'\nwebsocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))\n if ($in.commit.record.text -match \"(?>(?:$emojiPattern|\\#\\w+)\") {\n $match = $matches.0 \n Write-Host $spacing,$match,$spacing -NoNewline\n }\n }" + }, + { + "Title": "EXAMPLE 5", + "Markdown": "", + "Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |\n Where-Object {\n $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external'\n } |\n Foreach-Object {\n $_.commit.record.embed.external.uri\n }" + }, + { + "Title": "EXAMPLE 6", + "Markdown": "", + "Code": "" } ] } \ No newline at end of file From 102fc2793560ea6239627c28449992ee578451b6 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Thu, 28 Nov 2024 07:01:35 +0000 Subject: [PATCH 04/60] feat: Get-WebSocket -TimeOut ( Fixes #23 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From 3515639af50eba9af2639b60ce40ab8327db31be Mon Sep 17 00:00:00 2001 From: James Brundage Date: Thu, 28 Nov 2024 07:01:38 +0000 Subject: [PATCH 05/60] feat: Get-WebSocket -TimeOut ( Fixes #23 ) --- docs/_data/LastDateBuilt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_data/LastDateBuilt.json b/docs/_data/LastDateBuilt.json index 96642b6..0f1a06e 100644 --- a/docs/_data/LastDateBuilt.json +++ b/docs/_data/LastDateBuilt.json @@ -1 +1 @@ -"2024-11-27" \ No newline at end of file +"2024-11-28" \ No newline at end of file From 3c8b30d7197288ab9e0e75bc8102807958f6d871 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Thu, 28 Nov 2024 07:01:38 +0000 Subject: [PATCH 06/60] feat: Get-WebSocket -TimeOut ( Fixes #23 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From b1b6f74b9458ff2812b32c6fa71b6dc0df1250e1 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Wed, 27 Nov 2024 23:30:46 -0800 Subject: [PATCH 07/60] feat: Get-WebSocket -Maximum ( Fixes #22 ) --- Commands/Get-WebSocket.ps1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Commands/Get-WebSocket.ps1 b/Commands/Get-WebSocket.ps1 index 6b8b195..35c77d8 100644 --- a/Commands/Get-WebSocket.ps1 +++ b/Commands/Get-WebSocket.ps1 @@ -91,7 +91,11 @@ function Get-WebSocket { # The timeout for the WebSocket connection. If this is provided, after the timeout elapsed, the WebSocket will be closed. [TimeSpan] - $TimeOut, + $TimeOut, + + # The maximum number of messages to receive before closing the WebSocket. + [long] + $Maximum, # The maximum time to wait for a connection to be established. # By default, this is 7 seconds. @@ -141,6 +145,8 @@ function Get-WebSocket { $webSocketStartTime = $Variable.WebSocketStartTime = [DateTime]::Now $Variable.WebSocket = $ws + + $MessageCount = [long]0 while ($true) { @@ -149,9 +155,17 @@ function Get-WebSocket { $ws.CloseAsync([Net.WebSockets.WebSocketCloseStatus]::NormalClosure, 'Timeout', $CT).Wait() break } + + if ($Maximum -and $MessageCount -ge $Maximum) { + $ws.CloseAsync([Net.WebSockets.WebSocketCloseStatus]::NormalClosure, 'Maximum messages reached', $CT).Wait() + break + } + + $Buf = [byte[]]::new($BufferSize) $Seg = [ArraySegment[byte]]::new($Buf) $null = $ws.ReceiveAsync($Seg, $CT).Wait() + $MessageCount++ $JS = $OutputEncoding.GetString($Buf, 0, $Buf.Count) if ([string]::IsNullOrWhitespace($JS)) { continue } try { From 3cad8eba8096869fcba31c1bc73fb9f2a4c66122 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Thu, 28 Nov 2024 07:32:49 +0000 Subject: [PATCH 08/60] feat: Get-WebSocket -Maximum ( Fixes #22 ) --- docs/Get-WebSocket.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/Get-WebSocket.md b/docs/Get-WebSocket.md index eecf987..b96dd5d 100644 --- a/docs/Get-WebSocket.md +++ b/docs/Get-WebSocket.md @@ -149,6 +149,13 @@ The timeout for the WebSocket connection. If this is provided, after the timeou |------------|--------|--------|-------------| |`[TimeSpan]`|false |named |false | +#### **Maximum** +The maximum number of messages to receive before closing the WebSocket. + +|Type |Required|Position|PipelineInput| +|---------|--------|--------|-------------| +|`[Int64]`|false |named |false | + #### **ConnectionTimeout** The maximum time to wait for a connection to be established. By default, this is 7 seconds. @@ -177,5 +184,5 @@ RunspacePools allow you to limit the scope of the handler to a pool of runspaces ### Syntax ```PowerShell -Get-WebSocket [[-WebSocketUri] ] [-Handler ] [-Variable ] [-Name ] [-InitializationScript ] [-BufferSize ] [-OnConnect ] [-OnError ] [-OnOutput ] [-OnWarning ] [-Watch] [-TimeOut ] [-ConnectionTimeout ] [-Runspace ] [-RunspacePool ] [] +Get-WebSocket [[-WebSocketUri] ] [-Handler ] [-Variable ] [-Name ] [-InitializationScript ] [-BufferSize ] [-OnConnect ] [-OnError ] [-OnOutput ] [-OnWarning ] [-Watch] [-TimeOut ] [-Maximum ] [-ConnectionTimeout ] [-Runspace ] [-RunspacePool ] [] ``` From e2382f65cf2c7ddeb255029d61ed248342470bf9 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Thu, 28 Nov 2024 07:32:49 +0000 Subject: [PATCH 09/60] feat: Get-WebSocket -Maximum ( Fixes #22 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From 5b92da4f809f32f8ba5c3499de4cdea9cd2f4607 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Thu, 28 Nov 2024 07:32:52 +0000 Subject: [PATCH 10/60] feat: Get-WebSocket -Maximum ( Fixes #22 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From 3fd880eafc3a776f433d6a736a7c29a22b5a7193 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Wed, 27 Nov 2024 23:33:34 -0800 Subject: [PATCH 11/60] feat: WebSocket action ( Fixes #24 ) --- Build/GitHub/Actions/WebSocketAction.ps1 | 349 +++++++++++++++++ Build/WebSocket.GitHubAction.PSDevOps.ps1 | 10 + action.yml | 442 ++++++++++++++++++++++ 3 files changed, 801 insertions(+) create mode 100644 Build/GitHub/Actions/WebSocketAction.ps1 create mode 100644 Build/WebSocket.GitHubAction.PSDevOps.ps1 create mode 100644 action.yml diff --git a/Build/GitHub/Actions/WebSocketAction.ps1 b/Build/GitHub/Actions/WebSocketAction.ps1 new file mode 100644 index 0000000..275bbbe --- /dev/null +++ b/Build/GitHub/Actions/WebSocketAction.ps1 @@ -0,0 +1,349 @@ +<# +.Synopsis + GitHub Action for WebSocket +.Description + GitHub Action for WebSocket. This will: + + * Import WebSocket + * If `-Run` is provided, run that script + * Otherwise, unless `-SkipScriptFile` is passed, run all *.WebSocket.ps1 files beneath the workflow directory + * If any `-ActionScript` was provided, run scripts from the action path that match a wildcard pattern. + + If you will be making changes using the GitHubAPI, you should provide a -GitHubToken + If none is provided, and ENV:GITHUB_TOKEN is set, this will be used instead. + Any files changed can be outputted by the script, and those changes can be checked back into the repo. + Make sure to use the "persistCredentials" option with checkout. +#> + +param( +# A PowerShell Script that uses WebSocket. +# Any files outputted from the script will be added to the repository. +# If those files have a .Message attached to them, they will be committed with that message. +[string] +$Run, + +# If set, will not process any files named *.WebSocket.ps1 +[switch] +$SkipScriptFile, + +# A list of modules to be installed from the PowerShell gallery before scripts run. +[string[]] +$InstallModule, + +# If provided, will commit any remaining changes made to the workspace with this commit message. +[string] +$CommitMessage, + +# If provided, will checkout a new branch before making the changes. +# If not provided, will use the current branch. +[string] +$TargetBranch, + +# The name of one or more scripts to run, from this action's path. +[string[]] +$ActionScript, + +# The github token to use for requests. +[string] +$GitHubToken = '{{ secrets.GITHUB_TOKEN }}', + +# The user email associated with a git commit. If this is not provided, it will be set to the username@noreply.github.com. +[string] +$UserEmail, + +# The user name associated with a git commit. +[string] +$UserName, + +# If set, will not push any changes made to the repository. +# (they will still be committed unless `-NoCommit` is passed) +[switch] +$NoPush, + +# If set, will not commit any changes made to the repository. +# (this also implies `-NoPush`) +[switch] +$NoCommit +) + +$ErrorActionPreference = 'continue' +"::group::Parameters" | Out-Host +[PSCustomObject]$PSBoundParameters | Format-List | Out-Host +"::endgroup::" | Out-Host + +$gitHubEventJson = [IO.File]::ReadAllText($env:GITHUB_EVENT_PATH) +$gitHubEvent = + if ($env:GITHUB_EVENT_PATH) { + $gitHubEventJson | ConvertFrom-Json + } else { $null } +"::group::Parameters" | Out-Host +$gitHubEvent | Format-List | Out-Host +"::endgroup::" | Out-Host + + +$anyFilesChanged = $false +$ActionModuleName = 'PSJekyll' +$actorInfo = $null + + +$checkDetached = git symbolic-ref -q HEAD +if ($LASTEXITCODE) { + "::warning::On detached head, skipping action" | Out-Host + exit 0 +} + +function InstallActionModule { + param([string]$ModuleToInstall) + $moduleInWorkspace = Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse -File | + Where-Object Name -eq "$($moduleToInstall).psd1" | + Where-Object { + $(Get-Content $_.FullName -Raw) -match 'ModuleVersion' + } + if (-not $moduleInWorkspace) { + $availableModules = Get-Module -ListAvailable + if ($availableModules.Name -notcontains $moduleToInstall) { + Install-Module $moduleToInstall -Scope CurrentUser -Force -AcceptLicense -AllowClobber + } + Import-Module $moduleToInstall -Force -PassThru | Out-Host + } else { + Import-Module $moduleInWorkspace.FullName -Force -PassThru | Out-Host + } +} +function ImportActionModule { + #region -InstallModule + if ($InstallModule) { + "::group::Installing Modules" | Out-Host + foreach ($moduleToInstall in $InstallModule) { + InstallActionModule -ModuleToInstall $moduleToInstall + } + "::endgroup::" | Out-Host + } + #endregion -InstallModule + + if ($env:GITHUB_ACTION_PATH) { + $LocalModulePath = Join-Path $env:GITHUB_ACTION_PATH "$ActionModuleName.psd1" + if (Test-path $LocalModulePath) { + Import-Module $LocalModulePath -Force -PassThru | Out-String + } else { + throw "Module '$ActionModuleName' not found" + } + } elseif (-not (Get-Module $ActionModuleName)) { + throw "Module '$ActionModuleName' not found" + } + + "::notice title=ModuleLoaded::$ActionModuleName Loaded from Path - $($LocalModulePath)" | Out-Host + if ($env:GITHUB_STEP_SUMMARY) { + "# $($ActionModuleName)" | + Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } +} +function InitializeAction { + #region Custom + #endregion Custom + + # Configure git based on the $env:GITHUB_ACTOR + if (-not $UserName) { $UserName = $env:GITHUB_ACTOR } + if (-not $actorID) { $actorID = $env:GITHUB_ACTOR_ID } + $actorInfo = + if ($GitHubToken -notmatch '^\{{2}' -and $GitHubToken -notmatch '\}{2}$') { + Invoke-RestMethod -Uri "https://api.github.com/user/$actorID" -Headers @{ Authorization = "token $GitHubToken" } + } else { + Invoke-RestMethod -Uri "https://api.github.com/user/$actorID" + } + + if (-not $UserEmail) { $UserEmail = "$UserName@noreply.github.com" } + git config --global user.email $UserEmail + git config --global user.name $actorInfo.name + + # Pull down any changes + git pull | Out-Host + + if ($TargetBranch) { + "::notice title=Expanding target branch string $targetBranch" | Out-Host + $TargetBranch = $ExecutionContext.SessionState.InvokeCommand.ExpandString($TargetBranch) + "::notice title=Checking out target branch::$targetBranch" | Out-Host + git checkout -b $TargetBranch | Out-Host + git pull | Out-Host + } +} + +function InvokeActionModule { + $myScriptStart = [DateTime]::Now + $myScript = $ExecutionContext.SessionState.PSVariable.Get("Run").Value + if ($myScript) { + Invoke-Expression -Command $myScript | + . ProcessOutput | + Out-Host + return + } + $myScriptTook = [Datetime]::Now - $myScriptStart + $MyScriptFilesStart = [DateTime]::Now + + $myScriptList = @() + $shouldSkip = $ExecutionContext.SessionState.PSVariable.Get("SkipScriptFile").Value + if ($shouldSkip) { + return + } + $scriptFiles = @( + Get-ChildItem -Recurse -Path $env:GITHUB_WORKSPACE | + Where-Object Name -Match "\.$($ActionModuleName)\.ps1$" + if ($ActionScript) { + if ($ActionScript -match '^\s{0,}/' -and $ActionScript -match '/\s{0,}$') { + $ActionScriptPattern = $ActionScript.Trim('/').Trim() -as [regex] + if ($ActionScriptPattern) { + $ActionScriptPattern = [regex]::new($ActionScript.Trim('/').Trim(), 'IgnoreCase,IgnorePatternWhitespace', [timespan]::FromSeconds(0.5)) + Get-ChildItem -Recurse -Path $env:GITHUB_ACTION_PATH | + Where-Object { $_.Name -Match "\.$($ActionModuleName)\.ps1$" -and $_.FullName -match $ActionScriptPattern } + } + } else { + Get-ChildItem -Recurse -Path $env:GITHUB_ACTION_PATH | + Where-Object Name -Match "\.$($ActionModuleName)\.ps1$" | + Where-Object FullName -Like $ActionScript + } + } + ) | Select-Object -Unique + $scriptFiles | + ForEach-Object -Begin { + if ($env:GITHUB_STEP_SUMMARY) { + "## $ActionModuleName Scripts" | + Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } + } -Process { + $myScriptList += $_.FullName.Replace($env:GITHUB_WORKSPACE, '').TrimStart('/') + $myScriptCount++ + $scriptFile = $_ + if ($env:GITHUB_STEP_SUMMARY) { + "### $($scriptFile.Fullname -replace [Regex]::Escape($env:GITHUB_WORKSPACE))" | + Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } + $scriptCmd = $ExecutionContext.SessionState.InvokeCommand.GetCommand($scriptFile.FullName, 'ExternalScript') + foreach ($requiredModule in $CommandInfo.ScriptBlock.Ast.ScriptRequirements.RequiredModules) { + if ($requiredModule.Name -and + (-not $requiredModule.MaximumVersion) -and + (-not $requiredModule.RequiredVersion) + ) { + InstallActionModule $requiredModule.Name + } + } + $scriptFileOutputs = . $scriptCmd + $scriptFileOutputs | + . ProcessOutput | + Out-Host + } + + $MyScriptFilesTook = [Datetime]::Now - $MyScriptFilesStart + $SummaryOfMyScripts = "$myScriptCount $ActionModuleName scripts took $($MyScriptFilesTook.TotalSeconds) seconds" + $SummaryOfMyScripts | + Out-Host + if ($env:GITHUB_STEP_SUMMARY) { + $SummaryOfMyScripts | + Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } + #region Custom + #endregion Custom +} + +function OutError { + $anyRuntimeExceptions = $false + foreach ($err in $error) { + $errParts = @( + "::error " + @( + if ($err.InvocationInfo.ScriptName) { + "file=$($err.InvocationInfo.ScriptName)" + } + if ($err.InvocationInfo.ScriptLineNumber -ge 1) { + "line=$($err.InvocationInfo.ScriptLineNumber)" + if ($err.InvocationInfo.OffsetInLine -ge 1) { + "col=$($err.InvocationInfo.OffsetInLine)" + } + } + if ($err.CategoryInfo.Activity) { + "title=$($err.CategoryInfo.Activity)" + } + ) -join ',' + "::" + $err.Exception.Message + if ($err.CategoryInfo.Category -eq 'OperationStopped' -and + $err.CategoryInfo.Reason -eq 'RuntimeException') { + $anyRuntimeExceptions = $true + } + ) -join '' + $errParts | Out-Host + if ($anyRuntimeExceptions) { + exit 1 + } + } +} + +function PushActionOutput { + if ($anyFilesChanged) { + "::notice::$($anyFilesChanged) Files Changed" | Out-Host + } + if ($CommitMessage -or $anyFilesChanged) { + if ($CommitMessage) { + Get-ChildItem $env:GITHUB_WORKSPACE -Recurse | + ForEach-Object { + $gitStatusOutput = git status $_.Fullname -s + if ($gitStatusOutput) { + git add $_.Fullname + } + } + + git commit -m $ExecutionContext.SessionState.InvokeCommand.ExpandString($CommitMessage) + } + + $checkDetached = git symbolic-ref -q HEAD + if (-not $LASTEXITCODE -and -not $NoPush -and -not $noCommit) { + if ($TargetBranch -and $anyFilesChanged) { + "::notice::Pushing Changes to $targetBranch" | Out-Host + git push --set-upstream origin $TargetBranch + } elseif ($anyFilesChanged) { + "::notice::Pushing Changes" | Out-Host + git push + } + "Git Push Output: $($gitPushed | Out-String)" + } else { + "::notice::Not pushing changes (on detached head)" | Out-Host + $LASTEXITCODE = 0 + exit 0 + } + } +} + +filter ProcessOutput { + $out = $_ + $outItem = Get-Item -Path $out -ErrorAction Ignore + if (-not $outItem -and $out -is [string]) { + $out | Out-Host + if ($env:GITHUB_STEP_SUMMARY) { + "> $out" | Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } + return + } + $fullName, $shouldCommit = + if ($out -is [IO.FileInfo]) { + $out.FullName, (git status $out.Fullname -s) + } elseif ($outItem) { + $outItem.FullName, (git status $outItem.Fullname -s) + } + if ($shouldCommit -and -not $NoCommit) { + "$fullName has changed, and should be committed" | Out-Host + git add $fullName + if ($out.Message) { + git commit -m "$($out.Message)" | Out-Host + } elseif ($out.CommitMessage) { + git commit -m "$($out.CommitMessage)" | Out-Host + } elseif ($gitHubEvent.head_commit.message) { + git commit -m "$($gitHubEvent.head_commit.message)" | Out-Host + } + $anyFilesChanged = $true + } + $out +} + +. ImportActionModule +. InitializeAction +. InvokeActionModule +. PushActionOutput +. OutError \ No newline at end of file diff --git a/Build/WebSocket.GitHubAction.PSDevOps.ps1 b/Build/WebSocket.GitHubAction.PSDevOps.ps1 new file mode 100644 index 0000000..5813b54 --- /dev/null +++ b/Build/WebSocket.GitHubAction.PSDevOps.ps1 @@ -0,0 +1,10 @@ +#requires -Module PSDevOps +Import-BuildStep -SourcePath ( + Join-Path $PSScriptRoot 'GitHub' +) -BuildSystem GitHubAction + +$PSScriptRoot | Split-Path | Push-Location + +New-GitHubAction -Name "UseWebSocket" -Description 'Work with WebSockets in PowerShell' -Action WebSocketAction -Icon chevron-right -OutputPath .\action.yml + +Pop-Location \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..9f82bfe --- /dev/null +++ b/action.yml @@ -0,0 +1,442 @@ + +name: UseWebSocket +description: Work with WebSockets in PowerShell +inputs: + Run: + required: false + description: | + A PowerShell Script that uses WebSocket. + Any files outputted from the script will be added to the repository. + If those files have a .Message attached to them, they will be committed with that message. + SkipScriptFile: + required: false + description: 'If set, will not process any files named *.WebSocket.ps1' + InstallModule: + required: false + description: A list of modules to be installed from the PowerShell gallery before scripts run. + CommitMessage: + required: false + description: If provided, will commit any remaining changes made to the workspace with this commit message. + TargetBranch: + required: false + description: | + If provided, will checkout a new branch before making the changes. + If not provided, will use the current branch. + ActionScript: + required: false + description: The name of one or more scripts to run, from this action's path. + GitHubToken: + required: false + default: '{{ secrets.GITHUB_TOKEN }}' + description: The github token to use for requests. + UserEmail: + required: false + description: The user email associated with a git commit. If this is not provided, it will be set to the username@noreply.github.com. + UserName: + required: false + description: The user name associated with a git commit. + NoPush: + required: false + description: | + If set, will not push any changes made to the repository. + (they will still be committed unless `-NoCommit` is passed) + NoCommit: + required: false + description: | + If set, will not commit any changes made to the repository. + (this also implies `-NoPush`) +branding: + icon: chevron-right + color: blue +runs: + using: composite + steps: + - name: WebSocketAction + id: WebSocketAction + shell: pwsh + env: + CommitMessage: ${{inputs.CommitMessage}} + SkipScriptFile: ${{inputs.SkipScriptFile}} + InstallModule: ${{inputs.InstallModule}} + Run: ${{inputs.Run}} + TargetBranch: ${{inputs.TargetBranch}} + NoPush: ${{inputs.NoPush}} + GitHubToken: ${{inputs.GitHubToken}} + UserEmail: ${{inputs.UserEmail}} + NoCommit: ${{inputs.NoCommit}} + UserName: ${{inputs.UserName}} + ActionScript: ${{inputs.ActionScript}} + run: | + $Parameters = @{} + $Parameters.Run = ${env:Run} + $Parameters.SkipScriptFile = ${env:SkipScriptFile} + $Parameters.SkipScriptFile = $parameters.SkipScriptFile -match 'true'; + $Parameters.InstallModule = ${env:InstallModule} + $Parameters.InstallModule = $parameters.InstallModule -split ';' -replace '^[''"]' -replace '[''"]$' + $Parameters.CommitMessage = ${env:CommitMessage} + $Parameters.TargetBranch = ${env:TargetBranch} + $Parameters.ActionScript = ${env:ActionScript} + $Parameters.ActionScript = $parameters.ActionScript -split ';' -replace '^[''"]' -replace '[''"]$' + $Parameters.GitHubToken = ${env:GitHubToken} + $Parameters.UserEmail = ${env:UserEmail} + $Parameters.UserName = ${env:UserName} + $Parameters.NoPush = ${env:NoPush} + $Parameters.NoPush = $parameters.NoPush -match 'true'; + $Parameters.NoCommit = ${env:NoCommit} + $Parameters.NoCommit = $parameters.NoCommit -match 'true'; + foreach ($k in @($parameters.Keys)) { + if ([String]::IsNullOrEmpty($parameters[$k])) { + $parameters.Remove($k) + } + } + Write-Host "::debug:: WebSocketAction $(@(foreach ($p in $Parameters.GetEnumerator()) {'-' + $p.Key + ' ' + $p.Value}) -join ' ')" + & {<# + .Synopsis + GitHub Action for WebSocket + .Description + GitHub Action for WebSocket. This will: + + * Import WebSocket + * If `-Run` is provided, run that script + * Otherwise, unless `-SkipScriptFile` is passed, run all *.WebSocket.ps1 files beneath the workflow directory + * If any `-ActionScript` was provided, run scripts from the action path that match a wildcard pattern. + + If you will be making changes using the GitHubAPI, you should provide a -GitHubToken + If none is provided, and ENV:GITHUB_TOKEN is set, this will be used instead. + Any files changed can be outputted by the script, and those changes can be checked back into the repo. + Make sure to use the "persistCredentials" option with checkout. + #> + + param( + # A PowerShell Script that uses WebSocket. + # Any files outputted from the script will be added to the repository. + # If those files have a .Message attached to them, they will be committed with that message. + [string] + $Run, + + # If set, will not process any files named *.WebSocket.ps1 + [switch] + $SkipScriptFile, + + # A list of modules to be installed from the PowerShell gallery before scripts run. + [string[]] + $InstallModule, + + # If provided, will commit any remaining changes made to the workspace with this commit message. + [string] + $CommitMessage, + + # If provided, will checkout a new branch before making the changes. + # If not provided, will use the current branch. + [string] + $TargetBranch, + + # The name of one or more scripts to run, from this action's path. + [string[]] + $ActionScript, + + # The github token to use for requests. + [string] + $GitHubToken = '{{ secrets.GITHUB_TOKEN }}', + + # The user email associated with a git commit. If this is not provided, it will be set to the username@noreply.github.com. + [string] + $UserEmail, + + # The user name associated with a git commit. + [string] + $UserName, + + # If set, will not push any changes made to the repository. + # (they will still be committed unless `-NoCommit` is passed) + [switch] + $NoPush, + + # If set, will not commit any changes made to the repository. + # (this also implies `-NoPush`) + [switch] + $NoCommit + ) + + $ErrorActionPreference = 'continue' + "::group::Parameters" | Out-Host + [PSCustomObject]$PSBoundParameters | Format-List | Out-Host + "::endgroup::" | Out-Host + + $gitHubEventJson = [IO.File]::ReadAllText($env:GITHUB_EVENT_PATH) + $gitHubEvent = + if ($env:GITHUB_EVENT_PATH) { + $gitHubEventJson | ConvertFrom-Json + } else { $null } + "::group::Parameters" | Out-Host + $gitHubEvent | Format-List | Out-Host + "::endgroup::" | Out-Host + + + $anyFilesChanged = $false + $ActionModuleName = 'PSJekyll' + $actorInfo = $null + + + $checkDetached = git symbolic-ref -q HEAD + if ($LASTEXITCODE) { + "::warning::On detached head, skipping action" | Out-Host + exit 0 + } + + function InstallActionModule { + param([string]$ModuleToInstall) + $moduleInWorkspace = Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse -File | + Where-Object Name -eq "$($moduleToInstall).psd1" | + Where-Object { + $(Get-Content $_.FullName -Raw) -match 'ModuleVersion' + } + if (-not $moduleInWorkspace) { + $availableModules = Get-Module -ListAvailable + if ($availableModules.Name -notcontains $moduleToInstall) { + Install-Module $moduleToInstall -Scope CurrentUser -Force -AcceptLicense -AllowClobber + } + Import-Module $moduleToInstall -Force -PassThru | Out-Host + } else { + Import-Module $moduleInWorkspace.FullName -Force -PassThru | Out-Host + } + } + function ImportActionModule { + #region -InstallModule + if ($InstallModule) { + "::group::Installing Modules" | Out-Host + foreach ($moduleToInstall in $InstallModule) { + InstallActionModule -ModuleToInstall $moduleToInstall + } + "::endgroup::" | Out-Host + } + #endregion -InstallModule + + if ($env:GITHUB_ACTION_PATH) { + $LocalModulePath = Join-Path $env:GITHUB_ACTION_PATH "$ActionModuleName.psd1" + if (Test-path $LocalModulePath) { + Import-Module $LocalModulePath -Force -PassThru | Out-String + } else { + throw "Module '$ActionModuleName' not found" + } + } elseif (-not (Get-Module $ActionModuleName)) { + throw "Module '$ActionModuleName' not found" + } + + "::notice title=ModuleLoaded::$ActionModuleName Loaded from Path - $($LocalModulePath)" | Out-Host + if ($env:GITHUB_STEP_SUMMARY) { + "# $($ActionModuleName)" | + Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } + } + function InitializeAction { + #region Custom + #endregion Custom + + # Configure git based on the $env:GITHUB_ACTOR + if (-not $UserName) { $UserName = $env:GITHUB_ACTOR } + if (-not $actorID) { $actorID = $env:GITHUB_ACTOR_ID } + $actorInfo = + if ($GitHubToken -notmatch '^\{{2}' -and $GitHubToken -notmatch '\}{2}$') { + Invoke-RestMethod -Uri "https://api.github.com/user/$actorID" -Headers @{ Authorization = "token $GitHubToken" } + } else { + Invoke-RestMethod -Uri "https://api.github.com/user/$actorID" + } + + if (-not $UserEmail) { $UserEmail = "$UserName@noreply.github.com" } + git config --global user.email $UserEmail + git config --global user.name $actorInfo.name + + # Pull down any changes + git pull | Out-Host + + if ($TargetBranch) { + "::notice title=Expanding target branch string $targetBranch" | Out-Host + $TargetBranch = $ExecutionContext.SessionState.InvokeCommand.ExpandString($TargetBranch) + "::notice title=Checking out target branch::$targetBranch" | Out-Host + git checkout -b $TargetBranch | Out-Host + git pull | Out-Host + } + } + + function InvokeActionModule { + $myScriptStart = [DateTime]::Now + $myScript = $ExecutionContext.SessionState.PSVariable.Get("Run").Value + if ($myScript) { + Invoke-Expression -Command $myScript | + . ProcessOutput | + Out-Host + return + } + $myScriptTook = [Datetime]::Now - $myScriptStart + $MyScriptFilesStart = [DateTime]::Now + + $myScriptList = @() + $shouldSkip = $ExecutionContext.SessionState.PSVariable.Get("SkipScriptFile").Value + if ($shouldSkip) { + return + } + $scriptFiles = @( + Get-ChildItem -Recurse -Path $env:GITHUB_WORKSPACE | + Where-Object Name -Match "\.$($ActionModuleName)\.ps1$" + if ($ActionScript) { + if ($ActionScript -match '^\s{0,}/' -and $ActionScript -match '/\s{0,}$') { + $ActionScriptPattern = $ActionScript.Trim('/').Trim() -as [regex] + if ($ActionScriptPattern) { + $ActionScriptPattern = [regex]::new($ActionScript.Trim('/').Trim(), 'IgnoreCase,IgnorePatternWhitespace', [timespan]::FromSeconds(0.5)) + Get-ChildItem -Recurse -Path $env:GITHUB_ACTION_PATH | + Where-Object { $_.Name -Match "\.$($ActionModuleName)\.ps1$" -and $_.FullName -match $ActionScriptPattern } + } + } else { + Get-ChildItem -Recurse -Path $env:GITHUB_ACTION_PATH | + Where-Object Name -Match "\.$($ActionModuleName)\.ps1$" | + Where-Object FullName -Like $ActionScript + } + } + ) | Select-Object -Unique + $scriptFiles | + ForEach-Object -Begin { + if ($env:GITHUB_STEP_SUMMARY) { + "## $ActionModuleName Scripts" | + Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } + } -Process { + $myScriptList += $_.FullName.Replace($env:GITHUB_WORKSPACE, '').TrimStart('/') + $myScriptCount++ + $scriptFile = $_ + if ($env:GITHUB_STEP_SUMMARY) { + "### $($scriptFile.Fullname -replace [Regex]::Escape($env:GITHUB_WORKSPACE))" | + Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } + $scriptCmd = $ExecutionContext.SessionState.InvokeCommand.GetCommand($scriptFile.FullName, 'ExternalScript') + foreach ($requiredModule in $CommandInfo.ScriptBlock.Ast.ScriptRequirements.RequiredModules) { + if ($requiredModule.Name -and + (-not $requiredModule.MaximumVersion) -and + (-not $requiredModule.RequiredVersion) + ) { + InstallActionModule $requiredModule.Name + } + } + $scriptFileOutputs = . $scriptCmd + $scriptFileOutputs | + . ProcessOutput | + Out-Host + } + + $MyScriptFilesTook = [Datetime]::Now - $MyScriptFilesStart + $SummaryOfMyScripts = "$myScriptCount $ActionModuleName scripts took $($MyScriptFilesTook.TotalSeconds) seconds" + $SummaryOfMyScripts | + Out-Host + if ($env:GITHUB_STEP_SUMMARY) { + $SummaryOfMyScripts | + Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } + #region Custom + #endregion Custom + } + + function OutError { + $anyRuntimeExceptions = $false + foreach ($err in $error) { + $errParts = @( + "::error " + @( + if ($err.InvocationInfo.ScriptName) { + "file=$($err.InvocationInfo.ScriptName)" + } + if ($err.InvocationInfo.ScriptLineNumber -ge 1) { + "line=$($err.InvocationInfo.ScriptLineNumber)" + if ($err.InvocationInfo.OffsetInLine -ge 1) { + "col=$($err.InvocationInfo.OffsetInLine)" + } + } + if ($err.CategoryInfo.Activity) { + "title=$($err.CategoryInfo.Activity)" + } + ) -join ',' + "::" + $err.Exception.Message + if ($err.CategoryInfo.Category -eq 'OperationStopped' -and + $err.CategoryInfo.Reason -eq 'RuntimeException') { + $anyRuntimeExceptions = $true + } + ) -join '' + $errParts | Out-Host + if ($anyRuntimeExceptions) { + exit 1 + } + } + } + + function PushActionOutput { + if ($anyFilesChanged) { + "::notice::$($anyFilesChanged) Files Changed" | Out-Host + } + if ($CommitMessage -or $anyFilesChanged) { + if ($CommitMessage) { + Get-ChildItem $env:GITHUB_WORKSPACE -Recurse | + ForEach-Object { + $gitStatusOutput = git status $_.Fullname -s + if ($gitStatusOutput) { + git add $_.Fullname + } + } + + git commit -m $ExecutionContext.SessionState.InvokeCommand.ExpandString($CommitMessage) + } + + $checkDetached = git symbolic-ref -q HEAD + if (-not $LASTEXITCODE -and -not $NoPush -and -not $noCommit) { + if ($TargetBranch -and $anyFilesChanged) { + "::notice::Pushing Changes to $targetBranch" | Out-Host + git push --set-upstream origin $TargetBranch + } elseif ($anyFilesChanged) { + "::notice::Pushing Changes" | Out-Host + git push + } + "Git Push Output: $($gitPushed | Out-String)" + } else { + "::notice::Not pushing changes (on detached head)" | Out-Host + $LASTEXITCODE = 0 + exit 0 + } + } + } + + filter ProcessOutput { + $out = $_ + $outItem = Get-Item -Path $out -ErrorAction Ignore + if (-not $outItem -and $out -is [string]) { + $out | Out-Host + if ($env:GITHUB_STEP_SUMMARY) { + "> $out" | Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } + return + } + $fullName, $shouldCommit = + if ($out -is [IO.FileInfo]) { + $out.FullName, (git status $out.Fullname -s) + } elseif ($outItem) { + $outItem.FullName, (git status $outItem.Fullname -s) + } + if ($shouldCommit -and -not $NoCommit) { + "$fullName has changed, and should be committed" | Out-Host + git add $fullName + if ($out.Message) { + git commit -m "$($out.Message)" | Out-Host + } elseif ($out.CommitMessage) { + git commit -m "$($out.CommitMessage)" | Out-Host + } elseif ($gitHubEvent.head_commit.message) { + git commit -m "$($gitHubEvent.head_commit.message)" | Out-Host + } + $anyFilesChanged = $true + } + $out + } + + . ImportActionModule + . InitializeAction + . InvokeActionModule + . PushActionOutput + . OutError} @Parameters + From 840680e0dc72116ea8ffb43f06656af634983c73 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Thu, 28 Nov 2024 07:35:33 +0000 Subject: [PATCH 12/60] feat: WebSocket action ( Fixes #24 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From d01a7ffb8224781ef8c74e3df150cc59cd91032b Mon Sep 17 00:00:00 2001 From: James Brundage Date: Thu, 28 Nov 2024 07:35:36 +0000 Subject: [PATCH 13/60] feat: WebSocket action ( Fixes #24 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From 1c91db588d95fcec44d10a056dd86b8ee277046b Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Wed, 27 Nov 2024 23:39:26 -0800 Subject: [PATCH 14/60] feat: WebSocket tests ( Fixes #25 ) --- WebSocket.tests.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 WebSocket.tests.ps1 diff --git a/WebSocket.tests.ps1 b/WebSocket.tests.ps1 new file mode 100644 index 0000000..19b6e82 --- /dev/null +++ b/WebSocket.tests.ps1 @@ -0,0 +1,8 @@ + +describe WebSocket { + it 'Can get websocket content' { + $websocketContent = @(websocket wss://jetstream2.us-east.bsky.network/subscribe -TimeOut 00:00:01 -Watch) + + $websocketContent.Count | Should -BeGreaterThan 0 + } +} \ No newline at end of file From 39c44342dd10aa0c11c40b5334932ee37cd0358a Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Thu, 28 Nov 2024 07:41:22 +0000 Subject: [PATCH 15/60] feat: WebSocket tests ( Fixes #25 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From 81a4f52f5c656c761597b3d9a867c924763981ac Mon Sep 17 00:00:00 2001 From: James Brundage Date: Thu, 28 Nov 2024 07:41:25 +0000 Subject: [PATCH 16/60] feat: WebSocket tests ( Fixes #25 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From de48130666549002333fbaad93798e3e150ec931 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Wed, 27 Nov 2024 23:42:20 -0800 Subject: [PATCH 17/60] feat: WebSocket Container starting .WebSocket files ( Fixes #26 ) --- Container.start.ps1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Container.start.ps1 b/Container.start.ps1 index dd49394..1f83e5c 100644 --- a/Container.start.ps1 +++ b/Container.start.ps1 @@ -16,7 +16,7 @@ # Run the initialization script. This will do all remaining initialization in a single layer. RUN --mount=type=bind,src=./,target=/Initialize ./Initialize/Container.init.ps1 - ENTRYPOINT ["pwsh", "-nologo", "-file", "/Container.start.ps1"] + ENTRYPOINT ["pwsh", "-nologo", "-noexit", "-file", "/Container.start.ps1"] ~~~ .NOTES Did you know that in PowerShell you can 'use' namespaces that do not really exist? @@ -58,8 +58,13 @@ if ($args) { } #region Custom else - { - + { + # If a single drive is mounted, start the socket files. + $webSocketFiles = $mountedFolders | Get-ChildItem -Filter *.WebSocket.ps1 + foreach ($webSocketFile in $webSocketFiles) { + Start-ThreadJob -Name $webSocketFile.Name -ScriptBlock {param($webSocketFile) . $using:webSocketFile.FullName } -ArgumentList $webSocketFile + . $webSocketFile.FullName + } } #endregion Custom } From b32e74a07cf869c36da641fcf5b6ade009ea9702 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Sat, 30 Nov 2024 13:13:32 -0800 Subject: [PATCH 18/60] docs: Generating WebSocket README with PipeScript ( Fixes #27 ) --- README.ps.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 README.ps.md diff --git a/README.ps.md b/README.ps.md new file mode 100644 index 0000000..a6fee75 --- /dev/null +++ b/README.ps.md @@ -0,0 +1,61 @@ +
+ WebSocket Logo (Animated) +
+ +# WebSocket + +Work with WebSockets in PowerShell + +WebSocket is a small PowerShell module that helps you work with WebSockets. + +It has a single command: Get-WebSocket. + +Because `Get` is the default verb in PowerShell, you can just call it `WebSocket`. + +## WebSocket Container + +You can use the WebSocket module within a container: + +~~~powershell +docker pull ghcr.io/powershellweb/websocket +docker run -it ghcr.io/powershellweb/websocket +~~~ + +### Installing and Importing + +~~~PowerShell +Install-Module WebSocket -Scope CurrentUser -Force +Import-Module WebSocket -Force -PassThru +~~~ + +### Get-WebSocket + +To connect to a websocket and start listening for results, use [Get-WebSocket](Get-WebSocket.md) + +~~~PowerShell +# Because get is the default verb, we can just say `WebSocket` +# The `-Watch` parameter will continually watch for results +websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch +~~~ + +To stop watching a websocket, simply stop the background job. + +### More Examples + +~~~PipeScript{ +Import-Module .\ +Get-Help Get-WebSocket | + %{ $_.Examples.Example.code} | + % -Begin { $exampleCount = 0 } -Process { + $exampleCount++ + @( + "#### Get-WebSocket Example $exampleCount" + '' + "~~~powershell" + $_ + "~~~" + '' + ) -join [Environment]::Newline + } +} +~~~ \ No newline at end of file From 5fd644b39d78156b73aedb21aaa7d23db832ed60 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sat, 30 Nov 2024 21:16:03 +0000 Subject: [PATCH 19/60] docs: Generating WebSocket README with PipeScript ( Fixes #27 ) --- README.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b5b4f2..5987a0a 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,14 @@ It has a single command: Get-WebSocket. Because `Get` is the default verb in PowerShell, you can just call it `WebSocket`. +## WebSocket Container + +You can use the WebSocket module within a container: + +~~~powershell +docker pull ghcr.io/powershellweb/websocket +docker run -it ghcr.io/powershellweb/websocket +~~~ ### Installing and Importing @@ -30,4 +38,61 @@ To connect to a websocket and start listening for results, use [Get-WebSocket](G websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch ~~~ -To stop watching a websocket, simply stop the background job. \ No newline at end of file +To stop watching a websocket, simply stop the background job. + +### More Examples + +#### Get-WebSocket Example 1 + +~~~powershell +# Create a WebSocket job that connects to a WebSocket and outputs the results. +Get-WebSocket -WebSocketUri "wss://localhost:9669" +~~~ + #### Get-WebSocket Example 2 + +~~~powershell +# Get is the default verb, so we can just say WebSocket. +websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post +~~~ + #### Get-WebSocket Example 3 + +~~~powershell +websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | + Foreach-Object { + $in = $_ + if ($in.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+') { + Write-Host $matches.0 -NoNewline + } + } +~~~ + #### Get-WebSocket Example 4 + +~~~powershell +$emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)' +websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | + Foreach-Object { + $in = $_ + $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7)) + if ($in.commit.record.text -match "(?>(?:$emojiPattern|\#\w+)") { + $match = $matches.0 + Write-Host $spacing,$match,$spacing -NoNewline + } + } +~~~ + #### Get-WebSocket Example 5 + +~~~powershell +websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | + Where-Object { + $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external' + } | + Foreach-Object { + $_.commit.record.embed.external.uri + } +~~~ + #### Get-WebSocket Example 6 + +~~~powershell + +~~~ + From 0f10ff8c80f37d535cbadcb9ba230acfc60232a3 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sat, 30 Nov 2024 21:16:13 +0000 Subject: [PATCH 20/60] docs: Generating WebSocket README with PipeScript ( Fixes #27 ) --- docs/README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/docs/README.md b/docs/README.md index f263805..1825ffa 100644 --- a/docs/README.md +++ b/docs/README.md @@ -12,6 +12,14 @@ It has a single command: Get-WebSocket. Because `Get` is the default verb in PowerShell, you can just call it `WebSocket`. +## WebSocket Container + +You can use the WebSocket module within a container: + +~~~powershell +docker pull ghcr.io/powershellweb/websocket +docker run -it ghcr.io/powershellweb/websocket +~~~ ### Installing and Importing @@ -31,3 +39,59 @@ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app. ~~~ To stop watching a websocket, simply stop the background job. + +### More Examples + +#### Get-WebSocket Example 1 + +~~~powershell +# Create a WebSocket job that connects to a WebSocket and outputs the results. +Get-WebSocket -WebSocketUri "wss://localhost:9669" +~~~ + #### Get-WebSocket Example 2 + +~~~powershell +# Get is the default verb, so we can just say WebSocket. +websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post +~~~ + #### Get-WebSocket Example 3 + +~~~powershell +websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | + Foreach-Object { + $in = $_ + if ($in.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+') { + Write-Host $matches.0 -NoNewline + } + } +~~~ + #### Get-WebSocket Example 4 + +~~~powershell +$emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)' +websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | + Foreach-Object { + $in = $_ + $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7)) + if ($in.commit.record.text -match "(?>(?:$emojiPattern|\#\w+)") { + $match = $matches.0 + Write-Host $spacing,$match,$spacing -NoNewline + } + } +~~~ + #### Get-WebSocket Example 5 + +~~~powershell +websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | + Where-Object { + $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external' + } | + Foreach-Object { + $_.commit.record.embed.external.uri + } +~~~ + #### Get-WebSocket Example 6 + +~~~powershell + +~~~ From 2c1f9d99437bac77c743eaae3a1cd819c8b6f145 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sat, 30 Nov 2024 21:16:13 +0000 Subject: [PATCH 21/60] docs: Generating WebSocket README with PipeScript ( Fixes #27 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From 72e72a016b7dc9aa26f10613190f645a71ee3aad Mon Sep 17 00:00:00 2001 From: James Brundage Date: Sat, 30 Nov 2024 21:16:16 +0000 Subject: [PATCH 22/60] docs: Generating WebSocket README with PipeScript ( Fixes #27 ) --- docs/_data/LastDateBuilt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_data/LastDateBuilt.json b/docs/_data/LastDateBuilt.json index 0f1a06e..55437ce 100644 --- a/docs/_data/LastDateBuilt.json +++ b/docs/_data/LastDateBuilt.json @@ -1 +1 @@ -"2024-11-28" \ No newline at end of file +"2024-11-30" \ No newline at end of file From c49d8e85e332ac54b482966414365ee1f9486816 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Sat, 30 Nov 2024 21:16:17 +0000 Subject: [PATCH 23/60] docs: Generating WebSocket README with PipeScript ( Fixes #27 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From e9d58174ef9182eb14cefbb5046ec9d35f17bc23 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Sat, 30 Nov 2024 13:18:29 -0800 Subject: [PATCH 24/60] docs: More Get-WebSocket examples ( Fixes #27 ) --- Commands/Get-WebSocket.ps1 | 29 ++++++++++++++++++++++++----- README.ps.md | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Commands/Get-WebSocket.ps1 b/Commands/Get-WebSocket.ps1 index 35c77d8..cbf1689 100644 --- a/Commands/Get-WebSocket.ps1 +++ b/Commands/Get-WebSocket.ps1 @@ -3,14 +3,35 @@ function Get-WebSocket { .SYNOPSIS WebSockets in PowerShell. .DESCRIPTION - Get-WebSocket allows you to connect to a websocket and handle the output. + Get-WebSocket gets a websocket. + + This will create a job that connects to a WebSocket and outputs the results. + + If the `-Watch` parameter is provided, will output a continous stream of objects from the websocket. .EXAMPLE # Create a WebSocket job that connects to a WebSocket and outputs the results. - Get-WebSocket -WebSocketUri "wss://localhost:9669" + Get-WebSocket -WebSocketUri "wss://localhost:9669/" .EXAMPLE # Get is the default verb, so we can just say WebSocket. + # `-Watch` will output a continous stream of objects from the websocket. + # For example, let's Watch BlueSky, but just the text. + websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | + % { + $_.commit.record.text + } + .EXAMPLE + # Watch BlueSky, but just the text and spacing + $blueSkySocketUrl = "wss://jetstream2.us-$( + 'east','west'|Get-Random + ).bsky.network/subscribe?$(@( + "wantedCollections=app.bsky.feed.post" + ) -join '&')" + websocket $blueSkySocketUrl -Watch | + % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"} + .EXAMPLE websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post .EXAMPLE + # Watch BlueSky, but just the emoji websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | Foreach-Object { $in = $_ @@ -20,7 +41,7 @@ function Get-WebSocket { } .EXAMPLE $emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)' - websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | + websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | Foreach-Object { $in = $_ $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7)) @@ -37,8 +58,6 @@ function Get-WebSocket { Foreach-Object { $_.commit.record.embed.external.uri } - .EXAMPLE - #> [CmdletBinding(PositionalBinding=$false)] param( diff --git a/README.ps.md b/README.ps.md index a6fee75..c3a7d5f 100644 --- a/README.ps.md +++ b/README.ps.md @@ -1,5 +1,5 @@
- WebSocket Logo (Animated) + WebSocket Logo (Animated)
# WebSocket From b0b979c7dc68feb86f2b2d4bfb97438dfdc07759 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sat, 30 Nov 2024 21:20:30 +0000 Subject: [PATCH 25/60] docs: More Get-WebSocket examples ( Fixes #27 ) --- README.md | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5987a0a..fb45508 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@
- WebSocket Logo (Animated) + WebSocket Logo (Animated)
# WebSocket @@ -46,17 +46,40 @@ To stop watching a websocket, simply stop the background job. ~~~powershell # Create a WebSocket job that connects to a WebSocket and outputs the results. -Get-WebSocket -WebSocketUri "wss://localhost:9669" +Get-WebSocket -WebSocketUri "wss://localhost:9669/" ~~~ #### Get-WebSocket Example 2 ~~~powershell # Get is the default verb, so we can just say WebSocket. -websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post +# `-Watch` will output a continous stream of objects from the websocket. +# For example, let's Watch BlueSky, but just the text. +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | + % { + $_.commit.record.text + } ~~~ #### Get-WebSocket Example 3 ~~~powershell +# Watch BlueSky, but just the text and spacing +$blueSkySocketUrl = "wss://jetstream2.us-$( + 'east','west'|Get-Random +).bsky.network/subscribe?$(@( + "wantedCollections=app.bsky.feed.post" +) -join '&')" +websocket $blueSkySocketUrl -Watch | + % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"} +~~~ + #### Get-WebSocket Example 4 + +~~~powershell +websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post +~~~ + #### Get-WebSocket Example 5 + +~~~powershell +# Watch BlueSky, but just the emoji websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | Foreach-Object { $in = $_ @@ -65,11 +88,11 @@ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.f } } ~~~ - #### Get-WebSocket Example 4 + #### Get-WebSocket Example 6 ~~~powershell $emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)' -websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | Foreach-Object { $in = $_ $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7)) @@ -79,7 +102,7 @@ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.f } } ~~~ - #### Get-WebSocket Example 5 + #### Get-WebSocket Example 7 ~~~powershell websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | @@ -90,9 +113,4 @@ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app. $_.commit.record.embed.external.uri } ~~~ - #### Get-WebSocket Example 6 - -~~~powershell - -~~~ From 3fe73fd468fcc99cc442f2fb59eeaa933066fa16 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sat, 30 Nov 2024 21:20:38 +0000 Subject: [PATCH 26/60] docs: More Get-WebSocket examples ( Fixes #27 ) --- docs/Get-WebSocket.md | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/docs/Get-WebSocket.md b/docs/Get-WebSocket.md index b96dd5d..7262b39 100644 --- a/docs/Get-WebSocket.md +++ b/docs/Get-WebSocket.md @@ -8,7 +8,11 @@ WebSockets in PowerShell. ### Description -Get-WebSocket allows you to connect to a websocket and handle the output. +Get-WebSocket gets a websocket. + +This will create a job that connects to a WebSocket and outputs the results. + +If the `-Watch` parameter is provided, will output a continous stream of objects from the websocket. --- @@ -16,14 +20,35 @@ Get-WebSocket allows you to connect to a websocket and handle the output. Create a WebSocket job that connects to a WebSocket and outputs the results. ```PowerShell -Get-WebSocket -WebSocketUri "wss://localhost:9669" +Get-WebSocket -WebSocketUri "wss://localhost:9669/" ``` Get is the default verb, so we can just say WebSocket. +`-Watch` will output a continous stream of objects from the websocket. +For example, let's Watch BlueSky, but just the text. + +```PowerShell +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | + % { + $_.commit.record.text + } +``` +Watch BlueSky, but just the text and spacing + +```PowerShell +$blueSkySocketUrl = "wss://jetstream2.us-$( + 'east','west'|Get-Random +).bsky.network/subscribe?$(@( + "wantedCollections=app.bsky.feed.post" +) -join '&')" +websocket $blueSkySocketUrl -Watch | + % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"} +``` +> EXAMPLE 4 ```PowerShell websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post ``` -> EXAMPLE 3 +Watch BlueSky, but just the emoji ```PowerShell websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | @@ -34,11 +59,11 @@ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.f } } ``` -> EXAMPLE 4 +> EXAMPLE 6 ```PowerShell $emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)' -websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | Foreach-Object { $in = $_ $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7)) @@ -48,7 +73,7 @@ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.f } } ``` -> EXAMPLE 5 +> EXAMPLE 7 ```PowerShell websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | @@ -59,7 +84,6 @@ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app. $_.commit.record.embed.external.uri } ``` -> EXAMPLE 6 --- From 2597cccb50630df50a2d8f1cff9cdc87d7d4be0b Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sat, 30 Nov 2024 21:20:38 +0000 Subject: [PATCH 27/60] docs: More Get-WebSocket examples ( Fixes #27 ) --- docs/_data/Help/Get-WebSocket.json | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/_data/Help/Get-WebSocket.json b/docs/_data/Help/Get-WebSocket.json index fb114fd..54b5640 100644 --- a/docs/_data/Help/Get-WebSocket.json +++ b/docs/_data/Help/Get-WebSocket.json @@ -1,6 +1,6 @@ { "Synopsis": "WebSockets in PowerShell.", - "Description": "Get-WebSocket allows you to connect to a websocket and handle the output.", + "Description": "Get-WebSocket gets a websocket.\n\nThis will create a job that connects to a WebSocket and outputs the results.\n\nIf the `-Watch` parameter is provided, will output a continous stream of objects from the websocket.", "Parameters": [ { "Name": null, @@ -33,32 +33,37 @@ { "Title": "EXAMPLE 1", "Markdown": "Create a WebSocket job that connects to a WebSocket and outputs the results.", - "Code": "Get-WebSocket -WebSocketUri \"wss://localhost:9669\"" + "Code": "Get-WebSocket -WebSocketUri \"wss://localhost:9669/\"" }, { "Title": "EXAMPLE 2", - "Markdown": "Get is the default verb, so we can just say WebSocket.", - "Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post" + "Markdown": "Get is the default verb, so we can just say WebSocket.\n`-Watch` will output a continous stream of objects from the websocket.\nFor example, let's Watch BlueSky, but just the text. ", + "Code": "websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |\n % { \n $_.commit.record.text\n }" }, { "Title": "EXAMPLE 3", - "Markdown": "", - "Code": "websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n if ($in.commit.record.text -match '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}]+') {\n Write-Host $matches.0 -NoNewline\n }\n }" + "Markdown": "Watch BlueSky, but just the text and spacing", + "Code": "$blueSkySocketUrl = \"wss://jetstream2.us-$(\n 'east','west'|Get-Random\n).bsky.network/subscribe?$(@(\n \"wantedCollections=app.bsky.feed.post\"\n) -join '&')\"\nwebsocket $blueSkySocketUrl -Watch | \n % { Write-Host \"$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))\"}" }, { "Title": "EXAMPLE 4", "Markdown": "", - "Code": "$emojiPattern = '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}\\p{IsVariationSelectors}\\p{IsCombiningHalfMarks}]+)'\nwebsocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))\n if ($in.commit.record.text -match \"(?>(?:$emojiPattern|\\#\\w+)\") {\n $match = $matches.0 \n Write-Host $spacing,$match,$spacing -NoNewline\n }\n }" + "Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post" }, { "Title": "EXAMPLE 5", - "Markdown": "", - "Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |\n Where-Object {\n $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external'\n } |\n Foreach-Object {\n $_.commit.record.embed.external.uri\n }" + "Markdown": "Watch BlueSky, but just the emoji", + "Code": "websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n if ($in.commit.record.text -match '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}]+') {\n Write-Host $matches.0 -NoNewline\n }\n }" }, { "Title": "EXAMPLE 6", "Markdown": "", - "Code": "" + "Code": "$emojiPattern = '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}\\p{IsVariationSelectors}\\p{IsCombiningHalfMarks}]+)'\nwebsocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))\n if ($in.commit.record.text -match \"(?>(?:$emojiPattern|\\#\\w+)\") {\n $match = $matches.0 \n Write-Host $spacing,$match,$spacing -NoNewline\n }\n }" + }, + { + "Title": "EXAMPLE 7", + "Markdown": "", + "Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |\n Where-Object {\n $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external'\n } |\n Foreach-Object {\n $_.commit.record.embed.external.uri\n }" } ] } \ No newline at end of file From 6d93bcf5cc83f8ed0c271c9a8b61d9d23010646c Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sat, 30 Nov 2024 21:20:38 +0000 Subject: [PATCH 28/60] docs: More Get-WebSocket examples ( Fixes #27 ) --- docs/README.md | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/docs/README.md b/docs/README.md index 1825ffa..4a6f5f7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,5 @@
- WebSocket Logo (Animated) + WebSocket Logo (Animated)
# WebSocket @@ -46,17 +46,40 @@ To stop watching a websocket, simply stop the background job. ~~~powershell # Create a WebSocket job that connects to a WebSocket and outputs the results. -Get-WebSocket -WebSocketUri "wss://localhost:9669" +Get-WebSocket -WebSocketUri "wss://localhost:9669/" ~~~ #### Get-WebSocket Example 2 ~~~powershell # Get is the default verb, so we can just say WebSocket. -websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post +# `-Watch` will output a continous stream of objects from the websocket. +# For example, let's Watch BlueSky, but just the text. +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | + % { + $_.commit.record.text + } ~~~ #### Get-WebSocket Example 3 ~~~powershell +# Watch BlueSky, but just the text and spacing +$blueSkySocketUrl = "wss://jetstream2.us-$( + 'east','west'|Get-Random +).bsky.network/subscribe?$(@( + "wantedCollections=app.bsky.feed.post" +) -join '&')" +websocket $blueSkySocketUrl -Watch | + % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"} +~~~ + #### Get-WebSocket Example 4 + +~~~powershell +websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post +~~~ + #### Get-WebSocket Example 5 + +~~~powershell +# Watch BlueSky, but just the emoji websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | Foreach-Object { $in = $_ @@ -65,11 +88,11 @@ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.f } } ~~~ - #### Get-WebSocket Example 4 + #### Get-WebSocket Example 6 ~~~powershell $emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)' -websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | Foreach-Object { $in = $_ $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7)) @@ -79,7 +102,7 @@ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.f } } ~~~ - #### Get-WebSocket Example 5 + #### Get-WebSocket Example 7 ~~~powershell websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | @@ -90,8 +113,3 @@ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app. $_.commit.record.embed.external.uri } ~~~ - #### Get-WebSocket Example 6 - -~~~powershell - -~~~ From 1ed74965eca7b29e813301bf965faa773ec019c7 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sat, 30 Nov 2024 21:20:38 +0000 Subject: [PATCH 29/60] docs: More Get-WebSocket examples ( Fixes #27 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From de0cede785849100313c753f0c0a3384d44689f9 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Sat, 30 Nov 2024 21:20:41 +0000 Subject: [PATCH 30/60] docs: More Get-WebSocket examples ( Fixes #27 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From b11e8ee220e10fa8626f77941e00eb344fa69d8c Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Sat, 30 Nov 2024 13:20:53 -0800 Subject: [PATCH 31/60] docs: Get-WebSocket aliasing ( Fixes #28 ) --- Commands/Get-WebSocket.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Commands/Get-WebSocket.ps1 b/Commands/Get-WebSocket.ps1 index cbf1689..d6d3a47 100644 --- a/Commands/Get-WebSocket.ps1 +++ b/Commands/Get-WebSocket.ps1 @@ -60,6 +60,7 @@ function Get-WebSocket { } #> [CmdletBinding(PositionalBinding=$false)] + [Alias('WebSocket')] param( # The Uri of the WebSocket to connect to. [Parameter(Position=0,ValueFromPipelineByPropertyName)] From d525f2871eb377792c66a541a5a75adfba4b64b8 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sat, 30 Nov 2024 21:23:04 +0000 Subject: [PATCH 32/60] docs: Get-WebSocket aliasing ( Fixes #28 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From 55ca8430777ed2ad26bb77e691a9d728e3650a3d Mon Sep 17 00:00:00 2001 From: James Brundage Date: Sat, 30 Nov 2024 21:23:08 +0000 Subject: [PATCH 33/60] docs: Get-WebSocket aliasing ( Fixes #28 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From df9ebb4e5bf73c26dd7504970b71a3d37afc71c4 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Tue, 3 Dec 2024 16:43:09 -0800 Subject: [PATCH 34/60] feat: Get-WebSocket -WatchFor ( Fixes #29 ) --- Commands/Get-WebSocket.ps1 | 85 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 4 deletions(-) diff --git a/Commands/Get-WebSocket.ps1 b/Commands/Get-WebSocket.ps1 index d6d3a47..1644756 100644 --- a/Commands/Get-WebSocket.ps1 +++ b/Commands/Get-WebSocket.ps1 @@ -7,7 +7,7 @@ function Get-WebSocket { This will create a job that connects to a WebSocket and outputs the results. - If the `-Watch` parameter is provided, will output a continous stream of objects from the websocket. + If the `-Watch` parameter is provided, will output a continous stream of objects. .EXAMPLE # Create a WebSocket job that connects to a WebSocket and outputs the results. Get-WebSocket -WebSocketUri "wss://localhost:9669/" @@ -58,6 +58,33 @@ function Get-WebSocket { Foreach-Object { $_.commit.record.embed.external.uri } + .EXAMPLE + # BlueSky, but just the hashtags + websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$webSocketoutput.commit.record.text -match "\#\w+"}={ + $matches.0 + } + } + .EXAMPLE + # BlueSky, but just the hashtags (as links) + websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$webSocketoutput.commit.record.text -match "\#\w+"}={ + if ($psStyle.FormatHyperlink) { + $psStyle.FormatHyperlink($matches.0, "https://bsky.app/search?q=$([Web.HttpUtility]::UrlEncode($matches.0))") + } else { + $matches.0 + } + } + } + .EXAMPLE + websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$args.commit.record.text -match "\#\w+"}={ + $matches.0 + } + {$args.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+'}={ + $matches.0 + } + } #> [CmdletBinding(PositionalBinding=$false)] [Alias('WebSocket')] @@ -72,6 +99,7 @@ function Get-WebSocket { $Handler, # Any variables to declare in the WebSocket job. + # These variables will also be added to the job as properties. [Collections.IDictionary] $Variable = @{}, @@ -109,6 +137,28 @@ function Get-WebSocket { [switch] $Watch, + # If set, will watch the output of a WebSocket job for one or more conditions. + # The conditions are the keys of the dictionary, and can be a regex, a string, or a scriptblock. + # The values of the dictionary are what will happen when a match is found. + [ValidateScript({ + $keys = $_.Keys + $values = $_.values + foreach ($key in $keys) { + if ($key -isnot [scriptblock]) { + throw "Keys '$key' must be a scriptblock" + } + } + foreach ($value in $values) { + if ($value -isnot [scriptblock] -and $value -isnot [string]) { + throw "Value '$value' must be a string or scriptblock" + } + } + return $true + })] + [Alias('WhereFor','Wherefore')] + [Collections.IDictionary] + $WatchFor, + # The timeout for the WebSocket connection. If this is provided, after the timeout elapsed, the WebSocket will be closed. [TimeSpan] $TimeOut, @@ -167,8 +217,7 @@ function Get-WebSocket { $Variable.WebSocket = $ws $MessageCount = [long]0 - - + while ($true) { if ($ws.State -ne 'Open') {break } if ($TimeOut -and ([DateTime]::Now - $webSocketStartTime) -gt $TimeOut) { @@ -275,7 +324,35 @@ function Get-WebSocket { 7, 11, 13, 17, 19, 23 | Get-Random ) } while ($webSocketJob.State -in 'Running','NotStarted') - } else { + } + elseif ($WatchFor) { + . { + do { + $webSocketJob | Receive-Job + Start-Sleep -Milliseconds ( + 7, 11, 13, 17, 19, 23 | Get-Random + ) + } while ($webSocketJob.State -in 'Running','NotStarted') + } | . { + process { + $webSocketOutput = $_ + foreach ($key in @($WatchFor.Keys)) { + $result = + if ($key -is [ScriptBlock]) { + . $key $webSocketOutput + } + + if (-not $result) { continue } + if ($WatchFor[$key] -is [ScriptBlock]) { + $webSocketOutput | . $WatchFor[$key] + } else { + $WatchFor[$key] + } + } + } + } + } + else { $webSocketJob } } From 9734a057d5334c4bb2c400c4b0b621cb28a77e95 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 00:45:39 +0000 Subject: [PATCH 35/60] feat: Get-WebSocket -WatchFor ( Fixes #29 ) --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index fb45508..2180a22 100644 --- a/README.md +++ b/README.md @@ -113,4 +113,40 @@ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app. $_.commit.record.embed.external.uri } ~~~ + #### Get-WebSocket Example 8 + +~~~powershell +# BlueSky, but just the hashtags +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$webSocketoutput.commit.record.text -match "\#\w+"}={ + $matches.0 + } +} +~~~ + #### Get-WebSocket Example 9 + +~~~powershell +# BlueSky, but just the hashtags (as links) +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$webSocketoutput.commit.record.text -match "\#\w+"}={ + if ($psStyle.FormatHyperlink) { + $psStyle.FormatHyperlink($matches.0, "https://bsky.app/search?q=$([Web.HttpUtility]::UrlEncode($matches.0))") + } else { + $matches.0 + } + } +} +~~~ + #### Get-WebSocket Example 10 + +~~~powershell +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$args.commit.record.text -match "\#\w+"}={ + $matches.0 + } + {$args.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+'}={ + $matches.0 + } +} +~~~ From a8ae39bdddfc1dbe4e73ea35e7a1bb969024eb65 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 00:45:49 +0000 Subject: [PATCH 36/60] feat: Get-WebSocket -WatchFor ( Fixes #29 ) --- docs/Get-WebSocket.md | 48 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/docs/Get-WebSocket.md b/docs/Get-WebSocket.md index 7262b39..4efc78d 100644 --- a/docs/Get-WebSocket.md +++ b/docs/Get-WebSocket.md @@ -12,7 +12,7 @@ Get-WebSocket gets a websocket. This will create a job that connects to a WebSocket and outputs the results. -If the `-Watch` parameter is provided, will output a continous stream of objects from the websocket. +If the `-Watch` parameter is provided, will output a continous stream of objects. --- @@ -84,6 +84,40 @@ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app. $_.commit.record.embed.external.uri } ``` +BlueSky, but just the hashtags + +```PowerShell +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$webSocketoutput.commit.record.text -match "\#\w+"}={ + $matches.0 + } +} +``` +BlueSky, but just the hashtags (as links) + +```PowerShell +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$webSocketoutput.commit.record.text -match "\#\w+"}={ + if ($psStyle.FormatHyperlink) { + $psStyle.FormatHyperlink($matches.0, "https://bsky.app/search?q=$([Web.HttpUtility]::UrlEncode($matches.0))") + } else { + $matches.0 + } + } +} +``` +> EXAMPLE 10 + +```PowerShell +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$args.commit.record.text -match "\#\w+"}={ + $matches.0 + } + {$args.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+'}={ + $matches.0 + } +} +``` --- @@ -104,6 +138,7 @@ A ScriptBlock that will handle the output of the WebSocket. #### **Variable** Any variables to declare in the WebSocket job. +These variables will also be added to the job as properties. |Type |Required|Position|PipelineInput| |---------------|--------|--------|-------------| @@ -166,6 +201,15 @@ If set, will watch the output of the WebSocket job, outputting results continuou |----------|--------|--------|-------------|-------| |`[Switch]`|false |named |false |Tail | +#### **WatchFor** +If set, will watch the output of a WebSocket job for one or more conditions. +The conditions are the keys of the dictionary, and can be a regex, a string, or a scriptblock. +The values of the dictionary are what will happen when a match is found. + +|Type |Required|Position|PipelineInput|Aliases | +|---------------|--------|--------|-------------|----------------------| +|`[IDictionary]`|false |named |false |WhereFor
Wherefore| + #### **TimeOut** The timeout for the WebSocket connection. If this is provided, after the timeout elapsed, the WebSocket will be closed. @@ -208,5 +252,5 @@ RunspacePools allow you to limit the scope of the handler to a pool of runspaces ### Syntax ```PowerShell -Get-WebSocket [[-WebSocketUri] ] [-Handler ] [-Variable ] [-Name ] [-InitializationScript ] [-BufferSize ] [-OnConnect ] [-OnError ] [-OnOutput ] [-OnWarning ] [-Watch] [-TimeOut ] [-Maximum ] [-ConnectionTimeout ] [-Runspace ] [-RunspacePool ] [] +Get-WebSocket [[-WebSocketUri] ] [-Handler ] [-Variable ] [-Name ] [-InitializationScript ] [-BufferSize ] [-OnConnect ] [-OnError ] [-OnOutput ] [-OnWarning ] [-Watch] [-WatchFor ] [-TimeOut ] [-Maximum ] [-ConnectionTimeout ] [-Runspace ] [-RunspacePool ] [] ``` From df5c90464e537c3f300c92002fc7f84e7fc76dcc Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 00:45:49 +0000 Subject: [PATCH 37/60] feat: Get-WebSocket -WatchFor ( Fixes #29 ) --- docs/_data/Help/Get-WebSocket.json | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/_data/Help/Get-WebSocket.json b/docs/_data/Help/Get-WebSocket.json index 54b5640..912942c 100644 --- a/docs/_data/Help/Get-WebSocket.json +++ b/docs/_data/Help/Get-WebSocket.json @@ -1,6 +1,6 @@ { "Synopsis": "WebSockets in PowerShell.", - "Description": "Get-WebSocket gets a websocket.\n\nThis will create a job that connects to a WebSocket and outputs the results.\n\nIf the `-Watch` parameter is provided, will output a continous stream of objects from the websocket.", + "Description": "Get-WebSocket gets a websocket.\n\nThis will create a job that connects to a WebSocket and outputs the results.\n\nIf the `-Watch` parameter is provided, will output a continous stream of objects.", "Parameters": [ { "Name": null, @@ -64,6 +64,21 @@ "Title": "EXAMPLE 7", "Markdown": "", "Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |\n Where-Object {\n $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external'\n } |\n Foreach-Object {\n $_.commit.record.embed.external.uri\n }" + }, + { + "Title": "EXAMPLE 8", + "Markdown": "BlueSky, but just the hashtags", + "Code": "websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{\n {$webSocketoutput.commit.record.text -match \"\\#\\w+\"}={\n $matches.0\n } \n}" + }, + { + "Title": "EXAMPLE 9", + "Markdown": "BlueSky, but just the hashtags (as links)", + "Code": "websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{\n {$webSocketoutput.commit.record.text -match \"\\#\\w+\"}={\n if ($psStyle.FormatHyperlink) {\n $psStyle.FormatHyperlink($matches.0, \"https://bsky.app/search?q=$([Web.HttpUtility]::UrlEncode($matches.0))\")\n } else {\n $matches.0\n }\n }\n}" + }, + { + "Title": "EXAMPLE 10", + "Markdown": "", + "Code": "websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{\n {$args.commit.record.text -match \"\\#\\w+\"}={\n $matches.0\n }\n {$args.commit.record.text -match '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}]+'}={\n $matches.0\n }\n}" } ] } \ No newline at end of file From 675cdd622ba0151868156e755eda6940f46c8eac Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 00:45:49 +0000 Subject: [PATCH 38/60] feat: Get-WebSocket -WatchFor ( Fixes #29 ) --- docs/README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/README.md b/docs/README.md index 4a6f5f7..8ef65a9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -113,3 +113,39 @@ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app. $_.commit.record.embed.external.uri } ~~~ + #### Get-WebSocket Example 8 + +~~~powershell +# BlueSky, but just the hashtags +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$webSocketoutput.commit.record.text -match "\#\w+"}={ + $matches.0 + } +} +~~~ + #### Get-WebSocket Example 9 + +~~~powershell +# BlueSky, but just the hashtags (as links) +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$webSocketoutput.commit.record.text -match "\#\w+"}={ + if ($psStyle.FormatHyperlink) { + $psStyle.FormatHyperlink($matches.0, "https://bsky.app/search?q=$([Web.HttpUtility]::UrlEncode($matches.0))") + } else { + $matches.0 + } + } +} +~~~ + #### Get-WebSocket Example 10 + +~~~powershell +websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -WatchFor @{ + {$args.commit.record.text -match "\#\w+"}={ + $matches.0 + } + {$args.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+'}={ + $matches.0 + } +} +~~~ From 0957e7ba9b9b3191be505f83ffbe2dd2bd6dc85a Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 00:45:50 +0000 Subject: [PATCH 39/60] feat: Get-WebSocket -WatchFor ( Fixes #29 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From ced404e1fd23643a870454d97d57d92d0283cf39 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Wed, 4 Dec 2024 00:45:53 +0000 Subject: [PATCH 40/60] feat: Get-WebSocket -WatchFor ( Fixes #29 ) --- docs/_data/LastDateBuilt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_data/LastDateBuilt.json b/docs/_data/LastDateBuilt.json index 55437ce..8dd806a 100644 --- a/docs/_data/LastDateBuilt.json +++ b/docs/_data/LastDateBuilt.json @@ -1 +1 @@ -"2024-11-30" \ No newline at end of file +"2024-12-04" \ No newline at end of file From 575873892c2e48cb3e146d4d07be0df3f7f04a6b Mon Sep 17 00:00:00 2001 From: James Brundage Date: Wed, 4 Dec 2024 00:45:53 +0000 Subject: [PATCH 41/60] feat: Get-WebSocket -WatchFor ( Fixes #29 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From a34e86269460bd19da9779ce637712d3e04123ab Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Tue, 3 Dec 2024 19:27:03 -0800 Subject: [PATCH 42/60] feat: Get-WebSocket -RawText ( Fixes #30 ) --- Commands/Get-WebSocket.ps1 | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Commands/Get-WebSocket.ps1 b/Commands/Get-WebSocket.ps1 index 1644756..f36989d 100644 --- a/Commands/Get-WebSocket.ps1 +++ b/Commands/Get-WebSocket.ps1 @@ -137,6 +137,11 @@ function Get-WebSocket { [switch] $Watch, + # If set, will output the raw text of the WebSocket job. + [Alias('Raw')] + [switch] + $RawText, + # If set, will watch the output of a WebSocket job for one or more conditions. # The conditions are the keys of the dictionary, and can be a regex, a string, or a scriptblock. # The values of the dictionary are what will happen when a match is found. @@ -230,15 +235,20 @@ function Get-WebSocket { break } - $Buf = [byte[]]::new($BufferSize) $Seg = [ArraySegment[byte]]::new($Buf) $null = $ws.ReceiveAsync($Seg, $CT).Wait() $MessageCount++ - $JS = $OutputEncoding.GetString($Buf, 0, $Buf.Count) - if ([string]::IsNullOrWhitespace($JS)) { continue } - try { - $webSocketMessage = ConvertFrom-Json $JS + + try { + $webSocketMessage = + if ($Raw) { + $OutputEncoding.GetString($Buf, 0, $Buf.Count) + } else { + $JS = $OutputEncoding.GetString($Buf, 0, $Buf.Count) + if ([string]::IsNullOrWhitespace($JS)) { continue } + ConvertFrom-Json $JS + } if ($handler) { $psCmd = if ($runspace.LanguageMode -eq 'NoLanguage' -or @@ -318,7 +328,7 @@ function Get-WebSocket { } $webSocketJob.pstypenames.insert(0, 'WebSocketJob') if ($Watch) { - do { + do { $webSocketJob | Receive-Job Start-Sleep -Milliseconds ( 7, 11, 13, 17, 19, 23 | Get-Random From de0d484fb17da70609627093df85046cf906122b Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 03:29:22 +0000 Subject: [PATCH 43/60] feat: Get-WebSocket -RawText ( Fixes #30 ) --- docs/Get-WebSocket.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/Get-WebSocket.md b/docs/Get-WebSocket.md index 4efc78d..e36f944 100644 --- a/docs/Get-WebSocket.md +++ b/docs/Get-WebSocket.md @@ -201,6 +201,13 @@ If set, will watch the output of the WebSocket job, outputting results continuou |----------|--------|--------|-------------|-------| |`[Switch]`|false |named |false |Tail | +#### **RawText** +If set, will output the raw text of the WebSocket job. + +|Type |Required|Position|PipelineInput|Aliases| +|----------|--------|--------|-------------|-------| +|`[Switch]`|false |named |false |Raw | + #### **WatchFor** If set, will watch the output of a WebSocket job for one or more conditions. The conditions are the keys of the dictionary, and can be a regex, a string, or a scriptblock. @@ -252,5 +259,5 @@ RunspacePools allow you to limit the scope of the handler to a pool of runspaces ### Syntax ```PowerShell -Get-WebSocket [[-WebSocketUri] ] [-Handler ] [-Variable ] [-Name ] [-InitializationScript ] [-BufferSize ] [-OnConnect ] [-OnError ] [-OnOutput ] [-OnWarning ] [-Watch] [-WatchFor ] [-TimeOut ] [-Maximum ] [-ConnectionTimeout ] [-Runspace ] [-RunspacePool ] [] +Get-WebSocket [[-WebSocketUri] ] [-Handler ] [-Variable ] [-Name ] [-InitializationScript ] [-BufferSize ] [-OnConnect ] [-OnError ] [-OnOutput ] [-OnWarning ] [-Watch] [-RawText] [-WatchFor ] [-TimeOut ] [-Maximum ] [-ConnectionTimeout ] [-Runspace ] [-RunspacePool ] [] ``` From 03883c9530b0b0047db7f249ff819d5e9a8f7303 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 03:29:22 +0000 Subject: [PATCH 44/60] feat: Get-WebSocket -RawText ( Fixes #30 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From 62176f2769406bb5e8a36cd41cdb1ec71a9b9c9c Mon Sep 17 00:00:00 2001 From: James Brundage Date: Wed, 4 Dec 2024 03:29:25 +0000 Subject: [PATCH 45/60] feat: Get-WebSocket -RawText ( Fixes #30 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From b00340c50c07e409f498175223d70aecb658ba62 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Tue, 3 Dec 2024 19:30:40 -0800 Subject: [PATCH 46/60] feat: Get-WebSocket -Binary ( Fixes #31 ) --- Commands/Get-WebSocket.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Commands/Get-WebSocket.ps1 b/Commands/Get-WebSocket.ps1 index f36989d..394ee74 100644 --- a/Commands/Get-WebSocket.ps1 +++ b/Commands/Get-WebSocket.ps1 @@ -137,11 +137,16 @@ function Get-WebSocket { [switch] $Watch, - # If set, will output the raw text of the WebSocket job. + # If set, will output the raw text that comes out of the WebSocket. [Alias('Raw')] [switch] $RawText, + # If set, will output the raw bytes that come out of the WebSocket. + [Alias('RawByte','RawBytes','Bytes','Byte')] + [switch] + $Binary, + # If set, will watch the output of a WebSocket job for one or more conditions. # The conditions are the keys of the dictionary, and can be a regex, a string, or a scriptblock. # The values of the dictionary are what will happen when a match is found. From d967dbde0244e57e47ced22f1cfe01e37bbb71a0 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 03:32:56 +0000 Subject: [PATCH 47/60] feat: Get-WebSocket -Binary ( Fixes #31 ) --- docs/Get-WebSocket.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/Get-WebSocket.md b/docs/Get-WebSocket.md index e36f944..5ad9b74 100644 --- a/docs/Get-WebSocket.md +++ b/docs/Get-WebSocket.md @@ -202,12 +202,19 @@ If set, will watch the output of the WebSocket job, outputting results continuou |`[Switch]`|false |named |false |Tail | #### **RawText** -If set, will output the raw text of the WebSocket job. +If set, will output the raw text that comes out of the WebSocket. |Type |Required|Position|PipelineInput|Aliases| |----------|--------|--------|-------------|-------| |`[Switch]`|false |named |false |Raw | +#### **Binary** +If set, will output the raw bytes that come out of the WebSocket. + +|Type |Required|Position|PipelineInput|Aliases | +|----------|--------|--------|-------------|---------------------------------------| +|`[Switch]`|false |named |false |RawByte
RawBytes
Bytes
Byte| + #### **WatchFor** If set, will watch the output of a WebSocket job for one or more conditions. The conditions are the keys of the dictionary, and can be a regex, a string, or a scriptblock. @@ -259,5 +266,5 @@ RunspacePools allow you to limit the scope of the handler to a pool of runspaces ### Syntax ```PowerShell -Get-WebSocket [[-WebSocketUri] ] [-Handler ] [-Variable ] [-Name ] [-InitializationScript ] [-BufferSize ] [-OnConnect ] [-OnError ] [-OnOutput ] [-OnWarning ] [-Watch] [-RawText] [-WatchFor ] [-TimeOut ] [-Maximum ] [-ConnectionTimeout ] [-Runspace ] [-RunspacePool ] [] +Get-WebSocket [[-WebSocketUri] ] [-Handler ] [-Variable ] [-Name ] [-InitializationScript ] [-BufferSize ] [-OnConnect ] [-OnError ] [-OnOutput ] [-OnWarning ] [-Watch] [-RawText] [-Binary] [-WatchFor ] [-TimeOut ] [-Maximum ] [-ConnectionTimeout ] [-Runspace ] [-RunspacePool ] [] ``` From a1e36f373d5ca10b6c78ef129cb95d99096a8caf Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 03:32:57 +0000 Subject: [PATCH 48/60] feat: Get-WebSocket -Binary ( Fixes #31 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From cb2ec591306f6d463b462d98b242e12ab1ab68eb Mon Sep 17 00:00:00 2001 From: James Brundage Date: Wed, 4 Dec 2024 03:33:00 +0000 Subject: [PATCH 49/60] feat: Get-WebSocket -Binary ( Fixes #31 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From e9572ae8dd2221123587e89e08d56e30b706878c Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Tue, 3 Dec 2024 19:35:22 -0800 Subject: [PATCH 50/60] feat: Sponsorship Support ( Fixes #14 ) --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..36bd853 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [StartAutomating] From 2ba3410c001c6acc57b14354d317ef620638163d Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Tue, 3 Dec 2024 19:40:14 -0800 Subject: [PATCH 51/60] feat: Get-WebSocket -Binary ( Fixes #31 ) --- Commands/Get-WebSocket.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Commands/Get-WebSocket.ps1 b/Commands/Get-WebSocket.ps1 index 394ee74..d40e351 100644 --- a/Commands/Get-WebSocket.ps1 +++ b/Commands/Get-WebSocket.ps1 @@ -247,7 +247,9 @@ function Get-WebSocket { try { $webSocketMessage = - if ($Raw) { + if ($Binary) { + $Buf + } elseif ($RawText) { $OutputEncoding.GetString($Buf, 0, $Buf.Count) } else { $JS = $OutputEncoding.GetString($Buf, 0, $Buf.Count) From 4f5d359999bd6fe5fa8ba9030faffb922fbbcfe5 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 03:42:30 +0000 Subject: [PATCH 52/60] feat: Get-WebSocket -Binary ( Fixes #31 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From 7ef90bc76f6cbc9f0ea5c5055d56e9378c144fe3 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Wed, 4 Dec 2024 03:42:32 +0000 Subject: [PATCH 53/60] feat: Get-WebSocket -Binary ( Fixes #31 ) --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From 71e97dccca8d910cb0ad7c74a24a20f8a5e263fc Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Tue, 3 Dec 2024 19:53:27 -0800 Subject: [PATCH 54/60] feat: Get-WebSocket -Binary ( Fixes #31 ) Returning only non-zero bytes --- Commands/Get-WebSocket.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/Get-WebSocket.ps1 b/Commands/Get-WebSocket.ps1 index d40e351..45e28eb 100644 --- a/Commands/Get-WebSocket.ps1 +++ b/Commands/Get-WebSocket.ps1 @@ -248,7 +248,7 @@ function Get-WebSocket { try { $webSocketMessage = if ($Binary) { - $Buf + $Buf -gt 0 } elseif ($RawText) { $OutputEncoding.GetString($Buf, 0, $Buf.Count) } else { From 94e2476e26249892560a900679ac37f1ad5d0a63 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 03:55:56 +0000 Subject: [PATCH 55/60] feat: Get-WebSocket -Binary ( Fixes #31 ) Returning only non-zero bytes --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From 249dfe87ea601688676730ecf4c46c1949025d33 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Wed, 4 Dec 2024 03:55:59 +0000 Subject: [PATCH 56/60] feat: Get-WebSocket -Binary ( Fixes #31 ) Returning only non-zero bytes --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file + From 55e448071b95a4c110d2615f5b0a8c7c3fe62044 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Tue, 3 Dec 2024 20:09:39 -0800 Subject: [PATCH 57/60] release: WebSocket 0.1.1 Updating Release Notes and CHANGELOG --- CHANGELOG.md | 22 ++++++++++++++++++++-- WebSocket.psd1 | 29 ++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abb0512..6f73da7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,26 @@ -## WebSocket 0.1 - > Like It? [Star It](https://github.com/PowerShellWeb/WebSocket) > Love It? [Support It](https://github.com/sponsors/StartAutomating) +## WebSocket 0.1.1 + +* WebSocket GitHub Action + * Run any `*.WebSocket.ps1` files in a repository (#24) +* WebSocket container updates + * Container now runs mounted `*.WebSocket.ps1` files (#26) +* Get-WebSocket improvements: + * New Parameters: + * -Maximum (#22) + * -TimeOut (#23) + * -WatchFor (#29) + * -RawText (#30) + * -Binary (#31) +* WebSocket Testing (#25) +* Adding FUNDING.yml (#14) + +--- + +## WebSocket 0.1 + * Initial Release of WebSocket module * Get-WebSocket gets content from a WebSocket * Docker container for WebSocket diff --git a/WebSocket.psd1 b/WebSocket.psd1 index 8cdbd37..0441f61 100644 --- a/WebSocket.psd1 +++ b/WebSocket.psd1 @@ -1,5 +1,5 @@ @{ - ModuleVersion = '0.1' + ModuleVersion = '0.1.1' RootModule = 'WebSocket.psm1' Guid = '75c70c8b-e5eb-4a60-982e-a19110a1185d' Author = 'James Brundage' @@ -12,17 +12,28 @@ ProjectURI = 'https://github.com/PowerShellWeb/WebSocket' LicenseURI = 'https://github.com/PowerShellWeb/WebSocket/blob/main/LICENSE' ReleaseNotes = @' -## WebSocket 0.1 - > Like It? [Star It](https://github.com/PowerShellWeb/WebSocket) > Love It? [Support It](https://github.com/sponsors/StartAutomating) -* Initial Release of WebSocket module - * Get-WebSocket gets content from a WebSocket - * Docker container for WebSocket - * Build Workflow - * WebSocket Logo - * WebSocket website +## WebSocket 0.1.1 + +* WebSocket GitHub Action + * Run any `*.WebSocket.ps1` files in a repository (#24) +* WebSocket container updates + * Container now runs mounted `*.WebSocket.ps1` files (#26) +* Get-WebSocket improvements: + * New Parameters: + * -Maximum (#22) + * -TimeOut (#23) + * -WatchFor (#29) + * -RawText (#30) + * -Binary (#31) +* WebSocket Testing (#25) +* Adding FUNDING.yml (#14) + +--- + +Additional details available in the [CHANGELOG](CHANGELOG.md) '@ } } From a4f1cb5b0a64d8c38a08dd75ea0ed39f3bce84d5 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 04:12:03 +0000 Subject: [PATCH 58/60] release: WebSocket 0.1.1 Updating Release Notes and CHANGELOG --- docs/CHANGELOG.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7aeb592..1020c9d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,8 +1,26 @@ -## WebSocket 0.1 - > Like It? [Star It](https://github.com/PowerShellWeb/WebSocket) > Love It? [Support It](https://github.com/sponsors/StartAutomating) +## WebSocket 0.1.1 + +* WebSocket GitHub Action + * Run any `*.WebSocket.ps1` files in a repository (#24) +* WebSocket container updates + * Container now runs mounted `*.WebSocket.ps1` files (#26) +* Get-WebSocket improvements: + * New Parameters: + * -Maximum (#22) + * -TimeOut (#23) + * -WatchFor (#29) + * -RawText (#30) + * -Binary (#31) +* WebSocket Testing (#25) +* Adding FUNDING.yml (#14) + +--- + +## WebSocket 0.1 + * Initial Release of WebSocket module * Get-WebSocket gets content from a WebSocket * Docker container for WebSocket From 5a1e16cba133ac7cb857b2f966b7e70a8e5d1123 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Wed, 4 Dec 2024 04:12:03 +0000 Subject: [PATCH 59/60] release: WebSocket 0.1.1 Updating Release Notes and CHANGELOG --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d0f2cb..9d96e1c 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - + \ No newline at end of file From 0a303b73d02f6daaa196553ac066dee28fc331bb Mon Sep 17 00:00:00 2001 From: James Brundage Date: Wed, 4 Dec 2024 04:12:07 +0000 Subject: [PATCH 60/60] release: WebSocket 0.1.1 Updating Release Notes and CHANGELOG --- docs/_layouts/Default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_layouts/Default.html b/docs/_layouts/Default.html index 9d96e1c..9d0f2cb 100644 --- a/docs/_layouts/Default.html +++ b/docs/_layouts/Default.html @@ -24,4 +24,4 @@ {{content}} {% include Footer.html %} - \ No newline at end of file +