Skip to content

Commit fa538b0

Browse files
authored
🎨 Move to EZOut for formatting (#382)
* 🎨 initial commit for formatting - Add format view for result object - Add build code to generate xml * 🎨 add detailed view * 🎨 Adjust detailed formatting * 🎨 Update formatters + Refactoring on some controls + Added formatting for PSKoans.CompleteResult + All cases tested and looking fancy! * 🔥 Remove unneeded code - Removed Show-MeditationPrompt * ♻️ tidy up ezformat file * 🚀 Fix build script * ✅ Update tests & build script * 🚀 Enable verbose logging in format builder * 🚀 Add verbose logging * 🚀 Tinkering with format generation * 🚀 use built module instead of repo * ✅ Update tests + Remove mocks and checks for Show-MeditationPrompt + Other small fixes for slight behaviour changes * 🚀 -AllowClobber needed for EZOut install
1 parent 8dcd4e8 commit fa538b0

17 files changed

+449
-439
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.vs/
22
.DS_Store/
33
*.temppoint.*
4+
*.format.ps1xml
45
PSKoans.psproj

Build/Build-Module.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Grab nuget bits, set build variables, start build.
22
Get-PackageProvider -Name NuGet -ForceBootstrap > $null
33

4+
# Create format.ps1xml file
5+
& "$PSScriptRoot/../PSKoans.ezformat.ps1"
6+
47
Import-Module "$env:PROJECTROOT/PSKoans"
58

69
Set-BuildEnvironment

Build/Invoke-ModuleTests.ps1

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ Write-Host "STATUS: Testing with PowerShell v$($PSVersionTable.PSVersion)"
66
Write-Host $Lines
77

88
# Import the module and add temporary entry to PSModulePath for build/test purposes
9-
$env:PSModulePath = @(
10-
$env:PROJECTROOT
11-
$env:PSModulePath
12-
) -join [IO.Path]::PathSeparator
139

1410
Import-Module 'PSKoans'
1511

PSKoans.ezformat.ps1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#Requires -Modules EZOut
2+
# Install-Module EZOut
3+
# or https://github.com/StartAutomating/EZOut
4+
5+
$VerbosePreference = 'Continue'
6+
7+
$ModuleName = $MyInvocation.MyCommand.Name -replace '\.ezformat\.ps1', ''
8+
$ModuleFolder = Get-Item -Path "$PSScriptRoot/PSKoans" | Select-Object -ExpandProperty FullName
9+
10+
Write-Verbose "Building format file for '$ModuleName' in '$ModuleFolder'"
11+
12+
$formatting = @(
13+
foreach ($potentialDirectory in 'formatting', 'views') {
14+
$path = Join-Path $PSScriptRoot -ChildPath $potentialDirectory
15+
if (Test-Path $path) {
16+
Get-ChildItem -Path $path | ForEach-Object {
17+
Write-Verbose "Processing file '$($_.FullName)'"
18+
Import-FormatView -FilePath $_.FullName
19+
}
20+
}
21+
}
22+
)
23+
24+
if ($formatting) {
25+
$formatFilePath = Join-Path $ModuleFolder -ChildPath "$ModuleName.format.ps1xml"
26+
Write-Verbose "Writing format file to '$formatFilePath'"
27+
$formatting | Out-FormatData -Module $ModuleName | Set-Content $formatFilePath -Encoding UTF8
28+
}
29+
30+
$types = @(
31+
# Add your own Write-TypeView statements here
32+
)
33+
34+
if ($types) {
35+
$TypesFile = Join-Path $PSScriptRoot "$ModuleName.types.ps1xml"
36+
Write-Verbose "Writing types file to '$TypesFile'"
37+
$types | Out-TypeData | Set-Content $TypesFile -Encoding UTF8
38+
}

PSKoans/Data/Show-MeditationPrompt.Data.psd1

Lines changed: 3 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,5 @@
11
@{
2-
Prompts = @{
3-
Welcome = @"
4-
Welcome, seeker of enlightenment.
5-
Please wait a moment while we examine your karma...
6-
7-
"@
8-
DetailEntry = @"
9-
{0} It {1}
10-
"@
11-
Describe = @"
12-
Describing '{0}' has damaged your karma.
13-
"@
14-
TestFailed = @"
15-
16-
You have not yet reached enlightenment.
17-
18-
The answers you seek...
19-
20-
"@
21-
Meditate = @"
22-
23-
Please meditate on the following code:
24-
25-
"@
26-
Subject = @"
27-
{0} It {1}
28-
{2}
29-
"@
30-
Koan = @"
31-
32-
{0}
33-
34-
"@
35-
Path = @"
36-
You examine the path beneath your feet...
37-
38-
"@
39-
Topic = @"
40-
You must meditate further on your selected topic{0}:
41-
- {1}
42-
43-
"@
44-
OpenFolder = @"
45-
46-
Run 'Show-Karma -Meditate' to begin your meditations.
47-
48-
"@
49-
Completed = @"
50-
Congratulations! You have taken the first steps towards enlightenment.
51-
52-
You cast your gaze back upon the path that you have walked:
53-
54-
"@
55-
CompletedTopic = @"
56-
Congratulations! You have taken the first steps towards enlightenment.
57-
58-
You have completed: {0}
59-
60-
You cast your gaze back upon the path that you have walked...
61-
62-
"@
63-
BookSuggestion = @"
64-
65-
If you would like to further your studies in this manner, consider investing in
66-
'PowerShell by Mistake' by Don Jones - https://leanpub.com/powershell-by-mistake
67-
"@
68-
}
69-
Koans = @(
2+
Koans = @(
703
@'
714
The whole moon and the entire sky
725
Are reflected in one dewdrop on the grass.
@@ -238,7 +171,7 @@ you're not looking long enough.
238171
In order to write good code,
239172
you must become the code.
240173
'@
241-
@'
174+
@'
242175
Mind is not the Buddha,
243176
reason is not the Way.
244177
'@
@@ -249,7 +182,7 @@ that weighs you down.
249182
'@
250183
@'
251184
There are two rules in life:
252-
1. Never give out all of
185+
1. Never give out all of
253186
the information.
254187
'@
255188
@'

PSKoans/Init/ModuleConfiguration.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Write-Verbose 'Importing data strings'
33

44
$ShowMeditationPromptData = Import-PowerShellDataFile -Path "$script:ModuleRoot/Data/Show-MeditationPrompt.Data.psd1"
55
$script:MeditationStrings = $ShowMeditationPromptData['Koans']
6-
$script:MeditationPrompts = $ShowMeditationPromptData['Prompts']
76
Remove-Variable -Name 'ShowMeditationPromptData'
87

98
$Settings = Get-PSKoanSetting

PSKoans/PSKoans.format.ps1xml

Lines changed: 0 additions & 68 deletions
This file was deleted.

PSKoans/PSKoans.psd1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@
127127
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
128128
PrivateData = @{
129129

130+
Colors = @{
131+
132+
Meditation = @{
133+
Text = "#7AAFCA"
134+
Emphasis = "#DACF60"
135+
Passed = "#30DF60"
136+
Error = '#E02020'
137+
Progress = '#CACEFA'
138+
}
139+
140+
}
141+
130142
PSData = @{
131143

132144
# Tags applied to this module. These help with module discovery in online galleries.

0 commit comments

Comments
 (0)