Skip to content

Commit f1e2935

Browse files
Updates
1 parent 31a9bb0 commit f1e2935

File tree

12 files changed

+52
-12
lines changed

12 files changed

+52
-12
lines changed

PSModuleDevelopment/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
- New: Search-PSMDPropertyValue - search objects for values in properties
55
- Upd: Template PSFTest - adding WMI commands to list of forbidden commands
66
- Upd: Template PSFModule - adding changelog
7+
- Upd: Template PSFModule - adding strings for localization
8+
- Upd: Template PSFModule - adding scriptblocks
9+
- Upd: Template PSFProject - updated build txt files to include new module content
10+
- Fix: Template PSMTest - replacing all -Filter calls on Get-ChildItem
711
- Fix: New-PSMDTemplate records binary files as text files
812

913
## 2.2.5.41 (December 18th, 2018)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This is where the strings go, that are written by
2+
# Write-PSFMessage, Stop-PSFFunction or the PSFramework validation scriptblocks
3+
@{
4+
'key' = 'Value'
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<#
2+
Stored scriptblocks are available in [PsfValidateScript()] attributes.
3+
This makes it easier to centrally provide the same scriptblock multiple times,
4+
without having to maintain it in separate locations.
5+
6+
It also prevents lengthy validation scriptblocks from making your parameter block
7+
hard to read.
8+
9+
Set-PSFScriptblock -Name 'þnameþ.ScriptBlockName' -Scriptblock {
10+
11+
}
12+
#>
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
# Add all things you want to run after importing the main code
22

33
# Load Configurations
4-
foreach ($file in (Get-ChildItem "$ModuleRoot\internal\configurations\*.ps1" -ErrorAction Ignore)) {
4+
foreach ($file in (Get-ChildItem "$($script:ModuleRoot)\internal\configurations\*.ps1" -ErrorAction Ignore)) {
5+
. Import-ModuleFile -Path $file.FullName
6+
}
7+
8+
# Load Scriptblocks
9+
foreach ($file in (Get-ChildItem "$($script:ModuleRoot)\internal\scriptblocks\*.ps1" -ErrorAction Ignore)) {
510
. Import-ModuleFile -Path $file.FullName
611
}
712

813
# Load Tab Expansion
9-
foreach ($file in (Get-ChildItem "$ModuleRoot\internal\tepp\*.tepp.ps1" -ErrorAction Ignore)) {
14+
foreach ($file in (Get-ChildItem "$($script:ModuleRoot)\internal\tepp\*.tepp.ps1" -ErrorAction Ignore)) {
1015
. Import-ModuleFile -Path $file.FullName
1116
}
1217

1318
# Load Tab Expansion Assignment
14-
. Import-ModuleFile -Path "$ModuleRoot\internal\tepp\assignment.ps1"
19+
. Import-ModuleFile -Path "$($script:ModuleRoot)\internal\tepp\assignment.ps1"
1520

1621
# Load License
17-
. Import-ModuleFile -Path "$ModuleRoot\internal\scripts\license.ps1"
22+
. Import-ModuleFile -Path "$($script:ModuleRoot)\internal\scripts\license.ps1"
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
# Add all things you want to run before importing the main code
1+
# Add all things you want to run before importing the main code
2+
3+
# Load the strings used in messages
4+
. Import-ModuleFile -Path "$($script:ModuleRoot)\internal\scripts\strings.ps1"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<#
2+
This file loads the strings documents from the respective language folders.
3+
This allows localizing messages and errors.
4+
Load psd1 language files for each language you wish to support.
5+
Partial translations are acceptable - when missing a current language message,
6+
it will fallback to English or another available language.
7+
#>
8+
Import-PSFLocalizedString -Path "$($script:ModuleRoot)\en-us\*.psd1" -Module 'þnameþ' -Language 'en-US'

templates/PSFProject/build/filesAfter.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# In the order they are loaded during postimport
33

44
internal\configurations\*.ps1
5+
internal\scriptblocks\*.ps1
56
internal\tepp\*.tepp.ps1
67
internal\tepp\assignment.ps1
78
internal\scripts\license.ps1
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# List all files that are loaded in the preimport.ps1
2-
# In the order they are loaded during preimport
2+
# In the order they are loaded during preimport
3+
4+
internal\scripts\strings.ps1

templates/PSFTests/general/FileIntegrity.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function Get-FileEncoding
3333

3434
Describe "Verifying integrity of module files" {
3535
Context "Validating PS1 Script files" {
36-
$allFiles = Get-ChildItem -Path $moduleRoot -Recurse -Filter "*.ps1" | Where-Object FullName -NotLike "$moduleRoot\tests\*"
36+
$allFiles = Get-ChildItem -Path $moduleRoot -Recurse | Where-Object Name -like "*.ps1" | Where-Object FullName -NotLike "$moduleRoot\tests\*"
3737

3838
foreach ($file in $allFiles)
3939
{
@@ -72,7 +72,7 @@ Describe "Verifying integrity of module files" {
7272
}
7373

7474
Context "Validating help.txt help files" {
75-
$allFiles = Get-ChildItem -Path $moduleRoot -Recurse -Filter "*.help.txt" | Where-Object FullName -NotLike "$moduleRoot\tests\*"
75+
$allFiles = Get-ChildItem -Path $moduleRoot -Recurse | Where-Object Name -like "*.help.txt" | Where-Object FullName -NotLike "$moduleRoot\tests\*"
7676

7777
foreach ($file in $allFiles)
7878
{

templates/PSFTests/general/Manifest.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$moduleRoot = (Resolve-Path "$PSScriptRoot\..\..").Path
33
$manifest = ((Get-Content "$moduleRoot\þnameþ.psd1") -join "`n") | Invoke-Expression
44
Context "Basic resources validation" {
5-
$files = Get-ChildItem "$moduleRoot\functions" -Recurse -File -Filter "*.ps1"
5+
$files = Get-ChildItem "$moduleRoot\functions" -Recurse -File | Where-Object Name -like "*.ps1"
66
It "Exports all functions in the public folder" {
77

88
$functions = (Compare-Object -ReferenceObject $files.BaseName -DifferenceObject $manifest.FunctionsToExport | Where-Object SideIndicator -Like '<=').InputObject

0 commit comments

Comments
 (0)