Skip to content

Commit 502d401

Browse files
committed
chore: Remove module function that just displayed module description.
feat: Add proper help to module function. test: Update tests to test the module function for creating new repos. docs: Remove completed TODOs from ReadMe
1 parent 18ac875 commit 502d401

File tree

5 files changed

+75
-26
lines changed

5 files changed

+75
-26
lines changed

ReadMe.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,17 @@ Buy me a hot apple cider for providing this template open source and for free
108108

109109
Things to still do:
110110

111+
- Allow using a custom PowerShell Gallery feed URL.
111112
- Create new deployment on tag creation maybe
112113
- Add instructions for how to assign version number in the contributing docs depending on if they are using actions or pipelines
113114
- Prompt user for module name, org name, pipelines or actions, PowerShell gallery or custom feed with an option to leave it blank to - fill it in later
114-
- Show instructions for granting GitHub permissions etc. during the prompt script
115-
- Rename function to Get-TemplateDescription or similar and have it explain the module and a link to it.
116115
- Make azure DevOps and GitHub steps in the ReadMe collapsible.
117116
Have screenshots and link to recording of the setup in both, since they involve clicking around in the UI.
118117
Perhaps link to [this tutorial](https://dev.to/olalekan_oladiran_d74b7a6/how-to-enable-continuous-integration-with-azure-pipelines-1doi)?
119118
- In the ReadMe setup instructions or above, have a sentence or two explaining the layout of the ReadMe, or maybe a table of contents
120119
- Add some badges as well to the ReadMe.
121120
- Look at improving GitHub issue and PR templates: https://raw.githubusercontent.com/PowerShell/vscode-powershell/main/.github/ISSUE_TEMPLATE/bug-report.yml
122-
- Update the module to be able to create new repos without using GitHub template. Have a New-PowerShellScriptModuleRepository cmdlet
123121
- To prevent having to store CI/CD manual setup images in the repo, maybe have them as an external link to a GitHub branch.
124122
- Also create videos showing how to do the setup.
123+
- Maybe show instructions for setting up GitHub / Azure DevOps CI/CD during the initialization script. Or mention to follow the ReadMe instructions.
125124
- Add a simple PowerShell devcontainer for both this repo and the template.

deploy/Invoke-SmokeTests.ps1

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,25 @@ BeforeAll {
1313
# Import-Module "$PSScriptRoot\..\src\Template.PowerShell.ScriptModule" -Force
1414
}
1515

16-
Describe 'Get-TemplateDescription' {
17-
It 'Should return "Hello, World!"' {
18-
$result = Get-TemplateDescription
19-
$result | Should -Not -BeNullOrEmpty
16+
Describe 'New-PowerShellScriptModuleRepository' {
17+
It 'Should create a new directory with the module repository files' {
18+
# Arrange.
19+
$repositoryDirectoryPath = "$TestDrive\NewModule"
20+
$moduleName = 'NewModule'
21+
$organizationName = 'My Organization'
22+
23+
$expectedModuleDirectoryPath = Join-Path -Path $repositoryDirectoryPath -ChildPath "src\$moduleName"
24+
$expectedModuleFilePath = Join-Path -Path $expectedModuleDirectoryPath -ChildPath "$moduleName.psm1"
25+
$expectedModuleManifestFilePath = Join-Path -Path $expectedModuleDirectoryPath -ChildPath "$moduleName.psd1"
26+
$expectedModuleTestsFilePath = Join-Path -Path $expectedModuleDirectoryPath -ChildPath "$moduleName.Tests.ps1"
27+
28+
# Act.
29+
New-PowerShellScriptModuleRepository -RepositoryDirectoryPath $repositoryDirectoryPath -ModuleName $moduleName -OrganizationName $organizationName
30+
31+
# Assert.
32+
$expectedModuleDirectoryPath | Should -Exist
33+
$expectedModuleFilePath | Should -Exist
34+
$expectedModuleManifestFilePath | Should -Exist
35+
$expectedModuleTestsFilePath | Should -Exist
2036
}
2137
}
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
using module './Template.PowerShell.ScriptModule.psm1'
22

3-
Describe 'Get-TemplateDescription' {
4-
It 'Should return "Hello, World!"' {
5-
$result = Get-TemplateDescription
6-
$result | Should -Not -BeNullOrEmpty
3+
Describe 'New-PowerShellScriptModuleRepository' {
4+
It 'Should create a new directory with the module repository files' {
5+
# Arrange.
6+
$repositoryDirectoryPath = "$TestDrive\NewModule"
7+
$moduleName = 'NewModule'
8+
$organizationName = 'My Organization'
9+
10+
$expectedModuleDirectoryPath = Join-Path -Path $repositoryDirectoryPath -ChildPath "src\$moduleName"
11+
$expectedModuleFilePath = Join-Path -Path $expectedModuleDirectoryPath -ChildPath "$moduleName.psm1"
12+
$expectedModuleManifestFilePath = Join-Path -Path $expectedModuleDirectoryPath -ChildPath "$moduleName.psd1"
13+
$expectedModuleTestsFilePath = Join-Path -Path $expectedModuleDirectoryPath -ChildPath "$moduleName.Tests.ps1"
14+
15+
# Act.
16+
New-PowerShellScriptModuleRepository -RepositoryDirectoryPath $repositoryDirectoryPath -ModuleName $moduleName -OrganizationName $organizationName
17+
18+
# Assert.
19+
$expectedModuleDirectoryPath | Should -Exist
20+
$expectedModuleFilePath | Should -Exist
21+
$expectedModuleManifestFilePath | Should -Exist
22+
$expectedModuleTestsFilePath | Should -Exist
723
}
824
}

src/Template.PowerShell.ScriptModule/Template.PowerShell.ScriptModule.psd1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ Checkout the template repository at https://github.com/deadlydog/Template.PowerS
6868

6969
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
7070
FunctionsToExport = @(
71-
'Get-TemplateDescription'
7271
'New-PowerShellScriptModuleRepository'
7372
)
7473

src/Template.PowerShell.ScriptModule/Template.PowerShell.ScriptModule.psm1

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,45 @@
1-
# This is just example code. Run the _InitializeRepository.ps1 script to replace this file with your module.
2-
3-
function Get-TemplateDescription
1+
function New-PowerShellScriptModuleRepository
42
{
5-
[CmdletBinding()]
6-
Param ()
3+
<#
4+
.SYNOPSIS
5+
Creates a new PowerShell script module repository directory with boilerplate files and CI/CD workflows already defined.
76
8-
[string] $description = @'
9-
This module is part of a template git repository that you can use to create new PowerShell script module repos quickly and easily with boilerplate files and CI/CD workflows already defined.
7+
.DESCRIPTION
8+
This function creates a new PowerShell script module repository with boilerplate files and CI/CD workflows already defined. This allows you to create new PowerShell script modules quickly and easily.
109
11-
For more information, visit the repository at https://github.com/deadlydog/Template.PowerShell.ScriptModule.
12-
'@
10+
Once the directory is created, you can run `git init` in it to initialize it as a git repository, and then push it to your own git server.
1311
14-
Write-Output $description
15-
}
12+
You will then need to follow the instructions in the ReadMe.md file to finish setting up the repository.
1613
17-
function New-PowerShellScriptModuleRepository
18-
{
14+
.PARAMETER RepositoryDirectoryPath
15+
The path to the new directory that should be created for the module repository.
16+
17+
.PARAMETER ModuleName
18+
The name of the module to create.
19+
20+
.PARAMETER OrganizationName
21+
The name of the individual or organization that owns the module.
22+
23+
.EXAMPLE
24+
PS> New-PowerShellScriptModuleRepository -RepositoryDirectoryPath 'C:\MyNewModule' -ModuleName 'MyNewModule' -OrganizationName 'My Name'
25+
26+
Creates a new module repository at 'C:\MyNewModule' with the module name 'MyNewModule' and the organization name 'My Name'.
27+
28+
.INPUTS
29+
None. You cannot pipe objects to New-PowerShellScriptModuleRepository.
30+
31+
.OUTPUTS
32+
None. New-PowerShellScriptModuleRepository does not return any output.
33+
It creates a new directory with the module repository files.
34+
35+
.LINK
36+
https://github.com/deadlydog/Template.PowerShell.ScriptModule
37+
#>
1938
[CmdletBinding()]
2039
[Alias('New-PSRepository')]
2140
Param
2241
(
23-
[Parameter(Mandatory = $true, HelpMessage = "The path to the directory where the module repository should be created.")]
42+
[Parameter(Mandatory = $true, HelpMessage = "The path to the new directory that should be created for the module repository.")]
2443
[ValidateNotNullOrEmpty()]
2544
[string] $RepositoryDirectoryPath,
2645

0 commit comments

Comments
 (0)