Skip to content

Commit 00f9fd8

Browse files
Merge pull request #278 from StartAutomating/Posh-Community
Posh community
2 parents db595a6 + 4b3e369 commit 00f9fd8

19 files changed

+368
-15
lines changed

GitHub/Jobs/BuildPosh.psd1 renamed to Build/GitHub/Jobs/BuildPosh.psd1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
name = 'GitLogger'
2828
uses = 'GitLogging/GitLoggerAction@main'
2929
id = 'GitLogger'
30+
},@{
31+
name = 'PSA'
32+
uses = 'StartAutomating/PSA@main'
33+
id = 'PSA'
3034
}
3135
)
3236
}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
#requires -Module Posh
22
#requires -Module PSDevOps
3-
Import-BuildStep -ModuleName Posh
3+
Import-BuildStep -SourcePath (
4+
Join-Path $PSScriptRoot 'GitHub'
5+
) -BuildSystem GitHubWorkflow
6+
47
Push-Location ($PSScriptRoot | Split-Path)
58
New-GitHubWorkflow -Name "Build and Publish Posh" -On Demand, Push -Job TagReleaseAndPublish,
69
TestPowerShellOnLinux,
710
BuildPosh -OutputPath (
811
Join-Path $pwd .\.github\workflows\BuildAndPublishPosh.yml
9-
)
12+
) -Env @{
13+
"AT_PROTOCOL_HANDLE" = "mrpowershell.bsky.social"
14+
"AT_PROTOCOL_APP_PASSWORD" = '${{ secrets.AT_PROTOCOL_APP_PASSWORD }}'
15+
}
1016

1117
Pop-Location

Build/Posh.PSA.ps1

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Any *.PSA.ps1 file will be run when PSA runs.
2+
3+
# A good thing to do at the start of this file is to connect.
4+
5+
Connect-BlueSky
6+
7+
# If $env:AT_PROTOCOL_HANDLE or $env:AT_PROTOCOL_EMAIL is set, it will be treated as the username
8+
# If $env:AT_PROTOCOL_APP_PASSWORD is set, it will be treated as the App Password.
9+
# _Never_ use your actual BlueSky password
10+
11+
# Once we're connected, we can do anything our app password allows.
12+
13+
# However, you _might_ want to output some information first, so that you can see you're connected.
14+
15+
Get-BskyActorProfile -Actor $env:AT_PROTOCOL_HANDLE -Cache | Out-Host
16+
17+
# To ensure you're not going to send a skeet on every checkin, it's a good idea to ask what GitHub is up to
18+
19+
# There will be a variable, $GitHubEvent, that contains information about the event.
20+
21+
# A fairly common scenario is to perform an annoucement whenever a PR is merged.
22+
23+
$isMergeToMain =
24+
($gitHubEvent.head_commit.message -match "Merge Pull Request #(?<PRNumber>\d+)") -and
25+
$gitHubEvent.ref -eq 'refs/heads/main'
26+
27+
if ($isMergeToMain) {
28+
$psaModule = Get-Module PSA
29+
30+
$fullMessage = @(
31+
"PowerShell just got a little more Posh",
32+
"The Shell just got a little more sweet",
33+
"PowerShell just got more color in it's cheeks",
34+
"PowerShell just got a bit more pretty" | Get-Random
35+
36+
"Posh $($psaModule.Version) is out!"
37+
)
38+
39+
Send-AtProto -Text $fullMessage -WebCard @{
40+
Url = "https://github.com/StartAutomating/Posh"
41+
} -LinkPattern @{
42+
"Posh" = "https://github.com/StartAutomating/Posh"
43+
}
44+
45+
return
46+
}

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## Posh 0.1.9: Posh Community
2+
3+
* New Blog: Christian Ritter ( thanks @HCRitter ! )
4+
5+
* Additions to all community modules (when Posh is also loaded)
6+
* PSModuleInfo.Presentation (#262)
7+
* Module Profiles (#273)
8+
* Installable Recommendations (#233)
9+
10+
* Posh now runs any .ModuleProfiles at the end of it's import (#164)
11+
12+
* Integrated [PSA](https://github.com/StartAutomating/PSA) for automated annoucements on BlueSky.
13+
14+
---
15+
116
## Posh 0.1.8: Posh Formatting
217

318
* New Formatting:

Posh.ps.psm1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,16 @@ $poshCommands =
8585

8686
$posh | Add-Member NoteProperty Commands $poshCommands -Force
8787

88-
Export-ModuleMember -Variable posh
88+
$exportedVariables = @('posh')
89+
90+
$hasModuleProfiles = $posh.ModuleProfiles
91+
if ($hasModuleProfiles) {
92+
foreach ($moduleProfile in $hasModuleProfiles) {
93+
. $moduleProfile
94+
}
95+
}
96+
97+
Export-ModuleMember -Variable $exportedVariables
8998

9099
$posh.OnRemove = {
91100

Posh.psd1

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.1.8'
2+
ModuleVersion = '0.1.9'
33
FormatsToProcess = 'Posh.format.ps1xml'
44
TypesToProcess = 'Posh.types.ps1xml'
55
RootModule = 'Posh.psm1'
@@ -15,15 +15,18 @@
1515
IconURI = 'https://raw.githubusercontent.com/StartAutomating/Posh/main/Assets/Posh.png'
1616
Tags = 'Posh', '.ps1xml', 'Format','Output','Types', 'Colorized', 'Prompt', 'Customization'
1717
ReleaseNotes = @'
18-
## Posh 0.1.8: Posh Formatting
18+
## Posh 0.1.9: Posh Community
1919
20-
* New Formatting:
21-
* Get-Service shows up in color! (#265)
22-
* Get-Event gets a table formatter (and .EventID, .SourceID, .Time) (#268)
23-
* Get-FileHash groups by algorithm and autosizes (#270)
24-
* Improving Formatting:
25-
* Get-Command now shows Source, not Module (#266) ( thanks @ehmiiz ! )
26-
* Improving Enclosure Support in Links (#272)
20+
* New Blog: Christian Ritter ( thanks @HCRitter ! )
21+
22+
* Additions to all community modules (when Posh is also loaded)
23+
* PSModuleInfo.Presentation (#262)
24+
* Module Profiles (#273)
25+
* Installable Recommendations (#233)
26+
27+
* Posh now runs any .ModuleProfiles at the end of it's import (#164)
28+
29+
* Integrated [PSA](https://github.com/StartAutomating/PSA) for automated annoucements on BlueSky.
2730
2831
---
2932
@@ -85,7 +88,8 @@ More History in [CHANGELOG](https://github.com/StartAutomating/Posh/blob/main/CH
8588
@{"Pipe How"="https://pipe.how/index.xml"},
8689
@{"PowerShell is Fun"="https://powershellisfun.com/feed/"},
8790
@{"PowerShell Weekly"="https://psweekly.dowst.dev/feed/"},
88-
@{"Stefan Stranger"="https://stefanstranger.github.io/feed"}
91+
@{"Stefan Stranger"="https://stefanstranger.github.io/feed"},
92+
@{"Christian Ritter"="https://devdojo.com/feed/hcritter"}
8993

9094
# Got more News? Feel free to file an issue and open a PR to add your feed.
9195

Posh.psm1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,16 @@ $poshCommands =
8989

9090
$posh | Add-Member NoteProperty Commands $poshCommands -Force
9191

92-
Export-ModuleMember -Variable posh
92+
$exportedVariables = @('posh')
93+
94+
$hasModuleProfiles = $posh.ModuleProfiles
95+
if ($hasModuleProfiles) {
96+
foreach ($moduleProfile in $hasModuleProfiles) {
97+
. $moduleProfile
98+
}
99+
}
100+
101+
Export-ModuleMember -Variable $exportedVariables
93102

94103
$posh.OnRemove = {
95104

Posh.types.ps1xml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,6 +2651,35 @@ Pipe $Posh.Prompt to Get-Member to see what it can do.</Value>
26512651
</NoteProperty>
26522652
</Members>
26532653
</Type>
2654+
<Type>
2655+
<Name>Posh.Recommendation</Name>
2656+
<Members>
2657+
<AliasProperty>
2658+
<Name>Update</Name>
2659+
<ReferencedMemberName>Install</ReferencedMemberName>
2660+
</AliasProperty>
2661+
<ScriptMethod>
2662+
<Name>Install</Name>
2663+
<Script>
2664+
&lt;#
2665+
.SYNOPSIS
2666+
Installs the recommended module
2667+
.DESCRIPTION
2668+
Uses Install-Module to install the recommended module.
2669+
#&gt;
2670+
param(
2671+
2672+
)
2673+
2674+
if ($this.Name -and -not $this.Url) {
2675+
Install-Module $this.Name -Scope CurrentUser -Force
2676+
}
2677+
2678+
2679+
</Script>
2680+
</ScriptMethod>
2681+
</Members>
2682+
</Type>
26542683
<Type>
26552684
<Name>Posh.RSS.Article</Name>
26562685
<Members>
@@ -3415,6 +3444,51 @@ $this.LinkList(@(
34153444

34163445
</GetScriptBlock>
34173446
</ScriptProperty>
3447+
<ScriptProperty>
3448+
<Name>ModuleProfile</Name>
3449+
<GetScriptBlock>
3450+
&lt;#
3451+
.SYNOPSIS
3452+
Gets a Module's Profile
3453+
.DESCRIPTION
3454+
Gets the profile file associated with the module.
3455+
3456+
Any module can have a file within the same directory as $profile, named `$($this.Name).profile.ps1`.
3457+
3458+
This file may be loaded when the module loads, or anytime thereafter.
3459+
#&gt;
3460+
if (-not $profile) { return ''}
3461+
($profile |
3462+
Split-Path |
3463+
Join-Path -ChildPath "$($this.Name).profile.ps1"
3464+
).ToString()
3465+
</GetScriptBlock>
3466+
</ScriptProperty>
3467+
<ScriptProperty>
3468+
<Name>ModuleProfiles</Name>
3469+
<GetScriptBlock>
3470+
&lt;#
3471+
.SYNOPSIS
3472+
Gets a Module's Profiles
3473+
.DESCRIPTION
3474+
Gets the profile files associated with the module.
3475+
3476+
Any module can have a file within the same directory any valid $profile location, named `$($this.Name).profile.ps1`.
3477+
3478+
This file may be loaded when the module loads, or anytime thereafter.
3479+
#&gt;
3480+
if (-not $profile) { return @()}
3481+
,@(@($profile.psobject.properties |
3482+
Where-Object MemberType -EQ NoteProperty |
3483+
Select-Object -ExpandProperty Value) -as [io.fileinfo[]] |
3484+
Split-Path |
3485+
Select-Object -Unique |
3486+
Where-Object { $_ } |
3487+
Join-Path -ChildPath "$($this.Name).profile.ps1" |
3488+
Where-Object { $_ | Test-Path } |
3489+
ForEach-Object { $_.FullName })
3490+
</GetScriptBlock>
3491+
</ScriptProperty>
34183492
<ScriptProperty>
34193493
<Name>News</Name>
34203494
<GetScriptBlock>
@@ -3445,6 +3519,22 @@ if (-not $this.'.News') {
34453519
$this.'.News'
34463520
</GetScriptBlock>
34473521
</ScriptProperty>
3522+
<ScriptProperty>
3523+
<Name>Presentation</Name>
3524+
<GetScriptBlock>
3525+
&lt;#
3526+
.SYNOPSIS
3527+
Gets module presentations
3528+
.DESCRIPTION
3529+
Gets PowerPoint presentations and templates located within a PowerShell module.
3530+
#&gt;
3531+
$this |
3532+
Split-Path |
3533+
Get-ChildItem -Recurse |
3534+
Where-Object Extension -In '.pptx', '.potx','.ppt' |
3535+
Select-Object -Unique
3536+
</GetScriptBlock>
3537+
</ScriptProperty>
34483538
<ScriptProperty>
34493539
<Name>Preset</Name>
34503540
<GetScriptBlock>

Tests/Posh.News.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe "Posh News" {
77
it "Only has blogs that have articles" {
88
foreach ($feed in $Posh.News.All) {
99
if (-not $feed.Article) {
10-
throw "$($feed.Name) has no articles!"
10+
Write-Warning "$($feed.Name) has no articles!"
1111
}
1212
}
1313
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<#
2+
.SYNOPSIS
3+
Gets a Module's Profile
4+
.DESCRIPTION
5+
Gets the profile file associated with the module.
6+
7+
Any module can have a file within the same directory as $profile, named `$($this.Name).profile.ps1`.
8+
9+
This file may be loaded when the module loads, or anytime thereafter.
10+
#>
11+
if (-not $profile) { return ''}
12+
($profile |
13+
Split-Path |
14+
Join-Path -ChildPath "$($this.Name).profile.ps1"
15+
).ToString()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<#
2+
.SYNOPSIS
3+
Gets a Module's Profiles
4+
.DESCRIPTION
5+
Gets the profile files associated with the module.
6+
7+
Any module can have a file within the same directory any valid $profile location, named `$($this.Name).profile.ps1`.
8+
9+
This file may be loaded when the module loads, or anytime thereafter.
10+
#>
11+
if (-not $profile) { return @()}
12+
,@(@($profile.psobject.properties |
13+
Where-Object MemberType -EQ NoteProperty |
14+
Select-Object -ExpandProperty Value) -as [io.fileinfo[]] |
15+
Split-Path |
16+
Select-Object -Unique |
17+
Where-Object { $_ } |
18+
Join-Path -ChildPath "$($this.Name).profile.ps1" |
19+
Where-Object { $_ | Test-Path } |
20+
ForEach-Object { $_.FullName })
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<#
2+
.SYNOPSIS
3+
Gets module presentations
4+
.DESCRIPTION
5+
Gets PowerPoint presentations and templates located within a PowerShell module.
6+
#>
7+
$this |
8+
Split-Path |
9+
Get-ChildItem -Recurse |
10+
Where-Object Extension -In '.pptx', '.potx','.ppt' |
11+
Select-Object -Unique

Types/Posh.Recommendation/Alias.psd1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
"Update" = "Install"
3+
}

Types/Posh.Recommendation/Install.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<#
2+
.SYNOPSIS
3+
Installs the recommended module
4+
.DESCRIPTION
5+
Uses Install-Module to install the recommended module.
6+
#>
7+
param(
8+
9+
)
10+
11+
if ($this.Name -and -not $this.Url) {
12+
Install-Module $this.Name -Scope CurrentUser -Force
13+
}
14+

docs/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## Posh 0.1.9: Posh Community
2+
3+
* New Blog: Christian Ritter ( thanks @HCRitter ! )
4+
5+
* Additions to all community modules (when Posh is also loaded)
6+
* PSModuleInfo.Presentation (#262)
7+
* Module Profiles (#273)
8+
* Installable Recommendations (#233)
9+
10+
* Posh now runs any .ModuleProfiles at the end of it's import (#164)
11+
12+
* Integrated [PSA](https://github.com/StartAutomating/PSA) for automated annoucements on BlueSky.
13+
14+
---
15+
116
## Posh 0.1.8: Posh Formatting
217

318
* New Formatting:

0 commit comments

Comments
 (0)