Skip to content

Commit 2442d84

Browse files
committed
docs: update readme files; fix issues found when updating readme files
1 parent 8a9042d commit 2442d84

File tree

12 files changed

+141
-21
lines changed

12 files changed

+141
-21
lines changed

.github/workflows/github-actions-push.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ jobs:
5454
- name: Install Requirements
5555
working-directory: ${{ github.workspace }}
5656
run: ./build/scripts/Install-Requirements.ps1
57+
- name: Test PowerShell Module Manifest
58+
run: ./../../../build/scripts/Test-PowerShellModuleManifest.ps1
5759
- name: Pester Tests
5860
run: ./../../../build/scripts/Test-PowerShell.ps1
5961
- name: PSScriptAnalyzer
@@ -117,4 +119,4 @@ jobs:
117119
run: |
118120
./build/scripts/Publish-Package.ps1 -PackagePath "a/${{ env.ARTIFACT_NAME }}/${{ env.PACKAGE_NAME }}"
119121
env:
120-
NUGETSOURCE: ${{ vars.NUGETSOURCE }}
122+
NUGETSOURCE: ${{ vars.NUGETSOURCE }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Custom PowerShell template for dotnet new.
55
# Local Testing
66

77
```powershell
8-
nuget pack Compendium.PowerShell.nuspec -NoDefaultExcludes -OutputFileNamesWithoutVersion -Version 1.0.0
9-
dotnet new install Compendium.PowerShell.nupkg
8+
nuget pack Compendium.PowerShell.nuspec -NoDefaultExcludes -Version 0.0.1
9+
dotnet new install Compendium.PowerShell.0.0.1.nupkg
1010
dotnet new uninstall Compendium.PowerShell
1111
```

build/scripts/Test-PowerShell.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Invoke-Pester
1+
Invoke-Pester
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test-ModuleManifest -Path './Compendium.ps1'

src/Compendium.PowerShell.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<file src="Compendium.PowerShell\Compendium\Classes\Compendium.ps1" target="content\Compendium\Classes\Compendium.ps1" />
2626
<file src="Compendium.PowerShell\Compendium\Private\Test-CompendiumName.ps1" target="content\Compendium\Private\Test-CompendiumName.ps1" />
2727
<file src="Compendium.PowerShell\Compendium\Public\Find-Compendium.ps1" target="content\Compendium\Public\Find-Compendium.ps1" />
28-
<file src="Compendium.PowerShell\Compendium\Test\Compendium.Tag.Tests.ps1" target="content\Compendium\Test\Compendium.Tag.Tests.ps1" />
28+
<file src="Compendium.PowerShell\Compendium\Test\Compendium.GetTag.Tests.ps1" target="content\Compendium\Test\Compendium.GetTag.Tests.ps1" />
2929
<file src="Compendium.PowerShell\Compendium\Test\Find-Compendium.Tests.ps1" target="content\Compendium\Test\Find-Compendium.Tests.ps1" />
3030
</files>
3131
</package>
Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,62 @@
1-
PowerShell template for dotnet new.
1+
# PowerShell Module
2+
3+
This dotnet template will create a new PowerShell module with boilerplate setup for the module and data files. Please make sure to fill in the data file fields and attributes for `Author`, `Description`, `Tags`, and any other relevant fields. Additionally, stubs for a class, public, and private functions as well as Pester tests have been created to get you up and running quickly.
4+
5+
## Getting Started
6+
7+
The following guide will get you started using the template, how to run Pester tests, and how to add classes and functions.
8+
9+
### dotnet new
10+
11+
To set up a new PowerShell module using the dotnet template run the following command
12+
13+
`dotnet new powershell --moduleName <name>`
14+
15+
### Quickstart
16+
17+
example:
18+
19+
```powershell
20+
dotnet new powershell --moduleName Book
21+
Import-Module -Name 'Pester' # Make sure you are using the latest version of Pester (eg >= 5.7), see: https://pester.dev/docs/introduction/installation
22+
Invoke-Pester -Path './Book'
23+
Import-Module -Name './Book'
24+
$books = @(
25+
[Book]::new('Book 1', @{ powershell = 'module' })
26+
[Book]::new('Book 2', @{ powershell = 'module' })
27+
)
28+
$books[1].Name
29+
$books | Find-Book -Name 'Book 1'
30+
```
31+
32+
### Adding Classes
33+
34+
Add new classes in the `Classes` folder. Once a new class has been added and you want it to be available when a user imports the module make sure to add it to the `$ExportableTypes` variable in the module file.
35+
36+
### Adding Functions
37+
38+
Public functions should be added in the `Public` folder. New functions also need to be added to the `FunctionsToExport` field in the data file. Private functions should be added in the `Private` folder and will only be accessible from within the module itself.
39+
40+
### Testing
41+
42+
This template comes with boilerplate tests using Pester for the built in files which tests both a function and a method of the class. Make sure you are using the latest version of Pester (`>= 5.7`) - Pester comes pre-installed on Windows 10/Windows Server 2016 with an older version by default and newer versions can be installed side-by-side, see [https://pester.dev/docs/introduction/installation](https://pester.dev/docs/introduction/installation) for installation details.
43+
44+
## Template
45+
46+
The template contains the following folder structure:
47+
48+
```text
49+
.
50+
├── <module-name>/<module-name>.psd1
51+
├── <module-name>/<module-name>.psm1
52+
├── <module-name>/README.md
53+
├── <module-name>/Classes/
54+
│ ├── <module-name>.ps1
55+
├── <module-name>/Private/
56+
│ ├── Test-<module-name>.ps1
57+
├── <module-name>/Public/
58+
│ ├── Find-<module-name>.ps1
59+
├── <module-name>/Test/
60+
│ ├── <module-name>.GetTag.Tests.ps1
61+
│ ├── Find-<module-name>.Tests.ps1
62+
```

src/Compendium.PowerShell/Compendium/Classes/Compendium.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Compendium {
1616
}
1717
}
1818

19-
[object] Tag([string] $key) {
19+
[object] GetTag([string] $key) {
2020
Write-Verbose -Message "Called `$this.Tag($key)"
2121

2222
return $this.Tags.$key

src/Compendium.PowerShell/Compendium/Compendium.psm1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ param()
33

44
Write-Verbose -Message $PSScriptRoot
55

6-
Write-Verbose -Message "Import types using TypeAccelerators"
7-
8-
# Define the types to export with type accelerators.
9-
106
Write-Verbose -Message 'Import everything in sub folders folder'
117
foreach($Folder in @('Classes', 'Private', 'Public'))
128
{
@@ -24,6 +20,10 @@ foreach($Folder in @('Classes', 'Private', 'Public'))
2420

2521
Export-ModuleMember -Function (Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1").BaseName
2622

23+
Write-Verbose -Message "Import types using TypeAccelerators"
24+
25+
# Define the types to export with type accelerators.
26+
2727
$ExportableTypes = @(
2828
[Compendium]
2929
)

src/Compendium.PowerShell/Compendium/Public/Find-Compendium.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
.Example
1515
# Find by name
16-
@([Compendium]::new('Atelier', @('page 1'))) | Find-Compendium -Name 'Atelier'
16+
@([Compendium]::new('Atelier', @{'tag' = 'value'})) | Find-Compendium -Name 'Atelier'
1717
#>
1818
function Find-Compendium {
1919
[CmdletBinding()]
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# PowerShell Module
2+
3+
This dotnet template will create a new PowerShell module with boilerplate setup for the module and data files. Please make sure to fill in the data file fields and attributes for `Author`, `Description`, `Tags`, and any other relevant fields. Additionally, stubs for a class, public, and private functions as well as Pester tests have been created to get you up and running quickly.
4+
5+
## Getting Started
6+
7+
The following guide will get you started using the template, how to run Pester tests, and how to add classes and functions.
8+
9+
### dotnet new
10+
11+
To set up a new PowerShell module using the dotnet template run the following command
12+
13+
`dotnet new powershell --moduleName <name>`
14+
15+
### Quickstart
16+
17+
example:
18+
19+
```powershell
20+
dotnet new powershell --moduleName Book
21+
Import-Module -Name 'Pester' # Make sure you are using the latest version of Pester (eg >= 5.7), see: https://pester.dev/docs/introduction/installation
22+
Invoke-Pester -Path './Book'
23+
Import-Module -Name './Book'
24+
$books = @(
25+
[Book]::new('Book 1', @{ powershell = 'module' })
26+
[Book]::new('Book 2', @{ powershell = 'module' })
27+
)
28+
$books[1].Name
29+
$books | Find-Book -Name 'Book 1'
30+
```
31+
32+
### Adding Classes
33+
34+
Add new classes in the `Classes` folder. Once a new class has been added and you want it to be available when a user imports the module make sure to add it to the `$ExportableTypes` variable in the module file.
35+
36+
### Adding Functions
37+
38+
Public functions should be added in the `Public` folder. New functions also need to be added to the `FunctionsToExport` field in the data file. Private functions should be added in the `Private` folder and will only be accessible from within the module itself.
39+
40+
### Testing
41+
42+
This template comes with boilerplate tests using Pester for the built in files which tests both a function and a method of the class. Make sure you are using the latest version of Pester (`>= 5.7`) - Pester comes pre-installed on Windows 10/Windows Server 2016 with an older version by default and newer versions can be installed side-by-side, see [https://pester.dev/docs/introduction/installation](https://pester.dev/docs/introduction/installation) for installation details.
43+
44+
## Documentation
45+
46+
For PowerShell documentation see, [https://learn.microsoft.com/en-us/powershell/scripting/how-to-use-docs?view=powershell-7.5](https://learn.microsoft.com/en-us/powershell/scripting/how-to-use-docs?view=powershell-7.5).
47+
48+
See [https://learn.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest?view=powershell-7.5](https://learn.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest?view=powershell-7.5) for details on writing a PowerShell module manifest.
49+
50+
For more information about using type accelerators to export classes see, [https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_classes?view=powershell-7.5#exporting-classes-with-type-accelerators](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_classes?view=powershell-7.5#exporting-classes-with-type-accelerators).
51+
52+
For details about PowerShell classes see, [https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_classes?view=powershell-7.5](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_classes?view=powershell-7.5).
53+
54+
For comment based help see, [https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help?view=powershell-7.5](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help?view=powershell-7.5).
55+
56+
For documentation and information about PowerShell Pester testing see, [https://pester.dev/](https://pester.dev/) and for more details about creatig unit tests within modules see, [https://pester.dev/docs/usage/modules](https://pester.dev/docs/usage/modules).

0 commit comments

Comments
 (0)